:root {
  --bg: #F4F6FA; --surface: #FFFFFF; --surface-2: #EEF2F8; --line: #DCE3EE; --text: #0B1B3A; --muted: #5A6A86;
  --brand: #0B1B3A; --accent: #0891B2; --accent-soft: #CFF3FA; --ok: #15803D; --ok-soft: #DCFCE7; --warn: #A16207; --warn-soft: #FEF3C7;
  --bad: #B91C1C; --bad-soft: #FEE2E2; --side: #0B1B3A; --side-text: #C9D6EA; --side-active: #22D3EE; --shadow: 0 1px 2px rgba(11,27,58,.06), 0 4px 16px rgba(11,27,58,.06);
  --r: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070F22; --surface: #0E1A33; --surface-2: #14233F; --line: #1F3152; --text: #E6EDF8; --muted: #93A4C3;
    --brand: #E6EDF8; --accent: #22D3EE; --accent-soft: #0C3A4A; --ok: #4ADE80; --ok-soft: #0F3323; --warn: #FBBF24; --warn-soft: #3A2C08;
    --bad: #F87171; --bad-soft: #3D1212; --side: #050B1A; --side-text: #9FB2D3; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070F22; --surface: #0E1A33; --surface-2: #14233F; --line: #1F3152; --text: #E6EDF8; --muted: #93A4C3;
  --brand: #E6EDF8; --accent: #22D3EE; --accent-soft: #0C3A4A; --ok: #4ADE80; --ok-soft: #0F3323; --warn: #FBBF24; --warn-soft: #3A2C08;
  --bad: #F87171; --bad-soft: #3D1212; --side: #050B1A; --side-text: #9FB2D3; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "DM Sans", system-ui, sans-serif; }
h1, h2, h3, h4 { font-family: Sora, "DM Sans", sans-serif; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-family: Sora; font-weight: 700; }
.logo small { display: block; font: 500 11px "DM Sans"; color: var(--side-text); letter-spacing: .04em; text-transform: uppercase; }
.side a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--side-text); font-weight: 500; }
.side a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.side a.on { background: rgba(34,211,238,.12); color: #fff; box-shadow: inset 3px 0 0 var(--side-active); }
.side .badge { margin-left: auto; }
.side .rodape { margin-top: auto; padding: 10px; font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.side .rodape button { background: transparent; border: 1px solid rgba(255,255,255,.15); color: var(--side-text); border-radius: 8px; padding: 6px 8px; cursor: pointer; text-align: left; }
main { padding: 24px 28px 60px; min-width: 0; }
.topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.mobilebar { display: none; }

/* componentes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.kpi .v { font: 700 26px Sora; margin-top: 4px; } .kpi .l { color: var(--muted); font-size: 13px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; } .bar i { display: block; height: 100%; background: var(--accent); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--accent); } .btn:disabled { opacity: .5; cursor: default; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; } :root[data-theme="dark"] .btn.pri { color: #04202A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.pri { color: #04202A; } }
.btn.sm { padding: 5px 10px; font-size: 13px; } .btn.ghost { background: transparent; } .btn.danger { color: var(--bad); }
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.acc { background: var(--accent-soft); color: var(--accent); }
.badge { background: var(--accent); color: #04202A; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 9px 12px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-color: var(--accent); }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.f > span { color: var(--muted); }
label.chk { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
.tablewrap { overflow-x: auto; }
.lista > * + * { border-top: 1px solid var(--line); }
.linha { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; }
.linha .grow { flex: 1; min-width: 0; }
.vazio { padding: 26px; text-align: center; color: var(--muted); }
.trunc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sec-t { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }

/* kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.col { background: var(--surface-2); border-radius: var(--r); padding: 10px; min-height: 200px; }
.col h3 { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 4px 10px; }
.col.over { outline: 2px dashed var(--accent); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--accent); }
.kcard .t { font-weight: 600; font-size: 14px; } .kcard .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--muted); align-items: center; }

/* gaveta / modal */
.veu { position: fixed; inset: 0; background: rgba(5,11,26,.5); z-index: 40; display: flex; justify-content: flex-end; }
.gaveta { background: var(--bg); width: min(880px, 100%); height: 100%; overflow-y: auto; padding: 22px 24px 60px; box-shadow: -10px 0 40px rgba(0,0,0,.25); }
.gaveta .cab { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.x { border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 18px; flex: none; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 14px; } .dl dt { color: var(--muted); } .dl dd { margin: 0; }
.ficha li { margin-bottom: 4px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: 90vw; }
#toast.on { opacity: 1; }
pre.log { background: var(--surface-2); padding: 10px; border-radius: 9px; max-height: 320px; overflow: auto; font-size: 12px; white-space: pre-wrap; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 20% 0%, rgba(34,211,238,.18), transparent), var(--bg); }
.login .card { width: min(400px, 100%); padding: 28px; }
.login h1 { margin: 8px 0 4px; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0 30% 0 0; z-index: 50; height: 100%; }
  .side.aberta { display: flex; }
  .mobilebar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 30; }
  .mobilebar button { background: none; border: 0; color: #fff; font-size: 22px; }
  main { padding: 16px 16px 60px; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; } .dl dt { margin-top: 6px; }
  .gaveta { padding: 16px; }
}
