:root {
  --bg: #f4f6fb; --card: #ffffff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2aabf3; --accent-dark: #1b7fc0; --good: #0e9f6e; --bad: #d04a59; --warn: #d47a18;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1220; --card: #121a2b; --text: #e5e7eb; --muted: #9aa4b2; --line: #243047; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
input, select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-weight: 800; color: #fff;
        background: linear-gradient(135deg, #2aabf3, #7c4ddb); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
       padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 8px; flex: 1 1 260px; }
.top .brand { flex: 1 1 auto; }
@media (max-width: 640px) {
  /* Phone: brand + "Sair" on the first row, filters full width below. */
  .filters { order: 3; flex-basis: 100%; }
}
.filters select { flex: 1; }
.tabs { display: flex; gap: 6px; padding: 10px 16px; overflow-x: auto; }
.tabs button { white-space: nowrap; }
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.content { padding: 0 16px 32px; max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong { display: block; font-size: 26px; margin: 2px 0; }
.kpi small { color: var(--muted); }
.up { color: var(--good); } .down { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
h2 { font-size: 16px; margin: 0 0 10px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.clickable { cursor: pointer; }
.table-wrap { overflow-x: auto; }
.empty { color: var(--muted); padding: 10px 0; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--accent), var(--accent-dark)); border-radius: 6px 6px 0 0; min-height: 2px; position: relative; }
.bars-labels { display: flex; gap: 4px; font-size: 11px; color: var(--muted); }
.bars-labels span { flex: 1; text-align: center; }

.store-card { display: flex; flex-direction: column; gap: 10px; }
.store-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.on { background: #0e9f6e22; color: var(--good); } .pill.off { background: #d04a5922; color: var(--bad); }
.pill.warn { background: #d47a1822; color: var(--warn); } .pill.muted { background: #6b728022; color: var(--muted); }
.registers { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.register { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.register small { color: var(--muted); display: block; }

.modal-root .backdrop { position: fixed; inset: 0; background: #0008; display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-root .card { width: min(720px, 100%); max-height: 90vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px;
         border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; }
.toast.show { opacity: 1; } .toast.error { background: var(--bad); }

.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row > * { flex: 1 1 180px; }
.form-row > button { flex: 0 0 auto; }
.form-col { display: flex; flex-direction: column; gap: 10px; }
.checks { display: flex; gap: 12px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 6px; }
.secret { font: 600 22px/1.3 ui-monospace, Consolas, monospace; letter-spacing: 1px; background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 12px; text-align: center; user-select: all; }
label.inline{display:inline-flex;align-items:center;gap:6px;white-space:nowrap}label.inline input{width:auto}.form-col textarea{width:100%;font:inherit;padding:10px;border-radius:10px;border:1px solid #d7deea}code{background:#eef2f8;padding:1px 5px;border-radius:5px}
.progress{display:grid;gap:6px}.progress-bar{height:10px;border-radius:6px;background:#e7ecf5;overflow:hidden}.progress-bar i{display:block;height:100%;width:0;background:linear-gradient(90deg,#00c2b8,#1878ff);transition:width .2s}details.card summary{cursor:pointer;padding:4px 0}details.card[open] summary{margin-bottom:12px}
