:root {
  --bg: #f1f5f9; --card: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --side: #0b1220; --side-ink: #cbd5e1; --accent: #0ea5e9; --accent-d: #0284c7;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --info: #2563eb;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code { background: #f1f5f9; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 12.5px; word-break: break-all; }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% 0%, #0c4a6e 0%, var(--side) 60%); }
.auth-card { width: min(400px, 92vw); background: var(--card); border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-card h2 { margin: 18px 0 6px; }
.auth-card form { display: grid; gap: 14px; margin-top: 14px; }

.logo-row { display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); position: relative; display: inline-block; }
.logo::before { content: ""; position: absolute; left: 6px; top: 7px; width: 18px; height: 12px; border: 2px solid #fff; border-radius: 3px; }
.logo::after { content: ""; position: absolute; left: 12px; top: 10px; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .2px; }

/* Layout */
.layout { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); padding: 18px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand-name { color: #fff; }
nav { display: grid; gap: 2px; }
nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; color: var(--side-ink); user-select: none; }
nav a i { font-style: normal; width: 18px; text-align: center; opacity: .8; }
nav a:hover { background: rgba(255,255,255,.06); }
nav a.active { background: rgba(14,165,233,.16); color: #fff; }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #64748b; }
main { padding: 0 28px 40px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 20px 0 16px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.title { font-size: 20px; font-weight: 700; }
.top-right { display: flex; gap: 8px; align-items: center; }

/* Pílulas */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 12.5px; background: #e2e8f0; color: #334155; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { background: #dcfce7; color: var(--ok); }
.pill.warn { background: #fef3c7; color: var(--warn); }
.pill.bad { background: #fee2e2; color: var(--bad); }
.pill.info { background: #dbeafe; color: var(--info); }
.badge { background: #f1f5f9; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); }

/* Cartões */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; border: 1px solid #eef2f7; }
.card.info { background: #f0f9ff; border-color: #bae6fd; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.card-head h3 { margin: 0; font-size: 15px; }
h4 { margin: 20px 0 8px; font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }
.col { display: flex; flex-direction: column; }
.col .card { flex: 1; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } nav { grid-template-columns: repeat(4, 1fr); } main { padding: 0 14px 30px; } }

.preview { position: relative; background: #0b1220; border-radius: 10px; overflow: hidden; aspect-ratio: 16/9; display: grid; place-items: center; }
.preview img { width: 100%; height: 100%; object-fit: contain; display: block; }
.snap-empty { position: absolute; color: #94a3b8; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.url-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.url-row code { flex: 1; }
.dest { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.dest-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.dest .err { color: var(--bad); font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.progress { height: 6px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .5s; }

/* Formulários */
label { display: grid; gap: 6px; font-weight: 500; color: #334155; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(14,165,233,.35); border-color: var(--accent); }
textarea { resize: vertical; font-family: Consolas, "Cascadia Mono", monospace; font-size: 12.5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; margin: 12px 0; }
.form-grid.one { grid-template-columns: 1fr; }
.span-2 { grid-column: span 2; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } .span-2 { grid-column: auto; } }
.checks { display: grid; gap: 8px; margin-top: 6px; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 6px 0; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.input-row { display: flex; gap: 8px; align-items: center; }
.seg { display: flex; gap: 18px; margin: 10px 0 6px; flex-wrap: wrap; }
.seg label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.seg input { width: auto; accent-color: var(--accent); }
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--muted); }

.btn { font: inherit; font-weight: 600; border: 1px solid #cbd5e1; background: #fff; color: #0f172a; padding: 9px 16px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin: 6px 0 18px; }
.actions.left { justify-content: flex-start; margin: 12px 0 0; }
.error { color: var(--bad); min-height: 1em; margin: 0; }
.warn { color: var(--warn); }

.table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.table td .btn { margin-left: 4px; }
.st-ok { color: var(--ok); font-weight: 700; }
.st-pend { color: var(--warn); }
.st-off { color: #94a3b8; }
.st-err { color: var(--bad); }

.howto { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.machine { display: flex; align-items: center; gap: 12px; font-family: Consolas, monospace; font-size: 22px; font-weight: 700; letter-spacing: 1.5px; margin: 8px 0 16px; }
.device { background: #f0f9ff; border: 1px dashed #7dd3fc; border-radius: 10px; padding: 14px; margin: 12px 0; text-align: center; }
.device .code { font-family: Consolas, monospace; font-size: 30px; font-weight: 800; letter-spacing: 4px; margin: 8px 0; }
.drive-status { margin: 10px 0; font-weight: 600; }
.logs { background: #0b1220; color: #cbd5e1; padding: 12px; border-radius: 10px; max-height: 420px; overflow: auto; font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-all; }

.modal { position: fixed; inset: 0; background: rgba(2,6,23,.7); display: grid; place-items: center; z-index: 20; }
.modal-box { background: #fff; border-radius: 12px; padding: 14px; width: min(1100px, 94vw); }
.modal-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
.modal video { width: 100%; max-height: 75vh; background: #000; border-radius: 8px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 30; max-width: 420px; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* Central */
.c-wrap { max-width: 1400px; margin: 0 auto; padding: 0 24px 40px; }
.c-top { display: flex; justify-content: space-between; align-items: center; padding: 18px 0; }
.stats { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); border: 1px solid #eef2f7; }
.stat b { display: block; font-size: 26px; margin-top: 4px; }
@media (max-width: 1000px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #dcfce7; } .dot.off { background: #94a3b8; } .dot.warn { background: var(--warn); }
tr.row { cursor: pointer; } tr.row:hover td { background: #f8fafc; }
.drawer { position: fixed; top: 0; right: 0; width: min(560px, 100vw); height: 100vh; background: #fff; box-shadow: -10px 0 40px rgba(2,6,23,.2); z-index: 15; overflow: auto; padding: 20px 22px; }
.drawer img { width: 100%; border-radius: 8px; background: #0b1220; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: #f1f5f9; color: #475569; font-weight: 600; }
.tag.ok { background: #dcfce7; color: var(--ok); } .tag.warn { background: #fef3c7; color: var(--warn); } .tag.bad { background: #fee2e2; color: var(--bad); }
.toolbar { display: flex; gap: 10px; align-items: center; }
.toolbar input { width: 280px; }

.fin { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 14px; margin-bottom: 14px; }
.fin .stat { cursor: pointer; border-left: 4px solid #0ea5e9; }
.fin .stat.bad { border-left-color: var(--bad); } .fin .stat.warn { border-left-color: var(--warn); } .fin .stat.ok { border-left-color: var(--ok); }
.fin .stat b { font-size: 22px; }
.owner-bill { background: #fff; border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; border: 1px solid #eef2f7; box-shadow: var(--shadow); font-weight: 600; }
.owner-bill.bad { border-left: 4px solid var(--bad); } .owner-bill.warn { border-left: 4px solid var(--warn); } .owner-bill.ok { border-left: 4px solid var(--ok); }
.drawer.wide { width: min(920px, 100vw); }
.bill-row td { vertical-align: middle; }
.pay-list { max-height: 220px; overflow: auto; }
.sub { font-size: 11.5px; color: var(--muted); }
@media (max-width: 1100px) { .fin { grid-template-columns: repeat(3, minmax(0,1fr)); } .stats { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 640px) { .fin, .stats { grid-template-columns: repeat(2, minmax(0,1fr)); } }
