/* ==========================================================================
   Admin DevBatista — design do MVP
   Identidade visual de devbatista.com: tema escuro, ciano, Montserrat.
   ========================================================================== */

:root {
  --bg: #0b1120;
  --bg-side: #080d1a;
  --surface: rgba(15, 23, 42, 0.6);
  --surface-solid: #0f172a;
  --surface-2: #131c31;
  --surface-hover: rgba(255, 255, 255, 0.04);
  --border: #1e293b;
  --border-strong: #334155;
  --border-hover: rgba(8, 145, 178, 0.5);
  --rule: #172033;

  --text: #f1f5f9;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --faint: #64748b;
  --white: #ffffff;

  --cyan: #22d3ee;
  --cyan-300: #67e8f9;
  --cyan-700: #0e7490;
  --cyan-800: #155e75;
  --cyan-tint: rgba(34, 211, 238, 0.1);
  --cyan-line: rgba(22, 78, 99, 0.6);
  --blue: #60a5fa;
  --orange: #fb923c;

  --good: #6ee7b7;  --good-bg: rgba(16, 185, 129, 0.12);  --good-line: rgba(52, 211, 153, 0.25);
  --warn: #fcd34d;  --warn-bg: rgba(245, 158, 11, 0.12);  --warn-line: rgba(251, 191, 36, 0.25);
  --crit: #fca5a5;  --crit-bg: rgba(239, 68, 68, 0.12);   --crit-line: rgba(248, 113, 113, 0.3);
  --crit-dot: #f87171;

  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 16px;
  --radius-sm: 8px;
  --side-w: 256px;
  --top-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(34, 211, 238, 0.2); color: var(--white); }
a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--cyan-300); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.muted { color: var(--muted); }
.strong { color: var(--text); font-weight: 600; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.content { width: 100%; padding: 28px 32px 64px; display: flex; flex-direction: column; gap: 24px; }

/* ---------- Sidebar ---------- */
.side {
  background: var(--bg-side); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 20px 12px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand img { height: 24px; width: auto; opacity: .92; }
.brand .badge { margin-left: auto; }
.grp {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm);
  font-size: 14px; color: var(--muted); font-weight: 500; cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left;
}
.grp:hover { background: var(--surface-hover); color: var(--white); }
.grp.on { color: var(--white); font-weight: 600; }
.grp.on svg { color: var(--cyan); }
.grp .chev { margin-left: auto; transition: transform .2s; opacity: .6; }
.grp.open .chev { transform: rotate(90deg); }
.sub { display: none; flex-direction: column; margin: 2px 0 8px 21px; padding-left: 12px; border-left: 1px solid var(--border); }
.grp.open + .sub { display: flex; }
.it { padding: 7px 10px; font-size: 13px; color: var(--muted); border-radius: 6px; }
.it:hover { color: var(--white); background: var(--surface-hover); }
.it.on { color: var(--cyan-300); background: var(--cyan-tint); font-weight: 600; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 14px 10px 0; border-top: 1px solid var(--border); font-size: 13px; color: var(--white); font-weight: 600; }
.me small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }

/* ---------- Topbar ---------- */
.top {
  height: var(--top-h); position: sticky; top: 0; z-index: 20;
  background: rgba(11, 17, 32, 0.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 32px;
}
.icon-btn.menu-btn { display: none; }
.crumb { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--white); }
.crumb b { color: var(--text); font-weight: 600; }
.crumb .sep { margin: 0 6px; color: var(--faint); }
.search-trigger {
  display: flex; align-items: center; gap: 10px; width: 340px; height: 40px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); font-size: 13px; cursor: pointer;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span:first-of-type { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd { font-size: 11px; font-weight: 600; border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 6px; color: var(--muted); }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; position: relative; color: var(--text-2); cursor: pointer; padding: 0; flex: none;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--white); }
.icon-btn.ghost { border-color: transparent; background: transparent; }
.dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--crit-dot); border: 2px solid var(--bg); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--cyan); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none; border: 0; cursor: pointer;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.soft { background: var(--cyan-tint); color: var(--cyan-300); box-shadow: inset 0 0 0 1px var(--cyan-line); }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-label { color: var(--cyan); font-size: 12px; font-weight: 600; letter-spacing: .15em; text-transform: uppercase; }
h1 { margin: 0; font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; color: var(--white); }
h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--white); }
h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--white); }
.lead { color: var(--muted); font-size: 14px; margin: 0; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
a.card, .card.link { color: inherit; transition: border-color .3s; }
a.card:hover, .card.link:hover { border-color: var(--border-hover); color: inherit; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; }
.card-body { padding: 20px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.more { display: block; padding: 14px 20px; border-top: 1px solid var(--rule); font-size: 14px; font-weight: 600; }

.grid { display: grid; gap: 16px; }
.grid-kpi { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-kpi.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-kpi.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2-1 { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-height: 116px; }
.kpi .v { white-space: nowrap; font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--white); font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .f { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi.alert { border-color: var(--crit-line); }
.kpi.alert .eyebrow { color: var(--crit); }

/* key/value rows */
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--rule); font-size: 14px; }
.kv > span:first-child { color: var(--muted); }
.kv b { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px 24px; padding: 20px; }
.dl div { display: flex; flex-direction: column; gap: 4px; }
.dl dt, .dl .k { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.dl dd, .dl .v { margin: 0; color: var(--text); font-weight: 500; }

/* ---------- Badges & tags ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
}
.badge::before { content: none; }
.badge.dot-l::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-good { background: var(--good-bg); color: var(--good); box-shadow: inset 0 0 0 1px var(--good-line); }
.b-warn { background: var(--warn-bg); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-line); }
.b-crit { background: var(--crit-bg); color: var(--crit); box-shadow: inset 0 0 0 1px var(--crit-line); }
.b-info { background: var(--cyan-tint); color: var(--cyan-300); box-shadow: inset 0 0 0 1px var(--cyan-line); }
.b-mute { background: rgba(148, 163, 184, 0.1); color: var(--text-2); box-shadow: inset 0 0 0 1px rgba(51, 65, 85, 0.8); }
.b-blue { background: rgba(96, 165, 250, 0.1); color: #93c5fd; box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.3); }

/* ---------- Buttons ---------- */
.btn {
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: transparent;
  font-size: 14px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; white-space: nowrap; transition: background .2s, border-color .2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.05); border-color: #475569; color: var(--white); }
.btn.pri { background: var(--cyan); border-color: var(--cyan); color: var(--bg); }
.btn.pri:hover { background: var(--cyan-300); border-color: var(--cyan-300); box-shadow: 0 12px 30px rgba(34, 211, 238, 0.2); color: var(--bg); }
.btn.danger { border-color: var(--crit-line); color: var(--crit); }
.btn.danger:hover { background: var(--crit-bg); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.link-btn { border: 0; background: transparent; color: var(--cyan); font-weight: 600; cursor: pointer; padding: 6px 0; font-size: 13px; }
.link-btn:hover { color: var(--cyan-300); }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; font-size: 13px; color: var(--muted); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--white); }
.seg button.on { background: var(--cyan); color: var(--bg); font-weight: 600; }
.seg .c, .seg .n { font-size: 11px; opacity: .8; }
.select, .input, .textarea {
  height: 40px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-solid);
  color: var(--text); font-size: 14px; min-width: 0;
}
.select { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15); }
.search-field { position: relative; display: inline-flex; align-items: center; }
.search-field svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-field .input { padding-left: 36px; width: 260px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  text-align: left; padding: 12px 20px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.02); white-space: nowrap;
}
.table td { padding: 14px 20px; border-bottom: 1px solid var(--rule); vertical-align: middle; color: var(--text-2); }
.table tbody tr:hover td { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.strong, .table td .strong { color: var(--text); font-weight: 600; }
.table .num, .table .right { text-align: right; }
.table tr.late td { background: rgba(239, 68, 68, 0.05); }
.table tfoot td { font-weight: 700; color: var(--text); border-top: 1px solid var(--border); border-bottom: 0; }
.cell-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages button { min-width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
.pagination .pages button.on { border-color: var(--cyan); color: var(--cyan); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab {
  height: 44px; padding: 0 14px; border: 0; background: transparent; font-size: 14px; font-weight: 500; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--white); }
.tab.on { color: var(--white); font-weight: 600; border-bottom-color: var(--cyan); }
[data-panel][hidden] { display: none !important; }

/* ---------- Charts (CSS/SVG) ---------- */
.unit { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .06em; }
.bars { display: flex; align-items: flex-end; gap: 12px; height: 150px; border-bottom: 1px solid var(--border-strong); padding: 0 4px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bars .bar { width: 100%; max-width: 30px; background: var(--cyan-800); border-radius: 4px 4px 0 0; }
.bars .bar.cur { background: var(--cyan); }
.bars .lbl { font-size: 12px; font-weight: 700; color: var(--white); font-variant-numeric: tabular-nums; }
.axis { display: flex; gap: 12px; padding: 0 4px; }
.axis span { flex: 1; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: 110px minmax(0, 1fr) 48px; align-items: center; gap: 10px; font-size: 13px; }
.hbar .track { height: 12px; background: var(--rule); border-radius: 0 4px 4px 0; }
.hbar .fill { height: 12px; background: var(--cyan); border-radius: 0 4px 4px 0; }
.hbar .fill.alt { background: var(--cyan-800); }
.hbar .val { text-align: right; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.progress { height: 8px; background: var(--rule); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--cyan); border-radius: 999px; }
.progress.warn > i { background: var(--warn); }
.progress.crit > i { background: var(--crit-dot); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Timeline / activity ---------- */
.act { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--rule); font-size: 14px; }
.act .time { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 12px; padding: 12px 20px; border-top: 1px solid var(--rule); font-size: 14px; }
.tl i { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); margin-top: 7px; }
.tl small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Kanban ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.lane { background: rgba(15, 23, 42, 0.45); border: 1px solid var(--border); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 520px; }
.lane.drop { background: transparent; border: 1.5px dashed var(--border-strong); justify-content: center; align-items: center; text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
.lane-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 0; }
.lane-head b { font-size: 13px; font-weight: 700; color: var(--white); }
.lane-sum { font-size: 12px; color: var(--muted); padding: 0 4px 4px; font-variant-numeric: tabular-nums; }
.kcard { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; cursor: grab; }
.kcard:hover { border-color: var(--border-hover); }
.kcard .n { font-size: 14px; font-weight: 600; color: var(--white); }
.kcard .s { color: var(--muted); }
.kcard .r { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kcard .val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.kcard .meta { font-size: 12px; color: var(--muted); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .req { color: var(--cyan); }
.field .input, .field .select, .field .textarea { width: 100%; }
.input[type="file"] { height: auto; padding: 8px; color: var(--muted); }
.input[type="file"]::file-selector-button { height: 32px; margin-right: 12px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border-strong); background: transparent; color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--cyan); }
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--white); transition: transform .2s; }
.switch input:checked + span { background: var(--cyan); }
.switch input:checked + span::after { transform: translateX(18px); }
.fieldset-title { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); padding-top: 4px; }

/* ---------- Drawer & modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.7); backdrop-filter: blur(4px); z-index: 50; display: none; }
.overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); z-index: 60; background: var(--surface-solid); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); }
.modal {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); z-index: 60;
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius); display: none; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.modal.open { display: block; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; max-height: calc(76vh - 140px); overflow-y: auto; }
.kpi.warn { border-color: var(--warn-line); }
.kpi.warn .eyebrow { color: var(--warn); }
.table tr.soon td { background: rgba(245, 158, 11, 0.05); }
a.kcard, a.kcard:hover { color: inherit; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---------- Search palette & notifications ---------- */
.palette { position: fixed; left: 50%; top: 10vh; transform: translateX(-50%); width: min(640px, calc(100% - 32px)); z-index: 70; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius); display: none; overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); }
.palette.open { display: block; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette-input input { flex: 1; height: 56px; border: 0; background: transparent; color: var(--white); font-size: 16px; outline: none; }
.palette-group { padding: 10px 16px 4px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--text-2); font-size: 14px; }
.palette-item:hover, .palette-item.on { background: var(--cyan-tint); color: var(--white); }
.palette-item .badge { margin-left: auto; }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.popover { position: absolute; top: calc(var(--top-h) - 6px); right: 76px; width: 380px; z-index: 40; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--radius); display: none; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); overflow: hidden; }
.popover.open { display: block; }
.notif { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 12px; padding: 14px 16px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--text-2); }
.notif:hover { background: var(--surface-hover); color: var(--white); }
.notif i { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--cyan); }
.notif i.crit { background: var(--crit-dot); }
.notif i.warn { background: var(--warn); }
.notif i.read { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }
.notif small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Misc ---------- */
.empty { padding: 48px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ic { width: 48px; height: 48px; border-radius: 12px; background: var(--cyan-tint); color: var(--cyan); display: flex; align-items: center; justify-content: center; }
.note { border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 16px 20px; display: flex; gap: 14px; align-items: flex-start; font-size: 14px; color: var(--muted); }
.note b { color: var(--text); }
.callout { border-radius: 12px; padding: 14px 16px; background: var(--cyan-tint); box-shadow: inset 0 0 0 1px var(--cyan-line); color: var(--text-2); font-size: 14px; display: flex; gap: 12px; }
.callout.warn { background: var(--warn-bg); box-shadow: inset 0 0 0 1px var(--warn-line); }
.callout.crit { background: var(--crit-bg); box-shadow: inset 0 0 0 1px var(--crit-line); }
.co-avatar { width: 56px; height: 56px; border-radius: 12px; background: var(--cyan-tint); box-shadow: inset 0 0 0 1px var(--cyan-line); color: var(--cyan-300); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; flex: none; }
.co-avatar.sm { width: 36px; height: 36px; font-size: 13px; border-radius: 10px; }
.chip { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 12px; font-weight: 500; color: var(--text-2); background: transparent; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }
.caption { font-size: 12px; color: var(--muted); }
.thread { display: flex; flex-direction: column; gap: 16px; }
.msg { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; }
.msg .bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; color: var(--text-2); }
.msg.client .bubble { background: var(--cyan-tint); border-color: var(--cyan-line); }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg .who b { color: var(--text); }
.steps { display: flex; gap: 0; overflow-x: auto; }
.step { flex: 1; min-width: 120px; padding: 10px 12px; border-top: 3px solid var(--border-strong); font-size: 12px; color: var(--muted); font-weight: 600; }
.step.done { border-color: var(--cyan-800); color: var(--text-2); }
.step.cur { border-color: var(--cyan); color: var(--white); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(1200px 600px at 50% -10%, rgba(34, 211, 238, 0.08), transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); padding: 32px; display: flex; flex-direction: column; gap: 22px; }
.auth-card .logo { height: 28px; width: auto; align-self: flex-start; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-2-1 { grid-template-columns: minmax(0, 1fr); }
  .search-trigger { width: 240px; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 80; transform: translateX(-100%); transition: transform .25s ease; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(2, 6, 23, 0.7); }
  .icon-btn.menu-btn { display: inline-flex; }
  .top { padding: 0 12px; gap: 8px; }
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger .kbd { display: none; }
  .content { padding: 20px 16px 48px; gap: 20px; }
  h1 { font-size: 24px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .grid-kpi, .grid-kpi.g3, .grid-kpi.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  table.table.cards tr.late { background: rgba(239, 68, 68, 0.05); }
  table.table.cards tr.late td { background: transparent; }
  .kpi { padding: 14px; min-height: 96px; }
  .kpi .v { font-size: 20px; }
  .popover { right: 8px; left: 8px; width: auto; }
  .search-field .input { width: 100%; }
  .search-field { width: 100%; }
  .act { grid-template-columns: 48px minmax(0, 1fr); }
  .act .badge { display: none; }
  /* Tabelas viram cartões no celular */
  table.table.cards thead { display: none; }
  table.table.cards, table.table.cards tbody, table.table.cards tr, table.table.cards td { display: block; width: 100%; }
  table.table.cards tr { padding: 12px 16px; border-bottom: 1px solid var(--rule); }
  table.table.cards td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
  table.table.cards td[data-label=""]::before { content: none; }
  table.table.cards tfoot { display: block; }
}
@media (max-width: 340px) {
  .grid-kpi, .grid-kpi.g3, .grid-kpi.g4 { grid-template-columns: minmax(0, 1fr); }
}
.table .link-btn, .table td.right { white-space: nowrap; }
