/* ============================================================
   shared.css — Candle Dashboard
   Importado por todas as telas. CSS específico de cada tela
   permanece em bloco <style> dentro do próprio HTML.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Color primitives ────────────────────────────── */
  --slate-50:  #f8fafc;  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;  --slate-500: #64748b;
  --slate-600: #475569;  --slate-700: #334155;
  --slate-800: #1e293b;  --slate-900: #0f172a;

  --green-500:  #16a34a; --green-600: #15803d;
  --green-50:   #f0fdf4; --green-100:  #dcfce7;
  --yellow-500: #f59e0b; --yellow-50:  #fefce8;
  --red-500:    #dc2626; --red-600:    #b91c1c;
  --red-50:     #fef2f2; --red-100:    #fee2e2;
  --blue-500:   #2563eb; --blue-50:    #eff6ff;
  --blue-100:   #dbeafe;
  --orange-500: #f97316;
  --cyan-500:   #06b6d4;

  /* ── Semantic surfaces ───────────────────────────── */
  --bg:             var(--slate-100);
  --bg-secondary:   var(--slate-50);
  --surface:        #ffffff;
  --surface-hover:  var(--slate-50);
  --border:        var(--slate-200);
  --border-focus:  var(--blue-500);

  /* ── Semantic text ──────────────────────────────── */
  --text:          var(--slate-900);
  --text-secondary: var(--slate-600);
  --muted:         var(--slate-500);
  --muted-strong:  var(--slate-400);
  --accent:        var(--slate-900);
  --navy:          var(--slate-900);
  --slate:         var(--slate-500);
  --cyan:          var(--cyan-500);

  /* ── Semantic status colors ─────────────────────── */
  --success:       var(--green-500);
  --success-light: var(--green-50);
  --warning:       var(--yellow-500);
  --warning-light: var(--yellow-50);
  --danger:        var(--red-500);
  --danger-light:  var(--red-50);
  --info:          var(--blue-500);
  --info-light:    var(--blue-50);

  /* ── Legacy aliases (preserve backward compat) ──── */
  --green:  var(--green-500);
  --yellow: var(--yellow-500);
  --red:    var(--red-500);
  --blue:   var(--blue-500);

  /* ── Typography ─────────────────────────────────── */
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:   "SF Mono", "Cascadia Code", "Consolas", monospace;
  --text-xs:     10px;
  --text-sm:     12px;
  --text-base:   13px;
  --text-md:     14px;
  --text-lg:     16px;
  --text-xl:     20px;
  --text-2xl:    24px;
  --text-3xl:    28px;
  --leading-tight: 1.1;
  --leading-normal: 1.5;

  /* ── Spacing scale ──────────────────────────────── */
  --space-0:  0;
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ── Border radius ──────────────────────────────── */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* ── Elevation / shadows ────────────────────────── */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 6px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);

  /* ── Layout ─────────────────────────────────────── */
  --sidebar-collapsed: 48px;
  --sidebar-expanded:  220px;
  --topbar-h:          52px;
  --page-max:          1400px;
  --page-max-narrow:   1200px;

  /* ── Responsive breakpoints (reference only) ────── */
  /*  sm: 640px  |  md: 768px  |  lg: 1024px  |  xl: 1280px  */
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ── App shell ─────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Topbar ────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 12px;
  z-index: 35; transition: left .2s ease, background .2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
@media (min-width: 1024px) { .topbar { left: var(--sidebar-collapsed); } }
@media (min-width: 1024px) { body.sidebar-open .topbar { left: var(--sidebar-expanded); } }

.topbar-menu {
  background: none; border: none; font-size: 20px;
  cursor: pointer; color: var(--text); padding: 6px;
  min-width: 44px; min-height: 44px;
  line-height: 1; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); transition: background .15s;
}
.topbar-menu:hover { background: var(--bg-secondary); }
.topbar-menu:active { background: var(--slate-200); }
.topbar-menu:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
@media (min-width: 1024px) { .topbar-menu { display: none; } }

.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ── App content ───────────────────────────────── */
.app-content { flex: 1; padding-top: var(--topbar-h); min-width: 0; }
@media (min-width: 1024px) { .app-content { margin-left: var(--sidebar-collapsed); transition: margin-left .2s ease; } }
@media (min-width: 1024px) { body.sidebar-open .app-content { margin-left: var(--sidebar-expanded); } }

/* ── Page layout & Spacing ──────────────────────── */
.page { padding: var(--space-6); width: 100%; }
.page-wide  { max-width: var(--page-max); margin: 0 auto; }
.page-narrow { max-width: var(--page-max-narrow); margin: 0 auto; }

.page-header { margin-bottom: var(--space-8); }
.page-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); flex-wrap: wrap; }
.page-title { font-size: var(--text-2xl); font-weight: 800; color: var(--navy); line-height: 1.1; margin-bottom: 4px; }
.page-subtitle { font-size: var(--text-sm); color: var(--slate); font-weight: 500; }

/* ── Toolbar (legacy compat, used across pages) ────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar h1 { font-size: 20px; font-weight: 700; margin-right: auto; }
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.toolbar-spacer { flex: 1; }

.section { margin-bottom: var(--space-10); }
.section-header { margin-bottom: var(--space-5); display: flex; justify-content: space-between; align-items: center; }
.section-title {
  font-size: var(--text-md); font-weight: 700; color: var(--navy);
  margin-bottom: var(--space-3); padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

/* ── Drawer overlay ────────────────────────────── */
.drawer-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4); z-index: 40;
  backdrop-filter: blur(2px); opacity: 0;
  transition: opacity .25s ease;
}
body.drawer-open .drawer-overlay { display: block; opacity: 1; }

/* ── Drawer (mobile) ───────────────────────────── */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
  background: var(--surface); z-index: 50;
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow .3s ease;
  box-shadow: none;
  border-right: 1px solid var(--border);
}
body.drawer-open .drawer { transform: translateX(0); box-shadow: 10px 0 30px rgba(0,0,0,0.1); }

.drawer-logo-area { padding: 16px; border-bottom: 1px solid var(--border); }
.drawer-logo {
  background: var(--accent); color: #fff;
  border-radius: var(--radius); height: 36px;
  display: flex; align-items: center;
  padding: 0 12px; font-size: 13px; font-weight: 700; gap: 8px;
}
.drawer-logo img { height: 22px; width: auto; border-radius: 4px; }

.drawer-items { flex: 1; padding: 8px 0; overflow-y: auto; }
.drawer-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; font-size: 14px;
  color: var(--text); text-decoration: none;
  transition: background .1s;
  min-height: 48px; /* Touch target size */
}
body.drawer-open .drawer-item {
  animation: drawer-item-in .2s ease-out both;
}
body.drawer-open .drawer-item:nth-child(1)  { animation-delay: .04s; }
body.drawer-open .drawer-item:nth-child(2)  { animation-delay: .06s; }
body.drawer-open .drawer-item:nth-child(3)  { animation-delay: .08s; }
body.drawer-open .drawer-item:nth-child(4)  { animation-delay: .10s; }
body.drawer-open .drawer-item:nth-child(5)  { animation-delay: .12s; }
body.drawer-open .drawer-item:nth-child(n+6) { animation-delay: .14s; }

@keyframes drawer-item-in {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}
.drawer-item:hover { background: var(--bg); }
.drawer-item:active { background: var(--slate-200); }
.drawer-item.active { background: var(--bg); font-weight: 600; color: var(--blue); box-shadow: inset 3px 0 0 var(--blue-500); }
.drawer-item:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.drawer-item-icon { font-size: 16px; width: 24px; text-align: center; }

/* ── Alert badge no drawer ────────────────────────────────────── */
.drawer-badge {
  display: inline-block; background: #ef4444; color: #fff;
  border-radius: 9999px; font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px; line-height: 16px;
  text-align: center; margin-left: 4px;
}
.drawer-badge.hidden { display: none; }

/* ── Sidebar (desktop ≥1024px) ─────────────────── */
.sidebar {
  display: none; position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-collapsed);
  background: var(--accent);
  flex-direction: column; align-items: flex-start;
  z-index: 30;
  overflow: hidden; transition: width .2s ease;
}
@media (min-width: 1024px) { .sidebar { display: flex; } }
body.sidebar-open .sidebar { width: var(--sidebar-expanded); }

/* Logo area — expandido para acomodar ícone + logo grandes */
.sidebar-logo-area {
  width: 100%; height: auto; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 6px; min-height: 60px;
  flex-wrap: wrap;
}

/* Botão ☰ toggle — visível apenas em mobile */
.sidebar-toggle {
  display: none; width: 44px; height: 44px; flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.85); font-size: 18px;
  border-radius: var(--radius);
  align-items: center; justify-content: center;
  transition: background .1s; font-family: var(--font);
}
.sidebar-toggle:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-toggle:active { background: rgba(255,255,255,.22); }
.sidebar-toggle:focus-visible { outline: 2px solid rgba(255,255,255,.6); outline-offset: -2px; }

/* Mobile: mostrar toggle */
@media (max-width: 1023px) {
  .sidebar-toggle { display: flex; }
}

/* Ícone da marca (sempre visível) */
.sidebar-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

/* Brand — logo grande, visível ou não dependendo do estado */
.sidebar-logo {
  display: none; align-items: center; justify-content: center;
  height: 40px; gap: 6px; font-size: 14px; font-weight: 700;
  color: #fff; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap;
}
.sidebar-logo img { height: 20px; width: auto; border-radius: 3px; }
body.sidebar-open .sidebar-logo { display: flex; }

.sidebar-items { flex: 1; width: 100%; display: flex; flex-direction: column; gap: 2px; padding: 8px 6px 0; }
.sidebar-item {
  display: flex; align-items: center; gap: 0;
  width: 36px; height: 44px; border-radius: var(--radius);
  color: rgba(255,255,255,.85); text-decoration: none;
  font-size: 17px; justify-content: center;
  transition: background .1s, color .1s;
  white-space: nowrap; overflow: hidden;
}
.sidebar-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-item:active { background: rgba(255,255,255,.22); }
.sidebar-item:focus-visible { outline: 2px solid rgba(255,255,255,.6); outline-offset: -2px; }
.sidebar-item.active {
  background: rgba(255,255,255,.18); color: #fff;
  box-shadow: inset 3px 0 0 rgba(255,255,255,.6);
}
body.sidebar-open .sidebar-item { width: 100%; height: 40px; padding: 0 10px; justify-content: flex-start; gap: 10px; font-size: 15px; }

.sidebar-item-label { font-size: 12px; font-weight: 500; display: none; }
body.sidebar-open .sidebar-item-label { display: inline; }

/* Esconder labels dos itens filhos quando menu está compactado */
.sidebar-group-children .sidebar-item-label { display: none !important; }
body.sidebar-open .sidebar-group-children .sidebar-item-label { display: inline !important; }

/* ── Sidebar User Area (abaixo do logo) ────────────────────────── */
.sidebar-user-area {
  width: 100%; padding: 8px 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-user-area .user-avatar,
.sidebar-user-area .user-avatar-placeholder {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,255,255,.2);
}

.sidebar-user-info { display: none; flex: 1; min-width: 0; }
body.sidebar-open .sidebar-user-info { display: flex; flex-direction: column; gap: 4px; }

.sidebar-user-name {
  font-size: 12px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-user-logout {
  font-size: 10px; color: rgba(255,255,255,.7);
  text-decoration: none; cursor: pointer;
  transition: color .15s;
}

.sidebar-user-logout:hover { color: #fff; text-decoration: underline; }

/* ── Sidebar Search (só visível quando expandido) ────────────────── */
.sidebar-search {
  display: none; width: 100%; padding: 6px; margin: 4px 0;
  background: rgba(255,255,255,.05); border-radius: var(--radius);
}

body.sidebar-open .sidebar-search { display: flex; }

.sidebar-search input {
  width: 100%; border: none; background: none;
  padding: 4px 8px; font-size: 12px; color: #fff;
  outline: none; font-family: var(--font);
}

.sidebar-search input::placeholder { color: rgba(255,255,255,.5); }

/* ── Sidebar Badge (notificações) ────────────────────────────────– */
.sidebar-item {
  position: relative;
}

.sidebar-badge {
  position: absolute; top: 4px; right: -2px;
  background: #ef4444; color: #fff;
  border-radius: 9999px; font-size: 9px; font-weight: 700;
  padding: 1px 4px; min-width: 18px; height: 18px;
  text-align: center; line-height: 1; display: flex;
  align-items: center; justify-content: center;
  animation: badge-pulse .3s ease-out;
  box-shadow: 0 0 0 2px var(--slate-900);
}

body.sidebar-open .sidebar-badge { right: 8px; top: 11px; box-shadow: none; }

.sidebar-badge.hidden { display: none; }

@keyframes badge-pulse {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── Sincronização indicator ────────────────────────────────────── */
.sync-indicator {
  position: absolute; top: 4px; right: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent; border: 2px solid #64748b;
  opacity: 0.4;
}

.sync-indicator.syncing {
  background: #f59e0b;
  border-color: #f59e0b;
  opacity: 1;
  animation: pulse-sync .6s ease-in-out infinite;
}

.sync-indicator.completed {
  background: #16a34a;
  border-color: #16a34a;
  opacity: 1;
  animation: none;
}

@keyframes pulse-sync {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* ── Sidebar Favorite (estrela por item) ────────────────────────── */
.sidebar-favorite {
  margin-left: auto; opacity: 0.3; flex-shrink: 0;
  display: none; cursor: pointer; font-size: 14px;
  transition: opacity .15s, color .15s;
  user-select: none;
}

body.sidebar-open .sidebar-favorite { display: inline; }

.sidebar-item:hover .sidebar-favorite { opacity: 0.6; }

.sidebar-favorite.active { opacity: 1; color: #f59e0b; }

/* ── Sidebar Group (collapsible sections) ──────────────────────── */
.sidebar-group { width: 100%; }

.sidebar-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
  color: rgba(255,255,255,.85); font-size: 13px; font-weight: 600;
  transition: background .15s;
  width: 100%; border: none; background: none; text-align: left;
  font-family: inherit;
}
.sidebar-group-header:hover { background: rgba(255,255,255,.08); }
.sidebar-group-header > span:first-child {
  flex-shrink: 0; width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
}

.sidebar-group-arrow {
  margin-left: auto; font-size: 10px; transition: transform .2s;
  flex-shrink: 0; display: none;
}
body.sidebar-open .sidebar-group-arrow { display: inline; }
.sidebar-group-arrow.expanded { transform: rotate(90deg); }

.sidebar-group-children {
  max-height: 0; overflow: hidden; transition: max-height .25s ease;
}
.sidebar-group-children.expanded {
  max-height: none;
  overflow: visible;
  background: rgba(255,255,255,.10);
  border-radius: 6px;
  margin: 2px 4px 4px;
  padding: 2px 0;
}

.sidebar-section-label {
  padding: 4px 8px 2px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: rgba(255,255,255,.4); margin-top: 4px;
}
body.sidebar-open .sidebar-section-label { padding-left: 16px; }

/* ── Drawer group (mobile) ─────────────────────────────────────── */
.drawer-group-label {
  padding: 12px 16px 4px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: rgba(255,255,255,.5);
}
.drawer-child { padding-left: 32px !important; }

.sidebar-footer { width: 100%; padding: 0 6px 8px; margin-top: auto; }

/* Ícone (primeiro span) — tamanho fixo para normalizar emoji */
.sidebar-item > span:first-child {
  flex-shrink: 0; width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
}

/* ── Buttons ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; font-family: var(--font);
  transition: all .15s ease;
  text-decoration: none; line-height: 1.2;
  min-height: 40px; /* Base height for touch */
}
.btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.btn:active { transform: scale(0.98); }
.btn:disabled, .btn[disabled] {
  opacity: .5; cursor: not-allowed; pointer-events: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-ghost { background: none; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { opacity: .88; }
.btn-warning { background: var(--orange-500); color: #fff; }
.btn-warning:hover { opacity: .88; }
.btn-sm { padding: 4px 10px; font-size: 12px; font-weight: 600; border-radius: 6px; }

/* ── Data Table ────────────────────────────────── */
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.data-table thead {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.data-table th {
  text-align: left; padding: 10px 12px;
  font-weight: 700; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.data-table tbody tr:hover { background: var(--bg); }
.data-table tbody tr.total-row {
  background: #dbeafe; font-weight: 700; color: var(--text);
}
.data-table tbody tr.total-row td {
  font-weight: 700;
}
.data-table td {
  padding: 12px 12px; color: var(--text);
}
.data-table .num {
  text-align: right; font-variant-numeric: tabular-nums;
}
.data-table .period-name {
  font-weight: 500;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap--comfortable {
  border-radius: var(--radius-lg);
}

.data-table--contrast thead {
  background: #edf2f9;
  border-bottom: 1px solid #d4dce8;
}

.data-table--contrast th {
  color: #42526b;
  font-weight: 700;
  letter-spacing: .04em;
}

.data-table--contrast td {
  color: var(--navy);
}

.data-table--contrast tbody tr:hover {
  background: #f8fbff;
}

.data-table--contrast .num {
  color: #0f172a;
}

.data-table--financial th,
.data-table--financial td {
  white-space: nowrap;
}

/* ── Card ──────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }

/* ── Toolbar ───────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar h1 { font-size: 20px; font-weight: 700; margin-right: auto; }

/* ── Select field ──────────────────────────────── */
.select-field {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: var(--font); background: var(--bg); color: var(--text);
  outline: none; cursor: pointer;
}

/* ── Badge ─────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }

/* ── Roadmap Badges ────────────────────────────── */
.rm-badge-success  { background: #dcfce7; color: #166534; }
.rm-badge-warning  { background: #fef9c3; color: #854d0e; }
.rm-badge-info     { background: #dbeafe; color: #1e40af; }
.rm-text-muted     { color: var(--muted); font-size: 12px; }

/* ── Toast ─────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--accent); color: #fff;
  padding: 10px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  transform: translateY(80px); opacity: 0;
  transition: all .2s; z-index: 100;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── Empty state ───────────────────────────────── */
.empty { padding: 60px 0; text-align: center; color: var(--muted); }
.empty strong { display: block; font-size: 15px; margin-bottom: 6px; color: var(--text); }

/* ── Loading skeleton ──────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 1200px 100%; animation: shimmer 1.4s infinite; border-radius: 4px;
}

/* ── KPI Card ──────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4); margin-bottom: var(--space-6);
}
@media (max-width: 639px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 479px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
}
.kpi-card.positive { border-left-color: var(--green); }
.kpi-card.warning  { border-left-color: var(--yellow); }
.kpi-card.negative { border-left-color: var(--red); }
.kpi-card.menu-color { border-left-color: var(--accent); }

.kpi-label { font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-sub   { font-size: 10px; color: #94a3b8; margin-top: 4px; }

.kpi-progress     { height: 3px; border-radius: 99px; background: var(--border); margin-top: 6px; }
.kpi-progress-bar { height: 3px; border-radius: 99px; background: var(--green); transition: width .3s ease; }
.kpi-card.warning  .kpi-progress-bar { background: var(--yellow); }
.kpi-card.negative .kpi-progress-bar { background: var(--red); }

/* ── KPI Single Card (individual widget) ─────── */
.kpi-single-card {
  height: 100%; display: flex; flex-direction: column; justify-content: center;
  padding: 20px 16px; border-left: 4px solid transparent;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.kpi-single-card .kpi-label { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.kpi-single-card .kpi-value { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.kpi-single-card .kpi-sub { font-size: 10px; color: #94a3b8; }
.kpi-single-card.positive { border-left-color: var(--green); }
.kpi-single-card.negative { border-left-color: var(--red); }
.kpi-single-card.warning  { border-left-color: var(--yellow); }
.kpi-single-card .kpi-progress-bar { background: var(--green); }
.kpi-single-card.warning  .kpi-progress-bar { background: var(--yellow); }
.kpi-single-card.negative .kpi-progress-bar { background: var(--red); }

/* ── Widget states ─────────────────────────────── */
.widget-loading { padding: 24px 16px; display: flex; flex-direction: column; gap: 8px; }

.widget-empty, .widget-error { padding: 32px 16px; text-align: center; }
.widget-empty-icon, .widget-error-icon { font-size: 28px; display: block; margin-bottom: 8px; opacity: .5; }
.widget-empty-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.widget-empty-sub, .widget-error-sub { font-size: 11px; color: var(--muted); }
.widget-error-title { font-size: 13px; font-weight: 600; color: var(--red); margin-bottom: 4px; }
.widget-action {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 6px; font-size: 11px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-family: var(--font);
}
.widget-action.error { background: #fef2f2; border-color: #fecaca; color: var(--red); }

/* ── User profile (drawer + sidebar) ────────────── */
.user-profile {
  border-top: 1px solid var(--border);
  padding: 12px 0;
  margin-top: 12px;
}

.drawer-user { padding: 12px 12px; }
.sidebar-user { padding: 12px 0; }

.user-profile-content {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.user-avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-logout {
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s ease;
  cursor: pointer;
}

.user-logout:hover {
  color: var(--red);
  text-decoration: underline;
}

/* ── Blocker IDs ─────────────────────────────────── */
.rm-blocked-by {
  display: block;
  font-size: 11px;
  color: var(--red);
  margin-top: 4px;
  padding: 2px 6px;
  background: rgba(220, 38, 38, 0.1);
  border-radius: 4px;
}

.rm-blocked-id {
  display: inline-block;
  background: rgba(220, 38, 38, 0.2);
  padding: 1px 4px;
  border-radius: 3px;
  margin-right: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s ease;
}

.rm-blocked-id:hover {
  background: rgba(220, 38, 38, 0.4);
}

/* ── Progress Count ─────────────────────────────────── */
.rm-progress-count {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 2px;
}

/* ============================================================
   Canonical Design Tokens — Component Layer
   Card #209 — Centralize design tokens and shared UI components
   ============================================================ */

/* ── Utility classes ────────────────────────────────── */
.hidden        { display: none !important; }
.flex-row      { display: flex; align-items: center; gap: var(--space-2); }
.flex-1        { flex: 1; min-width: 0; }
.text-muted    { color: var(--muted); }
.text-sm       { font-size: var(--text-sm); }
.text-xs       { font-size: var(--text-xs); }
.text-right    { text-align: right; }
.text-center   { text-align: center; }
.justify-between { justify-content: space-between; }
.mb-0  { margin-bottom: 0; }
.mb-2  { margin-bottom: var(--space-2); }
.mb-3  { margin-bottom: var(--space-3); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-5  { margin-bottom: var(--space-5); }

/* ── Missing button variants ──────────────────────── */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  padding: var(--space-1) var(--space-2); min-width: 28px;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: background .12s, opacity .12s;
}
.btn-icon:hover { background: var(--bg); }
.btn-icon:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* ── Focus-visible ring for interactive elements ──── */
.btn:focus-visible,
.select-field:focus-visible,
.data-table tbody tr:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ── Modal system ──────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-sm { max-width: 500px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 800px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-4);
}
.modal-title { font-size: var(--text-lg); font-weight: 700; color: var(--text); }
.modal-close {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--muted); line-height: 1; padding: var(--space-1);
  border-radius: var(--radius-sm); transition: background .1s, color .1s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.modal-body { margin-bottom: var(--space-5); }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2);
}
.modal-error {
  background: var(--danger-light); border: 1px solid var(--red-100);
  color: var(--danger); border-radius: var(--radius);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}

/* ── Form components ───────────────────────────────── */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block; font-size: var(--text-sm); font-weight: 600;
  color: var(--text); margin-bottom: var(--space-1);
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--text-base); font-family: var(--font);
  color: var(--text); background: var(--surface); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-input::placeholder { color: var(--muted-strong); }

/* ── Error banner ──────────────────────────────────── */
.error-banner {
  background: var(--danger-light); border: 1px solid var(--red-100);
  color: var(--danger); border-radius: var(--radius);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
  font-size: var(--text-base);
}

/* ── Enhanced empty state ─────────────────────────── */
.empty-state {
  padding: var(--space-10) var(--space-5); text-align: center; color: var(--muted);
}
.empty-state-icon { font-size: 28px; display: block; margin-bottom: var(--space-2); opacity: .5; }
.empty-state-title { font-size: var(--text-md); font-weight: 600; color: var(--text); margin-bottom: var(--space-1); }
.empty-state-desc { font-size: var(--text-sm); color: var(--muted); }

/* ── Badge variants ───────────────────────────────── */
.badge-success { background: var(--green-100); color: var(--green-600); }
.badge-danger  { background: var(--red-100); color: var(--red-600); }
.badge-warning { background: var(--yellow-50); color: #854d0e; }
.badge-info    { background: var(--blue-100); color: #1e40af; }
.badge-muted   { background: var(--slate-100); color: var(--slate-600); }

/* ── Numeric & Data types ───────────────────────── */
.num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.amount { color: var(--green-600); font-weight: 600; }
.diff-pos { color: var(--green-600); font-weight: 600; }
.diff-neg { color: var(--red-600); font-weight: 600; }

/* ── Search components ──────────────────────────── */
.search-box { position: relative; width: 100%; max-width: 400px; }
.search-input { width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--border); border-radius: var(--radius); font-size: var(--text-sm); background: var(--surface); transition: all .2s ease; }
.search-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(6,182,212,0.1); background: #fff; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--slate); pointer-events: none; opacity: .6; }

/* ── Page layout variants ──────────────────────────── */
.page-wide  { max-width: var(--page-max); }
.page-narrow { max-width: var(--page-max-narrow); }

/* ── Data table compact variant ───────────────────── */
.data-table--compact th { padding: var(--space-1) var(--space-2); font-size: var(--text-xs); }
.data-table--compact td { padding: var(--space-1) var(--space-2); font-size: var(--text-sm); }

/* ── Stat card (for cadastro inline KPIs) ─────────── */
.stat-card {
  background: var(--bg-secondary); padding: var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-md);
}
.stat-card-label {
  font-size: var(--text-xs); font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
}
.stat-card-value {
  font-size: var(--text-2xl); font-weight: 700; color: var(--navy); margin-top: var(--space-1);
}

/* ── Tab system ────────────────────────────────────── */
.tabs { display: flex; gap: var(--space-1); margin-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.tab {
  padding: var(--space-2) var(--space-4); font-size: var(--text-sm); font-weight: 500;
  color: var(--muted); cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; transition: color .12s, border-color .12s;
  font-family: var(--font);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tabs--pill { border-bottom: none; gap: var(--space-1); }
.tabs--pill .tab {
  border-radius: var(--radius-sm); border-bottom: none;
  padding: var(--space-1) var(--space-3);
}
.tabs--pill .tab.active { background: var(--bg); color: var(--text); }

.tabs--contrast {
  padding: var(--space-1);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-lg);
  background: #eef3fb;
  width: fit-content;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.tabs--contrast .tab {
  border-radius: var(--radius-sm);
  border-bottom: none;
  padding: var(--space-2) var(--space-3);
  color: var(--slate-700);
  font-weight: 600;
}

.tabs--contrast .tab:hover {
  background: rgba(255, 255, 255, 0.72);
  color: var(--navy);
}

.tabs--contrast .tab.active {
  background: var(--surface);
  color: var(--navy);
  box-shadow: var(--shadow-xs);
}

/* ── Card header ──────────────────────────────────── */
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  font-size: var(--text-md); font-weight: 600; color: var(--text);
}

/* ============================================================
   Enhanced component states — accessibility, contrast, hierarchy
   Card #209 — Centralize design tokens and shared UI components
   ============================================================ */

/* ── Form field states ─────────────────────────────── */
.form-input:disabled, .form-select:disabled, .form-textarea:disabled {
  background: var(--bg); color: var(--muted); cursor: not-allowed;
  border-color: var(--slate-300);
}
.form-input[readonly], .form-textarea[readonly] {
  background: var(--bg-secondary); color: var(--text-secondary);
}
.form-input.is-error, .form-select.is-error, .form-textarea.is-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220,38,38,.12);
}
.form-error {
  font-size: var(--text-xs); color: var(--danger);
  margin-top: var(--space-1);
}
.form-hint {
  font-size: var(--text-xs); color: var(--muted);
  margin-top: var(--space-1);
}

/* ── KPI card clickable modifier ───────────────────── */
.kpi-card--clickable {
  cursor: pointer; min-width: 140px;
  transition: box-shadow .15s, transform .15s;
}
.kpi-card--clickable:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.kpi-card--clickable:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* ── KPI card size modifiers ────────────────────────── */
.kpi-card--lg { padding: var(--space-5); }
.kpi-card--lg .kpi-value { font-size: var(--text-3xl); }
.kpi-card--stat {
  padding: var(--space-3) var(--space-4);
  border-left: none; text-align: center;
}
.kpi-card--stat .kpi-value { font-size: var(--text-xl); }

/* ── Button secondary (outline with brand color) ──── */
.btn-secondary {
  background: var(--surface); color: var(--accent);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

/* ── Button disabled states ────────────────────────── */
.btn-primary:disabled { background: var(--slate-400); color: var(--slate-300); }
.btn-danger:disabled { background: var(--slate-300); color: var(--slate-200); }
.btn-success:disabled { background: var(--slate-300); color: var(--slate-200); }

/* ── Badge sizes ────────────────────────────────────── */
.badge-sm { font-size: var(--text-xs); padding: 1px 6px; }
.badge-md { font-size: var(--text-sm); padding: 2px 8px; }

/* ── Link styles ──────────────────────────────────── */
.link-accent {
  color: var(--info);
  text-decoration: none;
}
.link-accent:hover {
  text-decoration: underline;
}
.link-accent:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: 2px;
}
.link-muted {
  color: var(--muted);
  text-decoration: none;
}
.link-muted:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ── Card with padding (for non-table cards) ──────── */
.card-padded { padding: var(--space-4); }
.card-padded:hover { box-shadow: var(--shadow-sm); }

/* ── Alert/info banner ────────────────────────────── */
.info-banner {
  background: var(--info-light); border: 1px solid var(--blue-100);
  color: #1e40af; border-radius: var(--radius);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
  font-size: var(--text-base);
}
.warning-banner {
  background: var(--warning-light); border: 1px solid #fde68a;
  color: #854d0e; border-radius: var(--radius);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4);
  font-size: var(--text-base);
}

/* ── Loading state ─────────────────────────────────── */
.loading {
  text-align: center; padding: var(--space-5);
  color: var(--muted); font-size: var(--text-sm);
}

/* ── Code/slug badge ──────────────────────────────── */
.code-badge {
  font-size: var(--text-sm); font-weight: 500;
  color: var(--slate); background: var(--slate-100);
  padding: 2px 6px; border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

/* ── Search/Picker component ────────────────────────── */
.picker-search {
  width: 100%; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--text-base); font-family: var(--font);
  color: var(--text); background: var(--surface); outline: none;
  margin-bottom: var(--space-2);
}
.picker-search:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.picker-options {
  max-height: 200px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.picker-option {
  padding: var(--space-2) var(--space-3); cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background .1s;
}
.picker-option:hover { background: var(--bg); }
.picker-option:last-child { border-bottom: none; }
.picker-option-main { font-size: var(--text-base); font-weight: 600; color: var(--text); }
.picker-option-meta { font-size: var(--text-xs); color: var(--muted); }
.picker-empty { padding: var(--space-5); text-align: center; color: var(--muted); font-size: var(--text-sm); }

/* ── Filter panel ──────────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  width: 100%;
}

.filters-bar .filter-group {
  min-width: 0;
}

.filter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: nowrap;
}

.filters-bar--desktop {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(180px, 0.9fr)) auto;
  gap: var(--space-3);
  align-items: end;
}

.filters-bar--desktop > :not(.filter-actions) {
  min-width: 0;
}

.filters-bar--desktop .filter-actions {
  grid-column: 4;
  justify-self: end;
}

.filters-bar--desktop .filter-actions > * {
  flex-shrink: 0;
}

.filter-panel {
  display: flex; flex-wrap: wrap; gap: var(--space-3);
  margin-bottom: var(--space-4); align-items: flex-end;
}
.filter-row {
  display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap;
}
.filter-group { display: flex; flex-direction: column; gap: var(--space-1); }
.filter-label { font-size: var(--text-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; }
.filter-select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--text-base); font-family: var(--font);
  background: var(--bg); color: var(--text); outline: none; cursor: pointer;
}
.filter-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ── Search box ────────────────────────────────────── */
.search-box {
  position: relative; display: flex; align-items: center;
}
.search-input {
  width: 100%; padding: var(--space-2) var(--space-3) var(--space-2) var(--space-8);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--text-base); font-family: var(--font);
  color: var(--text); background: var(--surface); outline: none;
}
.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.search-icon {
  position: absolute; left: var(--space-3);
  color: var(--muted); font-size: var(--text-base); pointer-events: none;
}

/* ── Master-detail layout (for cadastro pages) ─────── */
.md-page { padding: var(--space-6); }
.md-page-header {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.md-page-title { font-size: var(--text-xl); font-weight: 700; color: var(--navy); }
.md-master-detail { display: flex; gap: var(--space-4); min-height: 60vh; }
.md-master-col { width: 320px; flex-shrink: 0; }
.md-detail-col { flex: 1; min-width: 0; }
.md-master-header {
  padding: var(--space-4); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.md-list-item {
  padding: var(--space-3) var(--space-4); cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background .1s;
}
.md-list-item:hover { background: var(--bg); }
.md-list-item.active { background: var(--info-light); }
.md-detail-placeholder {
  display: flex; align-items: center; justify-content: center;
  min-height: 300px; color: var(--muted); text-align: center;
}

/* ── Responsive: master-detail collapses on mobile ── */
@media (max-width: 768px) {
  .md-master-detail { flex-direction: column; }
  .md-master-col { width: 100%; }
}

/* ── Toggle switch ──────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--slate-300); border-radius: var(--radius-full);
  transition: background .15s;
}
.toggle-slider::before {
  content: ''; position: absolute; height: 16px; width: 16px;
  left: 2px; bottom: 2px; background: #fff;
  border-radius: 50%; transition: transform .15s;
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-slider {
  outline: 2px solid var(--border-focus); outline-offset: 2px;
}

/* ============================================================
   Mobile-first responsive rules
   Card #209 — Centralize design tokens and shared UI components
   Subtask #1212 — Mobile-first responsive behavior
   ============================================================ */

/* ── Base (mobile: < 640px) ────────────────────────── */

/* Shell: tighter topbar + spacing on small screens */
@media (max-width: 639px) {
  .topbar { height: 44px; padding: 0 10px; gap: 8px; }
  .topbar-title { font-size: 14px; }
  .topbar-menu { font-size: 18px; padding: 2px; }
  :root { --topbar-h: 44px; }
  .page { padding: var(--space-3); }
  .toolbar { gap: var(--space-2); margin-bottom: var(--space-3); flex-wrap: wrap; }
  .toolbar h1 { font-size: var(--text-lg); width: 100%; margin-bottom: var(--space-1); }
}

/* Stacked layouts: columns become vertical */
@media (max-width: 1279px) {
  .filters-bar--desktop {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .filters-bar--desktop .filter-actions {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
  }

  .filters-bar--desktop .filter-actions > * {
    flex: 1 1 0;
  }
}

@media (max-width: 639px) {
  .filter-panel { flex-direction: column; }
  .filter-row { flex-direction: column; width: 100%; }
  .filter-group { width: 100%; }
  .filter-select { width: 100%; }
  .filters-bar--desktop {
    grid-template-columns: 1fr;
  }
}

/* KPI row: stack cards vertically on mobile */
@media (max-width: 639px) {
  .kpi-card { padding: var(--space-3); }
  .kpi-value { font-size: var(--text-xl); }
  .kpi-card--lg { padding: var(--space-4); }
  .kpi-card--lg .kpi-value { font-size: var(--text-2xl); }
}

/* Tables: horizontal scroll on mobile */
@media (max-width: 767px) {
  .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table thead { display: table-header-group; }
  .data-table tbody { display: table-row-group; }
  .data-table tr { display: table-row; }
  .data-table th, .data-table td { white-space: nowrap; }
}

/* Cards: full width on mobile */
@media (max-width: 639px) {
  .card { border-radius: var(--radius); }
  .card-padded { padding: var(--space-3); }
  .card-header { padding: var(--space-3) var(--space-4); }
}

/* Forms: full width, stacked */
@media (max-width: 639px) {
  .form-group { margin-bottom: var(--space-3); }
  .form-input, .form-select, .form-textarea { font-size: 16px; /* prevent iOS zoom */ }
}

/* Modals: full-width on mobile */
@media (max-width: 639px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 85vh; padding: var(--space-4);
    width: 100%; max-width: 100%;
  }
  .modal-sm, .modal-md, .modal-lg { max-width: 100%; }
  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; justify-content: center; }
}

/* Buttons: touch-friendly minimum size */
@media (max-width: 1023px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .btn-icon { min-width: 44px; min-height: 44px; }
}

/* Tabs: scrollable on mobile */
@media (max-width: 639px) {
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab { flex-shrink: 0; }
}

/* ── Tablet (640px – 1023px) ────────────────────────── */

@media (min-width: 640px) and (max-width: 1023px) {
  .page { padding: var(--space-4); }
  .toolbar { gap: var(--space-3); }
}

/* ── Desktop (≥ 1024px) ────────────────────────────── */
/* Desktop styles are already the default in existing rules */

/* ── Print ────────────────────────────────────────── */
@media print {
  .topbar, .sidebar, .drawer, .drawer-overlay { display: none !important; }
  .app-content { margin-left: 0 !important; padding-top: 0; }
  .page { padding: 0; }
  .card { break-inside: avoid; }
  .data-table { overflow: visible; }
}
