/* Proof — Clear Ledger design, mobile first */
:root {
  --bg:#f0f4f8; --surface:#ffffff; --card:#ffffff; --card2:#f8fafc;
  --border:#e2e8f0; --border2:#cbd5e1;
  --blue:#2563eb; --blue-dim:#dbeafe; --teal:#22d3a5; --navy:#1e3a5f;
  --gold:#d97706; --gold-dim:#fef3c7; --green:#16a34a; --red:#dc2626;
  --text:#1e293b; --text2:#64748b; --text3:#94a3b8;
  --mono:'DM Mono',ui-monospace,monospace; --sans:'Inter',system-ui,-apple-system,'Segoe UI',sans-serif; --display:'Syne','Inter',system-ui,sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0b1220; --surface:#0f172a; --card:#111a2e; --card2:#0f172a;
    --border:#1f2a40; --border2:#2b3a55; --blue:#60a5fa; --blue-dim:#172554;
    --gold-dim:#3b2a0a; --text:#e2e8f0; --text2:#94a3b8; --text3:#64748b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:#0b1220; --surface:#0f172a; --card:#111a2e; --card2:#0f172a;
  --border:#1f2a40; --border2:#2b3a55; --blue:#60a5fa; --blue-dim:#172554;
  --gold-dim:#3b2a0a; --text:#e2e8f0; --text2:#94a3b8; --text3:#64748b; color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
button { font: inherit; }

/* Boot + sign-in */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--blue-dim); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.signin-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 32px 26px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 10px 40px rgba(15,23,42,.08); }
.signin-card img { width: 72px; height: 72px; border-radius: 18px; }
.signin-card h1 { font-family: var(--display); font-size: 28px; margin: 14px 0 2px; }
.signin-card p { color: var(--text2); margin-bottom: 22px; }
.ms-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border2); background: var(--surface); color: var(--text); font-weight: 600; text-decoration: none; }
.ms-btn:hover { border-color: var(--blue); }

/* Layout: phone = top bar + bottom tabs; desktop = sidebar */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand b { font-family: var(--display); font-size: 18px; }
.brand small { display: block; font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text3); margin-top: -2px; }
.topbar .spacer { flex: 1; }
.pill { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border); background: var(--card); font-size: 12px; color: var(--text2); white-space: nowrap; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text3); flex-shrink: 0; }
.dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.bad { background: var(--red); }
.env-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; background: var(--gold-dim); color: #92400e; }

.main { flex: 1; padding: 18px 16px calc(84px + var(--safe-b)); max-width: 1100px; width: 100%; margin: 0 auto; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: var(--safe-b); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; color: var(--text2); text-decoration: none; font-size: 10.5px; font-weight: 600; }
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--blue); }
.sidebar { display: none; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 236px 1fr; grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; padding: 14px 24px; }
  .tabs { display: none; }
  .sidebar { display: flex; flex-direction: column; gap: 2px; padding: 18px 12px; border-right: 1px solid var(--border); background: var(--card2); }
  .sidebar .section { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text3); padding: 12px 10px 6px; }
  .nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text2); text-decoration: none; font-weight: 500; border: 1px solid transparent; }
  .nav svg { width: 18px; height: 18px; }
  .nav:hover { background: var(--card); color: var(--text); }
  .nav.active { background: var(--blue-dim); border-color: rgba(37,99,235,.35); color: var(--blue); }
  .nav .soon { margin-left: auto; font-size: 9.5px; color: var(--text3); }
  .main { padding: 26px 30px 40px; }
}

/* Content */
h1.page { font-family: var(--display); font-size: 22px; margin-bottom: 2px; }
.page-desc { color: var(--text2); margin-bottom: 18px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.card h2 { font-family: var(--display); font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.stat .label { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); }
.stat .value { font-family: var(--display); font-size: 20px; font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.stat .sub { font-size: 12px; color: var(--text2); }
.module { display: flex; gap: 12px; align-items: flex-start; }
.module .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-dim); color: var(--blue); flex-shrink: 0; }
.module .ico svg { width: 20px; height: 20px; }
.module h3 { font-size: 14px; margin-bottom: 2px; }
.module p { font-size: 12.5px; color: var(--text2); }
.tag { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.tag-ok { background: rgba(34,197,94,.14); color: var(--green); }
.tag-warn { background: var(--gold-dim); color: #92400e; }
.tag-mute { background: var(--card2); color: var(--text2); border: 1px solid var(--border); }
.tag-bad { background: rgba(239,68,68,.12); color: var(--red); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; border-radius: 9px; border: none; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border2); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(239,68,68,.45); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.alert { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; border: 1px solid; }
.alert-info { background: rgba(37,99,235,.08); border-color: rgba(37,99,235,.3); }
.alert-ok { background: rgba(34,197,94,.09); border-color: rgba(34,197,94,.35); }
.alert-warn { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.35); }
.alert-bad { background: rgba(239,68,68,.09); border-color: rgba(239,68,68,.35); }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text2); }
.kv dd { overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: 12px; }

input[type=search], input[type=text] { width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border2); background: var(--surface); color: var(--text); font: inherit; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--text2); background: var(--card2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
.log { font-family: var(--mono); font-size: 11.5px; line-height: 1.8; max-height: 320px; overflow-y: auto; }
.muted { color: var(--text2); }
.install-bar { position: fixed; left: 12px; right: 12px; bottom: calc(76px + var(--safe-b)); z-index: 40; background: var(--navy); color: #fff; border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.install-bar span { flex: 1; font-size: 13px; }
.install-bar .btn { min-height: 34px; padding: 6px 12px; }
@media (min-width: 900px) { .install-bar { left: auto; right: 24px; bottom: 24px; max-width: 380px; } }

/* ── v0.2 Square module ── */
a.module { text-decoration: none; color: inherit; padding: 6px; border-radius: 10px; }
a.module:hover { background: var(--card2); }
.small { font-size: 12px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--card2); border: 1px solid var(--border); margin-bottom: 14px; max-width: 100%; overflow-x: auto; }
.seg a { padding: 7px 14px; border-radius: 8px; text-decoration: none; color: var(--text2); font-weight: 600; font-size: 13px; white-space: nowrap; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.drop { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 22px 14px; border: 2px dashed var(--border2); border-radius: 12px; cursor: pointer; text-align: center; color: var(--blue); }
.drop.over, .drop:hover { border-color: var(--blue); background: var(--blue-dim); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.files { list-style: none; margin-top: 10px; font-size: 13px; }
.files li { padding: 4px 0; overflow-wrap: anywhere; }
.list { display: flex; flex-direction: column; }
.row-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.row-link:last-child { border-bottom: none; }
.row-link:hover { background: var(--card2); }
.progress { height: 8px; border-radius: 6px; background: var(--card2); border: 1px solid var(--border); overflow: hidden; margin: 12px 0 6px; }
.progress div { height: 100%; background: var(--green); transition: width .3s; }
#sqMsg .alert { margin: 12px 0 0; }
.more { margin-top: 12px; }
.more summary { cursor: pointer; color: var(--text2); font-weight: 600; font-size: 13px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--border2); background: var(--surface); color: var(--text2); border-radius: 20px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chip span { color: var(--text3); margin-left: 3px; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.on span { color: rgba(255,255,255,.8); }
.je { background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; padding: 0 14px; }
.je summary { list-style: none; cursor: pointer; padding: 12px 0; }
.je summary::-webkit-details-marker { display: none; }
.je[open] { padding-bottom: 14px; }
.je[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.je-top, .je-sub { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.je-sub { font-size: 12.5px; color: var(--text2); margin-top: 2px; }
.je .alert { margin-top: 4px; }
.warn-list { padding-left: 18px; font-size: 13px; }
.warn-list li { margin-bottom: 6px; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text2); }
select { width: 100%; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--border2); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.je td:first-child, .je td .small { overflow-wrap: anywhere; }
.je td.num { width: 1%; padding-left: 8px; }
.row-link .tag { white-space: nowrap; flex-shrink: 0; }
input:disabled, select:disabled { opacity: .6; background: var(--card2); cursor: not-allowed; }
input[type=date] { width: 100%; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--border2); background: var(--surface); color: var(--text); font: inherit; }
.fa-table { background: var(--card); max-height: 70vh; overflow: auto; }
.fa-table table { min-width: 960px; }
.fa-table thead th { position: sticky; top: 0; z-index: 2; }
.fa-table thead tr.filters th { top: 35px; padding: 6px 8px; text-transform: none; letter-spacing: 0; }
.fa-table thead tr.filters input, .fa-table thead tr.filters select { padding: 6px 8px; font-size: 12.5px; min-width: 90px; }
.fa-table th.sortable { cursor: pointer; user-select: none; }
.fa-table th.sortable:hover, .fa-table th.sortable.on { color: var(--blue); }
.fa-table td:first-child, .fa-table th:first-child { position: sticky; left: 0; background: var(--card); z-index: 1; min-width: 200px; max-width: 280px; }
.fa-table thead th:first-child { z-index: 3; background: var(--card2); }
.fa-table td:first-child a { text-decoration: none; }
.fa-table td:first-child a:hover { text-decoration: underline; }
.fa-table tfoot td { background: var(--card2); border-top: 2px solid var(--border2); position: sticky; bottom: 0; }
.fa-table tfoot td:first-child { background: var(--card2); z-index: 2; }
.fa-table tbody tr:hover td { background: var(--card2); }
input[type=month] { width: 100%; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--border2); background: var(--surface); color: var(--text); font: inherit; }
.cg-table { background: var(--card); }
.cg-table table { min-width: 640px; }
.cg-table td { vertical-align: middle; }
.cg-table .btn { min-height: 32px; padding: 5px 12px; }
