:root {
  --bg: #f6f5f4;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --ink: #1c1917;
  --ink-2: #57534e;
  --ink-3: #857d78;
  --line: #e7e5e4;
  --line-2: #d6d3d1;
  --brand: #cf4a1c;
  --brand-ink: #ffffff;
  --brand-soft: #fde9df;
  --side: #1c1917;
  --side-ink: #d6d3d1;
  --side-active: #2b2623;
  --ok: #15803d;
  --ok-soft: #e5f4e9;
  --warn: #b45309;
  --warn-soft: #fbf0dc;
  --bad: #b42318;
  --bad-soft: #fbe6e3;
  --info: #1d4ed8;
  --info-soft: #e5ecfb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 1px 1px rgba(16, 24, 20, .04);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 620; }
h3 { font-size: 14px; font-weight: 620; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ── Layout ───────────────────────────── */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 650; font-size: 15px; }
.brand img { width: 26px; height: 26px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--side-ink); padding: 8px 10px; border-radius: 7px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.nav a:hover { background: var(--side-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #f07a3e; }
.nav .sep { height: 1px; background: #3a3431; margin: 10px 6px; }
.nav .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #948a84; padding: 6px 10px 2px; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #3a3431; font-size: 12.5px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot button { margin-top: 8px; }
.provider-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: #3a3431; color: #a7f3d0; margin-top: 6px; }
.provider-pill.demo { color: #fde68a; }

.main { padding: 26px 32px 60px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; }
.crumbs { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Cards / grid ─────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 18px; }
.grid.two { grid-template-columns: 1.4fr 1fr; }
.grid.half { grid-template-columns: 1fr 1fr; }
@media (max-width: 1050px) { .grid.two, .grid.half { grid-template-columns: 1fr; } }
.kpi { padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--ink-3); font-size: 12.5px; }
.kpi.warn .v { color: var(--warn); }
.kpi.bad .v { color: var(--bad); }
.kpi.ok .v { color: var(--ok); }

.org-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.org-card { padding: 16px; display: block; color: inherit; transition: border-color .15s, transform .15s; }
.org-card:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.org-card .name { font-weight: 620; font-size: 15px; margin-bottom: 10px; }
.meter { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 10px; }
.meter > span { display: block; height: 100%; background: var(--ok); }
.org-stats { display: flex; flex-wrap: wrap; gap: 6px; }

dl.props { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
dl.props dt { color: var(--ink-3); }
dl.props dd { margin: 0; word-break: break-word; }

/* ── Tables ───────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: #fbfaf9; }
tbody tr.clickable { cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.check, th.check { width: 34px; }
.empty { padding: 34px 16px; text-align: center; color: var(--ink-3); }

/* ── Badges ───────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 550; background: var(--line); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ── Forms ────────────────────────────── */
button, .btn { font: inherit; font-weight: 550; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); padding: 7px 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; line-height: 1.35; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.primary:hover, .btn.primary:hover { background: #b23c12; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: inherit; }
button.ghost:hover { background: rgba(255,255,255,.06); }
button.small, .btn.small { padding: 4px 9px; font-size: 12.5px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; background: var(--surface); width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid #f6b08a; outline-offset: 1px; border-color: var(--brand); }
input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--brand); padding: 0; }
textarea { min-height: 110px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 550; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.form { display: grid; gap: 14px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check-line { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; }
.check-line input { margin-top: 3px; flex: none; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }
.toolbar .grow { flex: 1; }

/* ── Notices ──────────────────────────── */
.notice { border-radius: 9px; padding: 10px 14px; font-size: 13.5px; border: 1px solid; }
.notice.warn { background: var(--warn-soft); border-color: #f1d6a8; color: #7c3a06; }
.notice.info { background: var(--info-soft); border-color: #c7d5f6; color: #1e3a8a; }
.notice.bad { background: var(--bad-soft); border-color: #f3c3bd; color: #7a1a12; }
.stack { display: grid; gap: 16px; }

/* ── Timeline (comentários) ───────────── */
.timeline { display: grid; gap: 12px; }
.comment { border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; background: var(--surface-2); }
.comment .meta { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.comment .body { white-space: pre-wrap; }
.desc { white-space: pre-wrap; }

/* ── Modal ────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 20, .45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: min(620px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { width: min(860px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.pick-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick-list label { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick-list label:last-child { border-bottom: 0; }
.summary-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; }

/* ── Toast ────────────────────────────── */
#toast-root { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--side); color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; font-size: 13.5px; }
.toast.bad { background: var(--bad); }

/* ── Login ────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #ffe3d3, transparent), var(--bg); }
.login { width: min(380px, 100%); padding: 28px; }
.login .brand { color: var(--ink); padding: 0 0 18px; font-size: 17px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

.spinner { width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--ink-3); }
.booting { min-height: 100vh; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .main { padding: 18px; }
  .form .row { grid-template-columns: 1fr; }
  dl.props { grid-template-columns: 1fr; }
}

/* ── 2FA ──────────────────────────────── */
.login.wide-login { width: min(440px, 100%); }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: .25em; text-align: center; padding: 10px; }
.steps { padding-left: 20px; margin: 10px 0 14px; display: grid; gap: 12px; font-size: 13.5px; }
.qr { margin: 10px 0 6px; }
.qr img { display: block; border: 1px solid var(--line); border-radius: 8px; }
.secret { background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: 7px; padding: 6px 10px; margin: 4px 0; font-size: 13px; word-break: break-all; user-select: all; }
.recovery { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px 16px; font-size: 14px; user-select: all; }

/* ── Estado vazio ─────────────────────── */
.empty-state { padding: 44px 24px; text-align: center; display: grid; gap: 10px; justify-items: center; }
.empty-state p { margin: 0; max-width: 420px; }

.notice.ok-notice { background: var(--ok-soft); border-color: #bfe3c9; color: #14532d; }

/* ── Gestão remota ────────────────────── */
.remote-frame { display: block; width: 100%; height: 72vh; min-height: 480px; border: 0; background: #0c0a09; border-radius: 0 0 var(--radius) var(--radius); }
pre.output { background: #1c1917; color: #e7e5e4; border-radius: 9px; padding: 12px 14px; margin: 0; max-height: 420px; overflow: auto; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
pre.output.small { font-size: 12px; }
.agent-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }

/* ── Separadores do motor ─────────────── */
.mesh-tabs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.mesh-tabs .grow { flex: 1; }
.mesh-tabs button.tab { border: 0; background: transparent; padding: 6px 11px; border-radius: 7px; font-weight: 550; color: var(--ink-2); }
.mesh-tabs button.tab:hover { background: var(--surface-2); }
.mesh-tabs button.tab.active { background: var(--brand-soft); color: var(--brand); }
.mesh-tabs button.tab:disabled { opacity: .4; }
.mesh-body .empty { padding: 26px; }
.modal.xl { width: min(1280px, 100%); }
.modal.xl .remote-frame { height: 74vh; border-radius: 8px; }
.pick-list .pick-all { background: var(--surface-2); }

/* ── Marca HPRS ───────────────────────── */
.brand .logo { height: 30px; width: auto; display: block; }
.brand .brand-name { line-height: 1.15; }
.brand .brand-name small { display: block; font-weight: 500; font-size: 11.5px; opacity: .7; }
.login .brand.big { flex-direction: column; gap: 6px; padding: 4px 0 20px; text-align: center; }
.login .brand.big .logo { height: 104px; }
.login .brand.big .brand-name { font-size: 15px; color: var(--ink-2); font-weight: 600; letter-spacing: .02em; }

/* ── Impressão ────────────────────────── */
.bad-text { color: var(--bad); }
.supplies { display: grid; gap: 12px; }
.supply-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.supply .meter { margin: 5px 0 0; height: 8px; }
.toner-mini { display: inline-flex; gap: 3px; align-items: flex-end; height: 22px; }
.toner-mini .tm { width: 7px; height: 22px; background: var(--line); border-radius: 2px; display: flex; align-items: flex-end; overflow: hidden; }
.toner-mini .tm > span { width: 100%; display: block; }
td.num .num, .num .small { text-align: right; }
table.totals td, table.totals th { padding: 7px 12px; }
table.totals tr.grand td { border-top: 2px solid var(--line-2); font-size: 15px; }
details.advanced { border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; }
details.advanced summary { cursor: pointer; font-weight: 550; font-size: 13px; }
button.ghost-dark { background: transparent; border-color: transparent; color: var(--ink-3); }
button.ghost-dark:hover { background: var(--surface-2); color: var(--ink); }

@media print {
  body { background: #fff; }
  .shell { display: block; }
  .side, .no-print, .page-head .actions button, .page-head .actions a, #toast-root { display: none !important; }
  .main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body:has(.print-area) .main > .stack > :not(.print-area):not(.page-head) { display: none; }
  input[type=month] { border: 0; padding: 0; font-weight: 600; }
}
