:root {
  --bg: #0f172a; --panel: #1e293b; --panel2: #273449; --text: #e2e8f0; --muted: #94a3b8;
  --accent: #38bdf8; --ok: #22c55e; --warn: #f59e0b; --bad: #ef4444; --border: #334155;
  --radius: 14px; --tap: 44px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overflow-x: hidden; }
.hidden { display: none !important; }
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.brand { font-weight: 700; font-size: 18px; display: flex; gap: 8px; align-items: center; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.badge.warn { background: #78350f; color: #fde68a; }
.badge.ok { background: #14532d; color: #bbf7d0; }
.badge.bad { background: #7f1d1d; color: #fecaca; }
.status-dots { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); }
.tiny { font-size: 11px; }
.tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 49px; z-index: 4; }
.tabs button { flex: 1 0 auto; min-height: var(--tap); background: none; border: none; color: var(--muted); font-size: 14px; padding: 0 10px; border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
main { padding: 16px; max-width: 760px; margin: 0 auto; }
h1 { margin: 0 0 4px; } h2 { font-size: 18px; margin: 20px 0 10px; } h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .error { color: var(--bad); min-height: 1em; }
.cards { display: grid; gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card .title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.card .title .state { text-align: right; }
.card .title h3 { margin: 0; }
.meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
button { min-height: var(--tap); min-width: var(--tap); padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .5; }
button.primary { background: var(--accent); color: #0b1220; border-color: transparent; }
button.danger { background: var(--bad); color: #fff; border-color: transparent; }
button.ok { background: var(--ok); color: #052e16; border-color: transparent; }
button.big { flex: 1 1 100%; min-height: 56px; font-size: 17px; }
input, select { min-height: var(--tap); width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 16px; }
label { display: block; margin: 8px 0; font-size: 14px; color: var(--muted); }
label input { margin-top: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row input, .row select { flex: 1 1 160px; width: auto; }
.login-card { max-width: 420px; margin: 15vh auto; }
.login-card input { margin: 12px 0; }
.screen { padding: 16px; }
.steps { padding-left: 20px; color: var(--muted); font-size: 14px; }
.steps li { margin: 4px 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td select { min-height: 36px; padding: 4px 8px; font-size: 14px; }
.log { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; max-height: 50vh; overflow: auto; }
.log div { padding: 5px 0; border-bottom: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.log .t { color: var(--muted); flex: 0 0 66px; }
.log .a { font-weight: 600; }
.log .blocked { color: var(--bad); } .log .forwarded, .log .cached { color: var(--ok); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-body { background: var(--panel); border-radius: var(--radius); padding: 20px; max-width: 520px; width: 100%; max-height: 80vh; overflow: auto; }
.modal-body h4 { margin: 12px 0 4px; } .modal-body ul { margin: 4px 0 8px; padding-left: 18px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--border); padding: 12px 18px; border-radius: 12px; z-index: 60; max-width: 90vw; font-size: 14px; }
.alert { background: #451a03; border: 1px solid #b45309; color: #fde68a; padding: 10px 12px; border-radius: 12px; margin-bottom: 10px; font-size: 14px; }
.state { font-weight: 700; }
.state.blocked { color: var(--bad); } .state.allowed { color: var(--ok); } .state.pending { color: var(--warn); }
pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 8px; }
@media (prefers-reduced-motion: no-preference) { button { transition: transform .08s; } button:active { transform: scale(.97); } }

/* ---------- Phase 2 ---------- */
.budget .big { font-size: 44px; font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.budget .big small { font-size: 16px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.budget .headline { font-size: 15px; margin: 2px 0 10px; }
.budget.blocked .big { color: var(--bad); } .budget.ok .big { color: var(--ok); }
.bar { height: 12px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); margin: 8px 0; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar > i.over { background: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border); color: var(--text); }
.chip.free { color: var(--muted); }
.grid7 { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.grid7 label { margin: 0; text-transform: capitalize; }
.hours-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) minmax(0, 1fr); gap: 6px; align-items: center; margin: 6px 0; }
.hours-row input[type=time] { min-width: 0; width: 100%; padding: 10px 6px; }
.hours-row input[type=time]::-webkit-calendar-picker-indicator { display: none; }
.grid7 input { min-width: 0; }
main, .card { min-width: 0; } .card { overflow-wrap: anywhere; }
.hours-row .day { display: flex; align-items: center; gap: 8px; text-transform: capitalize; font-size: 14px; color: var(--text); min-height: var(--tap); }
.hours-row input[type=checkbox] { width: 22px; height: 22px; min-height: 0; flex: 0 0 22px; }
.switchline { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; padding: 8px 10px; background: var(--bg); border-radius: 12px; border: 1px solid var(--border); font-size: 14px; }
.switch { position: relative; flex: 0 0 56px; width: 56px; height: 32px; min-height: 32px; min-width: 56px; padding: 0; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: left .15s; }
.switch.on { background: var(--warn); border-color: transparent; } .switch.on::after { left: 27px; background: #fff; }
.tap44 { min-height: 44px; display: flex; align-items: center; }
.attr { font-size: 13px; margin-top: 6px; }
.attr b.parent { color: var(--ok); } .attr b.pedro { color: var(--warn); }
.hist-row { display: grid; grid-template-columns: 78px 1fr 74px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); min-height: var(--tap); cursor: pointer; font-size: 13px; }
.hist-row.sel { background: var(--panel2); margin: 0 -8px; padding: 8px; border-radius: 10px; }
.hist-row .bar { margin: 0; height: 10px; }
textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; }
.sim-row { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.sim-row .t { display: inline-block; width: 46px; color: var(--muted); }
.sim-row .rem { display: inline-block; min-width: 64px; font-weight: 700; }
.sim-row .off { color: var(--bad); } .sim-row .on { color: var(--ok); } .sim-row .par { color: var(--accent); }
select.ov { min-height: 44px; }
@media (prefers-reduced-motion: reduce) { .switch::after { transition: none; } }

/* ---------- Phase 3 ---------- */
a.btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel2); color: var(--text); font-size: 15px; font-weight: 600; text-decoration: none; }
a.btn.primary { background: var(--accent); color: #0b1220; border-color: transparent; }
a.btn.ok { background: var(--ok); color: #052e16; border-color: transparent; }
a { color: var(--accent); }
.login-card .big-btn { width: 100%; min-height: 60px; font-size: 18px; margin: 10px 0; }
.login-card details { margin-top: 14px; } .login-card summary { min-height: var(--tap); display: flex; align-items: center; color: var(--muted); cursor: pointer; }
.banner { background: #0c4a6e; border-bottom: 1px solid #0369a1; color: #e0f2fe; padding: 10px 16px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner button { min-height: 40px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.quick button { min-height: 64px; font-size: 15px; line-height: 1.2; padding: 6px 8px; white-space: normal; }
.quick button.active { background: var(--ok); color: #052e16; border-color: transparent; }
.quick button small { display: block; font-weight: 500; font-size: 12px; opacity: .85; }
.request { background: #1e1b4b; border: 1px solid #4338ca; }
.srcrow { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.dotc { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }
.daystrip { position: relative; height: 34px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.daystrip i { position: absolute; top: 0; bottom: 0; display: block; }
.daystrip b.now { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; }
.strip-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin: 4px 0 8px; }
body.kid .budget .big { font-size: 46px; }
body.kid .budget .big small { display: block; margin-top: 4px; }
.linkbox { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; user-select: all; }
.codebox { font: 700 28px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; text-align: center; padding: 12px; background: var(--bg); border-radius: 12px; border: 1px dashed var(--border); }
