/*
 * Agenda telefônica Italine — mesmo padrão do FlowTask (medido na aplicação rodando):
 * fonte do sistema, superfícies lisas com borda fina, controles com cantos de 16 px (rounded-lg
 * = --radius 1rem), cards de 12 px, abas sublinhadas, barra de filtros acima das tabelas.
 * Cor da marca: azul-marinho Italine #2A2766, em escala gerada como o brand.ts do FlowTask
 * (a cor vira o tom 600; 50–500 clareiam com branco, 700–900 escurecem com preto).
 */

@import url('/static/fonts/mono/index.css');

/* ═══════════ Tokens — DIA ═══════════ */
:root {
  color-scheme: light;
  --page: 244 247 251;
  --surface: 255 255 255;
  --ink: 15 23 42;
  --hairline: 226 232 240;
  --shadow-rgb: 15 23 42;

  /* Marca (#2A2766) */
  --b50: 242 242 246; --b100: 229 229 237; --b200: 204 203 218; --b300: 166 164 191; --b400: 114 112 154;
  --b500: 72 69 123; --b600: 42 39 102; --b700: 34 31 82; --b800: 28 26 67;
  --brand: 42 39 102;          /* botões, barra do item ativo */
  --brand-hover: 34 31 82;
  --brand-text: 42 39 102;     /* links, ícone ativo */
  --brand-soft: 242 242 246;   /* fundo do item ativo */
  --brand-soft-text: 28 26 67;
  --brand-line: 204 203 218;

  /* slate: fundo (bg), texto (tx), borda (bd) — paleta do FlowTask */
  --bg-50: 248 250 252; --bg-100: 241 245 249; --bg-200: 226 232 240; --bg-300: 203 213 225;
  --bd-200: 226 232 240; --bd-300: 203 213 225;
  --tx-300: 203 213 225; --tx-400: 112 126 148; --tx-500: 84 98 120; --tx-600: 71 85 105;
  --tx-700: 51 65 85; --tx-800: 30 41 59; --tx-900: 15 23 42;

  /* tons (fundo 50, borda 200, texto 700/800, ponto 500) */
  --info-bg: 240 249 255; --info-bd: 186 230 253; --info-tx: 7 89 133; --info-dot: 14 165 233;
  --ok-bg: 236 253 245; --ok-bd: 167 243 208; --ok-tx: 6 95 70; --ok-dot: 16 185 129;
  --warn-bg: 255 251 235; --warn-bd: 253 230 138; --warn-tx: 146 64 14; --warn-dot: 245 158 11;
  --bad-bg: 255 241 242; --bad-bd: 254 205 211; --bad-tx: 159 18 57; --bad-dot: 244 63 94;
  --danger: 225 29 72; --danger-strong: 190 18 60;

  --radius: 16px;      /* rounded-lg do FlowTask: botões e campos */
  --radius-md: 14px;   /* rounded-md: etiquetas, abas segmentadas */
  --radius-xl: 12px;   /* rounded-xl: cards, menus, janelas */
  --sidebar-w: 240px;
  --sidebar-w-min: 64px;
  --header-h: 56px;
}

/* ═══════════ Tokens — NOITE ═══════════ */
html.dark {
  color-scheme: dark;
  --page: 7 11 22;
  --surface: 17 24 39;
  --ink: 241 245 249;
  --hairline: 45 57 78;
  --shadow-rgb: 0 0 0;

  --brand: 72 69 123;
  --brand-hover: 90 87 145;
  --brand-text: 166 164 191;
  --brand-soft: 25 30 52;
  --brand-soft-text: 204 203 218;
  --brand-line: 44 45 79;

  --bg-50: 22 30 46; --bg-100: 30 40 58; --bg-200: 42 53 74; --bg-300: 58 70 92;
  --bd-200: 45 57 78; --bd-300: 62 75 98;
  --tx-300: 120 134 158; --tx-400: 142 156 180; --tx-500: 164 178 198; --tx-600: 176 189 206;
  --tx-700: 203 213 225; --tx-800: 226 232 240; --tx-900: 241 245 249;

  --info-bg: 17 38 58; --info-bd: 16 66 97; --info-tx: 186 230 253; --info-dot: 56 189 248;
  --ok-bg: 17 40 48; --ok-bd: 17 72 66; --ok-tx: 167 243 208; --ok-dot: 52 211 153;
  --warn-bg: 40 37 36; --warn-bd: 85 64 31; --warn-tx: 253 230 138; --warn-dot: 251 191 36;
  --bad-bg: 40 28 45; --bad-bd: 85 36 56; --bad-tx: 254 205 211; --bad-dot: 251 113 133;
}

html.theme-transition, html.theme-transition *, html.theme-transition *::before, html.theme-transition *::after {
  transition: background-color .35s ease, border-color .35s ease, color .2s ease, fill .2s ease, stroke .2s ease !important;
}

/* ═══════════ Base ═══════════ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: rgb(var(--page));
  color: rgb(var(--tx-800));
  /* A mesma pilha do FlowTask (font-sans do Tailwind): Segoe UI no Windows, SF no Mac. */
  font: 14px/1.5 ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgb(var(--b500)); color: #fff; }
[hidden] { display: none !important; }
a { color: rgb(var(--brand-text)); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
code, .mono { font-family: 'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }
.spacer { flex: 1; }
.muted { color: rgb(var(--tx-500)); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgb(var(--bg-300)); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: rgb(var(--tx-400)); }

.icon { width: 16px; height: 16px; flex: none; }

/* ═══════════ Marca ═══════════ */
.logo-mark { width: 36px; height: 36px; border-radius: 12px; background: #fff; border: 1px solid rgb(var(--bd-200)); display: grid; place-items: center; flex: none; overflow: hidden; padding: 2px; box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / .05); }
.logo-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: rgb(var(--tx-900)); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; font-weight: 500; color: rgb(var(--tx-500)); white-space: nowrap; }

/* ═══════════ Menu lateral ═══════════ */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: rgb(var(--surface));
  border-right: 1px solid rgb(var(--hairline));
  transition: width .45s cubic-bezier(.2, .8, .2, 1), transform .3s ease;
}
.sidebar-top { height: 64px; display: flex; align-items: center; gap: 8px; padding: 0 16px; }
.sidebar-top .home { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; text-decoration: none; }
.sidebar-expand { display: none; justify-content: center; padding: 8px 0; }

.scope { padding: 4px 12px 12px; position: relative; }
.scope-box {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px;
  border: 1px solid rgb(var(--surface)); border-radius: var(--radius-xl);
  background: rgb(var(--surface)); color: inherit; font: inherit; text-align: left;
  box-shadow: inset 0 1px 1px rgb(255 255 255 / .8), 0 2px 8px rgb(var(--shadow-rgb) / .06);
}
html.dark .scope-box { border-color: rgb(var(--hairline)); box-shadow: none; }
button.scope-box { cursor: pointer; }
button.scope-box:hover { border-color: rgb(var(--brand-line)); }
.scope-dot { width: 12px; height: 12px; border-radius: 50%; background: rgb(2 132 199); box-shadow: 0 0 8px rgb(2 132 199 / .5); flex: none; }
.scope-text { flex: 1; min-width: 0; }
.scope-label { font-size: 11px; font-weight: 600; color: rgb(var(--tx-500)); line-height: 1; }
.scope-name { font-size: 12px; font-weight: 700; color: rgb(var(--tx-800)); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scope-box .chevron { width: 14px; height: 14px; color: rgb(var(--tx-400)); }

.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 14px; border: 0; border-radius: 8px; background: none;
  font-family: inherit; font-size: 14px; font-weight: 500; color: rgb(var(--tx-600));
  text-decoration: none; cursor: pointer; user-select: none; white-space: nowrap;
  transition: all .22s cubic-bezier(.16, 1, .3, 1);
}
.nav-item .icon { color: rgb(var(--tx-400)); transition: transform .2s; }
.nav-item:hover { background: rgb(var(--bg-100)); color: rgb(var(--ink)); }
.nav-item:hover .icon { color: rgb(var(--tx-700)); transform: scale(1.1); }
.nav-item.active { background: rgb(var(--brand-soft)); color: rgb(var(--brand-soft-text)); font-weight: 600; box-shadow: inset 2px 0 0 rgb(var(--brand)); }
.nav-item.active .icon { color: rgb(var(--brand-text)); }
.nav-item.active::before { content: ''; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 4px; border-radius: 9999px; background: rgb(var(--brand)); }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; }
.nav-item .chevron { margin-left: auto; width: 14px; height: 14px; transition: transform .2s; }
.nav-item .chevron.open { transform: rotate(180deg); }
.nav-sub { margin: 4px 4px 2px 16px; padding: 4px 4px 4px 16px; border-left: 2px solid rgb(var(--brand-line)); display: flex; flex-direction: column; gap: 4px; }
.nav-sub a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-xl); font-size: 12px; font-weight: 600; color: rgb(var(--tx-600)); text-decoration: none; border: 1px solid transparent; }
.nav-sub a .icon { width: 14px; height: 14px; color: rgb(var(--tx-400)); }
.nav-sub a:hover { background: rgb(var(--bg-50)); color: rgb(var(--tx-900)); }
.nav-sub a.active { background: rgb(var(--surface)); color: rgb(var(--brand-text)); font-weight: 700; border-color: rgb(var(--brand-line)); box-shadow: 0 2px 8px rgb(var(--shadow-rgb) / .08); }
.nav-sub a.active .icon { color: rgb(var(--brand-text)); }

.sidebar-user { padding: 12px; }
.user-card {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px;
  border-radius: var(--radius-xl); border: 1px solid rgb(var(--surface)); background: rgb(var(--surface));
  box-shadow: inset 0 1px 1px rgb(255 255 255 / .8), 0 2px 8px rgb(var(--shadow-rgb) / .06);
  cursor: pointer; font: inherit; color: inherit; text-align: left;
}
html.dark .user-card { border-color: rgb(var(--hairline)); box-shadow: none; }
.user-card:hover { border-color: rgb(var(--brand-line)); }
.user-card .who { min-width: 0; }
.user-card .who strong { display: block; font-size: 12px; color: rgb(var(--tx-800)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who small { display: block; font-size: 11px; font-weight: 500; color: rgb(var(--tx-500)); }

/* Avatar redondo com inicial (cores fixas por nome, como no FlowTask) */
.avatar { width: 32px; height: 32px; border-radius: 50%; background: rgb(var(--brand)); color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.c0 { background: rgb(42 39 102); } .avatar.c1 { background: rgb(220 38 38); } .avatar.c2 { background: rgb(16 185 129); }
.avatar.c3 { background: rgb(2 132 199); } .avatar.c4 { background: rgb(217 119 6); } .avatar.c5 { background: rgb(124 58 237); }
.avatar.c6 { background: rgb(219 39 119); } .avatar.c7 { background: rgb(13 148 136); }

/* Recolhido (64 px): só ícones, com dica flutuante */
.collapsed .sidebar { width: var(--sidebar-w-min); }
.collapsed .sidebar-top { justify-content: center; padding: 0 8px; }
.collapsed .sidebar-top .brand-text, .collapsed .sidebar-top .collapse-btn,
.collapsed .scope-text, .collapsed .scope-box .chevron, .collapsed .nav-item .label, .collapsed .nav-item .chevron,
.collapsed .nav-sub, .collapsed .user-card .who, .collapsed .nav-item.active::before { display: none; }
.collapsed .sidebar-expand { display: flex; }
.collapsed .scope { padding: 8px; }
.collapsed .scope-box { justify-content: center; }
.collapsed .nav-item { justify-content: center; padding: 12px; }
.collapsed .user-card { justify-content: center; }
.collapsed .nav-item[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  padding: 6px 12px; border-radius: var(--radius-xl); background: rgb(15 23 42 / .92); color: #fff;
  font-size: 12px; font-weight: 700; white-space: nowrap; z-index: 60;
}

/* ═══════════ Área principal e cabeçalho ═══════════ */
.main { padding-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: padding-left .3s ease; }
.collapsed .main { padding-left: var(--sidebar-w-min); }

.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  display: flex; align-items: center; gap: 12px; padding: 0 32px 0 44px;
  background: rgb(var(--surface)); border-bottom: 1px solid rgb(var(--hairline));
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: rgb(var(--tx-500)); min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs a { color: rgb(var(--tx-500)); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { color: rgb(var(--brand-text)); }
.crumbs .sep { width: 14px; height: 14px; color: rgb(var(--tx-300)); flex: none; }
.crumbs .current { font-weight: 600; color: rgb(var(--tx-900)); overflow: hidden; text-overflow: ellipsis; }
.menu-toggle { display: none !important; }

/* Busca global (Ctrl+K) */
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; width: 224px; padding: 0 6px 0 12px;
  border: 1px solid rgb(var(--hairline)); border-radius: 9999px; background: rgb(var(--surface));
  color: rgb(var(--tx-500)); font: inherit; font-size: 13px; cursor: pointer;
}
.search-trigger:hover { border-color: rgb(var(--bd-300)); }
.search-trigger .icon { width: 15px; height: 15px; color: rgb(var(--tx-400)); }
.search-trigger span { flex: 1; text-align: left; }
kbd { font-family: inherit; font-size: 11px; color: rgb(var(--tx-500)); border: 1px solid rgb(var(--hairline)); border-radius: 6px; padding: 1px 6px; background: rgb(var(--bg-50)); }

.content { padding: 24px 24px 48px; width: 100%; max-width: 2880px; margin-inline: auto; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* Alternador de tema (pílula com sol e lua) */
.theme-toggle { position: relative; width: 62px; height: 32px; border-radius: 9999px; border: 1px solid rgb(var(--hairline)); background: rgb(var(--surface)); cursor: pointer; padding: 0 6px; display: flex; align-items: center; justify-content: space-between; color: rgb(var(--tx-400)); flex: none; }
.theme-toggle > .icon { width: 12px; height: 12px; opacity: .5; }
.theme-toggle .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgb(251 191 36); box-shadow: 0 0 14px rgb(251 191 36 / .7); color: #fff; transition: left .5s cubic-bezier(.2, .8, .2, 1), background .3s; }
.theme-toggle .knob .icon { width: 14px; height: 14px; }
html.dark .theme-toggle .knob { left: 33px; background: rgb(99 102 241); box-shadow: 0 0 14px rgb(129 140 248 / .7); }

/* ═══════════ Cabeçalho de página ═══════════ */
.page-header { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.page-header .title { min-width: 0; flex: 1; }
.page-header h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: rgb(var(--tx-900)); display: flex; align-items: baseline; gap: 8px; }
.page-header h1 .count { font-size: 14px; font-weight: 600; color: rgb(var(--tx-500)); }
.page-header p { margin: 4px 0 0; font-size: 13px; color: rgb(var(--tx-600)); }
.page-header .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.section-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-bar p { margin: 0; font-size: 13px; color: rgb(var(--tx-600)); flex: 1; min-width: 220px; }
.section-bar .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Abas da página: sublinhadas, com ícone */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid rgb(var(--hairline)); overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; font-size: 14px; font-weight: 500; color: rgb(var(--tx-600)); text-decoration: none; white-space: nowrap; }
.tabs a .icon { color: rgb(var(--tx-400)); }
.tabs a:hover { color: rgb(var(--tx-900)); }
.tabs a.active { color: rgb(var(--tx-900)); font-weight: 600; border-bottom-color: rgb(var(--brand)); }
.tabs a.active .icon { color: rgb(var(--brand-text)); }
.tabs .count { font-size: 11px; color: rgb(var(--tx-500)); font-variant-numeric: tabular-nums; }

/* Abas segmentadas (sub-visões, alternador de tema) */
.segmented { display: inline-flex; align-items: center; height: 32px; padding: 2px; background: rgb(var(--bg-100)); border-radius: var(--radius); font-size: 13px; max-width: 100%; overflow-x: auto; }
.segmented a, .segmented button { height: 28px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: var(--radius-md); white-space: nowrap; color: rgb(var(--tx-600)); text-decoration: none; border: 0; background: none; font: inherit; cursor: pointer; }
.segmented a:hover, .segmented button:hover { color: rgb(var(--tx-900)); }
.segmented .active { background: rgb(var(--surface)); color: rgb(var(--tx-900)); font-weight: 600; box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / .08); }
.segmented .icon { width: 14px; height: 14px; }
.segmented .count { font-size: 11px; color: rgb(var(--tx-500)); font-variant-numeric: tabular-nums; }

/* Barra de busca/filtros acima da lista (BarraFiltros) */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-bar .search { position: relative; width: 288px; max-width: 100%; }
.filter-bar .search input { height: 32px; padding-left: 32px; border-color: rgb(var(--hairline)); }
.filter-bar .search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: rgb(var(--tx-400)); pointer-events: none; width: 15px; height: 15px; }
.filter-bar .total { font-size: 12px; color: rgb(var(--tx-500)); white-space: nowrap; }

/* ═══════════ Cards ═══════════ */
.card { background: rgb(var(--surface)); border: 1px solid rgb(var(--hairline)); border-radius: var(--radius-xl); overflow: hidden; box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / .04); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid rgb(var(--hairline)); }
.card-head h2 { font-size: 15px; font-weight: 600; color: rgb(var(--tx-900)); display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: rgb(var(--tx-500)); }
.card-head p { margin: 2px 0 0; font-size: 12px; color: rgb(var(--tx-600)); }
.card-body { padding: 16px; }
.card-body > h2 { font-size: 15px; font-weight: 600; color: rgb(var(--tx-900)); }
.card-body > h2 + p, .card-body > p { margin: 4px 0 12px; font-size: 13px; color: rgb(var(--tx-600)); }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* Faixa de indicadores */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); background: rgb(var(--surface)); border: 1px solid rgb(var(--hairline)); border-radius: var(--radius-xl); overflow: hidden; }
.kpi { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-left: 1px solid rgb(var(--bg-100)); }
.kpi:first-child { border-left: 0; }
.kpi .icon { color: rgb(var(--tx-400)); }
.kpi .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: rgb(var(--tx-900)); }
.kpi .label { font-size: 13px; color: rgb(var(--tx-600)); margin-left: 8px; }
.kpi .detail { font-size: 12px; color: rgb(var(--tx-500)); }
.kpi.ok .value, .kpi.ok .icon { color: rgb(var(--ok-dot)); }
.kpi.brand .value, .kpi.brand .icon { color: rgb(var(--brand-text)); }

/* ═══════════ Botões (pílula, 32 px) ═══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid rgb(var(--hairline)); background: rgb(var(--surface)); color: rgb(var(--tx-700));
  font-family: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: rgb(var(--bg-50)); border-color: rgb(var(--bd-300)); color: rgb(var(--ink)); }
.btn:disabled { opacity: .5; cursor: default; }
.btn .icon { width: 15px; height: 15px; }
.btn-primary { background: rgb(var(--brand)); border-color: transparent; color: #fff; font-weight: 600; }
.btn-primary:hover { background: rgb(var(--brand-hover)); border-color: transparent; color: #fff; }
.btn-danger { color: rgb(var(--bad-tx)); }
.btn-danger:hover { background: rgb(var(--bad-bg)); border-color: rgb(var(--bad-bd)); color: rgb(var(--bad-tx)); }
.btn-danger.solid { background: rgb(var(--danger)); border-color: transparent; color: #fff; font-weight: 600; }
.btn-danger.solid:hover { background: rgb(var(--danger-strong)); color: #fff; }
.btn-small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-block { width: 100%; height: 36px; }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; background: none; color: rgb(var(--tx-500)); border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: rgb(var(--bg-100)); color: rgb(var(--tx-900)); }
.icon-btn.danger:hover { background: rgb(var(--bad-bg)); color: rgb(var(--bad-tx)); }
.icon-btn.round { width: 32px; height: 32px; border: 1px solid rgb(var(--hairline)); border-radius: 50%; background: rgb(var(--surface)); }

/* ═══════════ Campos (36 px, cantos de 16 px) ═══════════ */
input[type="text"], input[type="email"], input[type="search"], input[type="password"], input[type="number"], input[type="tel"], select, textarea {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid rgb(var(--bd-300)); border-radius: var(--radius);
  background: rgb(var(--surface)); color: rgb(var(--ink));
  font-family: inherit; font-size: 13px;
  box-shadow: inset 0 1px 2px rgb(var(--shadow-rgb) / .03);
}
select { padding-right: 32px; }
textarea { height: auto; min-height: 84px; padding: 8px 12px; resize: vertical; border-radius: var(--radius-xl); }
input::placeholder, textarea::placeholder { color: rgb(var(--tx-400)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgb(var(--b500)); box-shadow: 0 0 0 3px rgb(var(--b500) / .18); }
input[readonly] { background: rgb(var(--bg-50)); }
input[type="checkbox"], input[type="radio"] { accent-color: rgb(var(--brand)); }
.field { margin-bottom: 14px; }
.field label, .label-row label { display: block; font-size: 12px; font-weight: 500; color: rgb(var(--tx-600)); margin-bottom: 4px; }
.field .hint { color: rgb(var(--tx-500)); font-size: 12px; margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.with-icon { position: relative; }
.with-icon > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: rgb(var(--tx-400)); pointer-events: none; }
.with-icon input { padding-left: 36px; }
.with-icon .reveal { position: absolute; right: 0; top: 0; bottom: 0; padding: 0 12px; border: 0; background: none; color: rgb(var(--tx-400)); cursor: pointer; display: grid; place-items: center; }
.with-icon .reveal:hover { color: rgb(var(--tx-600)); }
.with-icon.has-reveal input { padding-right: 36px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 13px; }
.check input { margin-top: 2px; width: 16px; height: 16px; flex: none; }
.check strong { font-weight: 600; color: rgb(var(--tx-900)); }
.check small { display: block; color: rgb(var(--tx-500)); font-size: 12px; margin-top: 2px; }

dl.details { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; margin: 0; font-size: 13px; }
dl.details dt { color: rgb(var(--tx-500)); font-weight: 500; }
dl.details dd { margin: 0; color: rgb(var(--tx-900)); word-break: break-word; }

/* ═══════════ Menus suspensos ═══════════ */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; min-width: 224px; padding: 8px 0;
  background: rgb(var(--surface)); border: 1px solid rgb(var(--hairline)); border-radius: var(--radius-xl);
  box-shadow: 0 20px 50px -10px rgb(var(--shadow-rgb) / .16);
}
.dropdown-menu .menu-head { padding: 8px 12px; border-bottom: 1px solid rgb(var(--bg-100)); margin-bottom: 4px; }
.dropdown-menu .menu-head strong { display: block; font-size: 12px; color: rgb(var(--tx-800)); }
.dropdown-menu .menu-head small { display: block; font-size: 11px; color: rgb(var(--tx-400)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropdown-menu .menu-label { padding: 6px 12px; font-size: 11px; font-weight: 600; color: rgb(var(--tx-500)); }
.dropdown-menu button, .dropdown-menu a {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0;
  color: rgb(var(--tx-700)); padding: 8px 12px; font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.dropdown-menu button .icon, .dropdown-menu a .icon { width: 14px; height: 14px; color: rgb(var(--tx-400)); }
.dropdown-menu button:hover, .dropdown-menu a:hover { background: rgb(var(--brand-soft)); color: rgb(var(--brand-text)); }
.dropdown-menu button.selected { background: rgb(var(--brand-soft)); color: rgb(var(--brand-text)); }
.dropdown-menu .danger { color: rgb(var(--danger)); }
.dropdown-menu .danger .icon { color: rgb(var(--danger)); }
.dropdown-menu .danger:hover { background: rgb(var(--bad-bg)); color: rgb(var(--danger)); }
.dropdown-menu hr { border: 0; border-top: 1px solid rgb(var(--bg-100)); margin: 4px 0; }
.dropdown-menu .scroll { max-height: 224px; overflow-y: auto; }
.dropdown-menu .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: rgb(var(--tx-400)); }
.dropdown-menu .segmented { width: calc(100% - 24px); margin: 0 12px 6px; display: flex; }
.dropdown-menu .segmented button { flex: 1; justify-content: center; padding: 0 6px; font-size: 11px; color: rgb(var(--tx-600)); border-radius: var(--radius-md); }
.dropdown-menu .segmented button:hover { background: none; }
.dropdown-menu .segmented button.active { background: rgb(var(--surface)); color: rgb(var(--tx-900)); }

/* ═══════════ Tabelas ═══════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid rgb(var(--hairline)); vertical-align: middle; }
th { font-size: 12px; font-weight: 500; color: rgb(var(--tx-500)); background: rgb(var(--bg-50)); white-space: nowrap; padding-top: 9px; padding-bottom: 9px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgb(var(--bg-50)); }
tbody tr.clickable { cursor: pointer; }
td { color: rgb(var(--tx-800)); }
td strong { font-weight: 600; color: rgb(var(--tx-900)); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.actions { text-align: right; white-space: nowrap; width: 1%; }
td.tight, th.tight { width: 1%; }
td .sub { display: block; color: rgb(var(--tx-500)); font-size: 12px; }
.who-cell { display: flex; align-items: center; gap: 10px; }
.who-cell .name { display: flex; align-items: center; gap: 6px; }
.footer-bar { display: flex; gap: 12px; align-items: center; padding: 8px 16px; color: rgb(var(--tx-500)); font-size: 12px; flex-wrap: wrap; border-top: 1px solid rgb(var(--hairline)); background: rgb(var(--bg-50)); }
.card-body .footer-bar { border: 0; background: none; padding: 12px 0 0; }

/* Estado vazio / carregando */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; padding: 32px 16px; color: rgb(var(--tx-600)); font-size: 12px; }
.empty .icon { width: 24px; height: 24px; color: rgb(var(--tx-300)); margin-bottom: 6px; }
.empty strong { font-size: 13px; font-weight: 600; color: rgb(var(--tx-900)); }
.empty .btn { margin-top: 10px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 40px 16px; font-size: 13px; color: rgb(var(--tx-500)); }
.loading .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════ Etiquetas e situação ═══════════ */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; border-radius: 6px; border: 1px solid rgb(var(--bd-200)); background: rgb(var(--bg-100)); color: rgb(var(--tx-700)); font-size: 11px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.badge.blue { background: rgb(var(--info-bg)); border-color: rgb(var(--info-bd)); color: rgb(var(--info-tx)); }
.badge.brand { background: rgb(var(--brand-soft)); border-color: rgb(var(--brand-line)); color: rgb(var(--brand-soft-text)); }
.badge.green { background: rgb(var(--ok-bg)); border-color: rgb(var(--ok-bd)); color: rgb(var(--ok-tx)); }
.badge.amber { background: rgb(var(--warn-bg)); border-color: rgb(var(--warn-bd)); color: rgb(var(--warn-tx)); }
.badge.red { background: rgb(var(--bad-bg)); border-color: rgb(var(--bad-bd)); color: rgb(var(--bad-tx)); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: rgb(var(--tx-700)); white-space: nowrap; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: rgb(var(--tx-300)); flex: none; }
.status.green::before { background: rgb(var(--ok-dot)); }
.status.amber::before { background: rgb(var(--warn-dot)); }
.status.red::before { background: rgb(var(--bad-dot)); }
.status.blue::before { background: rgb(var(--info-dot)); }

/* Avisos dentro da página */
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-xl); border: 1px solid rgb(var(--info-bd)); background: rgb(var(--info-bg)); color: rgb(var(--info-tx)); font-size: 13px; }
.notice.warning { border-color: rgb(var(--warn-bd)); background: rgb(var(--warn-bg)); color: rgb(var(--warn-tx)); }
.notice.danger { border-color: rgb(var(--bad-bd)); background: rgb(var(--bad-bg)); color: rgb(var(--bad-tx)); }
.notice .icon { margin-top: 2px; }
.error { display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; border-radius: 8px; border: 1px solid rgb(var(--bad-bd)); background: rgb(var(--bad-bg)); color: rgb(var(--bad-tx)); font-size: 13px; margin-top: 4px; }
.error p, .notice p { margin: 0; }

.link-row { display: flex; gap: 8px; margin: 8px 0 4px; }
.link-row input { font-family: 'JetBrains Mono Variable', ui-monospace, monospace; font-size: 12px; }
ul.steps, ol.steps { margin: 8px 0 0; padding-left: 20px; color: rgb(var(--tx-600)); font-size: 13px; }
.steps li { margin: 3px 0; }
.secret { font-family: 'JetBrains Mono Variable', ui-monospace, monospace; font-size: 20px; letter-spacing: .08em; text-align: center; padding: 14px; border-radius: var(--radius-xl); border: 1px dashed rgb(var(--bd-300)); background: rgb(var(--bg-50)); user-select: all; color: rgb(var(--tx-900)); }

/* ═══════════ Painel lateral (formulários) ═══════════ */
.drawer-wrap { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: flex-end; }
.drawer-backdrop { position: absolute; inset: 0; background: rgb(15 23 42 / .25); backdrop-filter: blur(2px); }
.drawer { position: relative; width: 100%; max-width: 576px; height: 100%; background: rgb(var(--surface)); box-shadow: 0 25px 50px -12px rgb(0 0 0 / .25); display: flex; flex-direction: column; animation: slideIn .18s ease-out; }
.drawer > header { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid rgb(var(--hairline)); }
.drawer > header h2 { font-size: 15px; font-weight: 600; color: rgb(var(--tx-900)); }
.drawer > header p { margin: 2px 0 0; font-size: 12px; color: rgb(var(--tx-600)); }
.drawer > header .icon-btn { width: 32px; height: 32px; margin-left: auto; }
.drawer > header .icon-btn .icon { width: 20px; height: 20px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer > footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid rgb(var(--hairline)); background: rgb(var(--bg-50)); }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ═══════════ Janelas (confirmação, busca) ═══════════ */
.modal-wrap { position: fixed; inset: 0; z-index: 210; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-wrap.top { align-items: flex-start; padding-top: 12vh; }
.modal-backdrop { position: absolute; inset: 0; background: rgb(15 23 42 / .4); backdrop-filter: blur(2px); }
.modal { position: relative; width: 100%; max-width: 448px; border-radius: var(--radius-xl); background: rgb(var(--surface)); box-shadow: 0 25px 50px -12px rgb(0 0 0 / .25); padding: 20px; }
.modal-wide { max-width: 560px; }
.modal .modal-top { display: flex; gap: 12px; align-items: flex-start; }
.modal .modal-icon { width: 40px; height: 40px; border-radius: var(--radius-xl); display: grid; place-items: center; flex: none; background: rgb(var(--brand-soft)); color: rgb(var(--brand-text)); }
.modal .modal-icon.danger { background: rgb(var(--bad-bg)); color: rgb(var(--danger)); }
.modal .modal-icon .icon { width: 20px; height: 20px; }
.modal h3 { font-size: 14px; font-weight: 600; color: rgb(var(--tx-900)); padding-top: 2px; }
.modal .modal-text { margin: 4px 0 0; font-size: 13px; color: rgb(var(--tx-600)); white-space: pre-line; }
.modal .modal-body { margin-top: 14px; }
.modal .modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 8px; }
.modal .modal-actions .btn { height: 36px; padding: 0 14px; font-size: 14px; font-weight: 700; }
.radio { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; cursor: pointer; padding: 10px 12px; border: 1px solid rgb(var(--hairline)); border-radius: var(--radius-xl); font-size: 13px; }
.radio:has(input:checked) { border-color: rgb(var(--brand-line)); background: rgb(var(--brand-soft)); }
.radio input { margin-top: 3px; }
.radio strong { font-weight: 600; color: rgb(var(--tx-900)); }
.radio small { display: block; color: rgb(var(--tx-500)); font-size: 12px; }
.preview { max-height: 200px; overflow: auto; border: 1px solid rgb(var(--hairline)); border-radius: var(--radius-xl); margin-bottom: 8px; }
.preview th, .preview td { padding: 6px 10px; font-size: 12px; }

/* Busca global */
.palette { position: relative; width: 100%; max-width: 560px; border-radius: var(--radius-xl); background: rgb(var(--surface)); box-shadow: 0 25px 50px -12px rgb(0 0 0 / .3); overflow: hidden; }
.palette .palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid rgb(var(--hairline)); }
.palette .palette-input .icon { color: rgb(var(--tx-400)); }
.palette .palette-input input { border: 0; box-shadow: none; height: 52px; padding: 0; font-size: 15px; border-radius: 0; }
.palette .palette-input input:focus { box-shadow: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 360px; overflow-y: auto; }
.palette li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 13px; color: rgb(var(--tx-800)); }
.palette li .icon { color: rgb(var(--tx-400)); }
.palette li small { margin-left: auto; color: rgb(var(--tx-500)); font-size: 12px; }
.palette li.sel { background: rgb(var(--brand-soft)); color: rgb(var(--brand-soft-text)); }
.palette li.sel .icon { color: rgb(var(--brand-text)); }
.palette .palette-empty { padding: 20px; text-align: center; color: rgb(var(--tx-500)); font-size: 13px; }

/* ═══════════ Avisos (toasts) ═══════════ */
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 220; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 380px); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-xl); border: 1px solid rgb(var(--info-bd)); background: rgb(var(--info-bg)); color: rgb(var(--info-tx)); font-size: 14px; font-weight: 600; box-shadow: 0 10px 15px -3px rgb(var(--shadow-rgb) / .1); animation: slideIn .18s ease-out; }
.toast.success { border-color: rgb(var(--ok-bd)); background: rgb(var(--ok-bg)); color: rgb(var(--ok-tx)); }
.toast.error { border-color: rgb(var(--bad-bd)); background: rgb(var(--bad-bg)); color: rgb(var(--bad-tx)); }
.toast > .icon { width: 20px; height: 20px; margin-top: 1px; }
.toast span { flex: 1; white-space: pre-line; }
.toast button { border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; padding: 0; }
.toast button:hover { opacity: 1; }

/* ═══════════ Login e páginas avulsas ═══════════ */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.auth { width: 100%; max-width: 384px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 20px; }
.auth-brand .logo-mark { width: 44px; height: 44px; margin-bottom: 12px; }
.auth-brand h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: rgb(var(--tx-900)); }
.auth-brand p { margin: 2px 0 0; font-size: 13px; color: rgb(var(--tx-500)); }
.auth-card { background: rgb(var(--surface)); border: 1px solid rgb(var(--hairline)); border-radius: var(--radius-xl); padding: 24px; box-shadow: 0 1px 2px rgb(var(--shadow-rgb) / .05); }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .field { margin: 0; }
.auth-card .error { margin: 0 0 16px; }
.auth-card .lead { margin: 0 0 4px; font-size: 13px; color: rgb(var(--tx-600)); }
.auth-card h2 { font-size: 15px; font-weight: 600; color: rgb(var(--tx-900)); }
.label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.label-row label { margin: 0; }
.label-row span { font-size: 12px; font-weight: 500; color: rgb(var(--brand-text)); }
.auth-foot { margin-top: 16px; text-align: center; font-size: 12px; color: rgb(var(--tx-500)); }
.auth-foot a { color: rgb(var(--brand-text)); }

/* ═══════════ Celular ═══════════ */
.scrim { display: none; }
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgb(15 23 42 / .3); backdrop-filter: blur(2px); z-index: 40; }
  .main, .collapsed .main { padding-left: 0; }
  .menu-toggle { display: inline-grid !important; }
  .collapse-btn { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search-trigger { width: 32px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .content { padding: 16px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid rgb(var(--bg-100)); }
  dl.details { grid-template-columns: 1fr; gap: 2px 0; }
  dl.details dd { margin-bottom: 10px; }
  .filter-bar .search { width: 100%; }
}
@media (max-width: 640px) {
  th.hide-sm, td.hide-sm { display: none; }
  .page-header .actions .btn .label { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .link-row { flex-direction: column; }
  th, td { padding: 9px 12px; }
  .drawer { max-width: 100%; }
}
