:root {
  --bg: #f4f6fa; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #1e3a8a; --brand2: #2563eb; --pos: #047857; --neg: #b91c1c; --radius: 12px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1120; --card: #111a2e; --ink: #e2e8f0; --muted: #94a3b8; --line: #1f2b44;
          --brand: #93c5fd; --brand2: #3b82f6; --pos: #34d399; --neg: #f87171; --shadow: none; }
  .qr svg { background: #fff; padding: 8px; border-radius: 8px; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--brand2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2rem 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
h2.inline { display: inline; }
h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; }
.muted { color: var(--muted); } .small { font-size: .82rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.r { text-align: right; white-space: nowrap; }

.top { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.5rem; background: var(--card);
       border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.top nav { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; }
.top nav a { padding: .4rem .75rem; border-radius: 8px; color: var(--muted); font-weight: 500; }
.top nav a.on, .top nav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.logout { display: flex; align-items: center; gap: .6rem; margin: 0; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 1.5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem;
        box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.card.narrow { max-width: 720px; }
.card.link { display: block; color: var(--ink); transition: transform .1s; }
.card.link:hover { transform: translateY(-2px); text-decoration: none; }
.card.archived { opacity: .6; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.cards h3 { margin: 0; } .big { font-size: 1.5rem; font-weight: 700; margin: .4rem 0 .1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.2rem; }
.grid2 > .card { margin-bottom: 1.2rem; }
.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); }
.kpi span { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi strong { font-size: 1.25rem; display: block; margin-top: .15rem; }
.kpi em { font-style: normal; font-size: .85rem; }
.kpi.pos strong, .kpi.pos em { color: var(--pos); } .kpi.neg strong, .kpi.neg em { color: var(--neg); }
.price-box { text-align: right; display: flex; flex-direction: column; } .price-box strong { font-size: 1.6rem; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
          border-bottom: 1px solid var(--line); padding: .45rem .5rem; font-weight: 600; }
.tbl th.r { text-align: right; }
.tbl td { border-bottom: 1px solid var(--line); padding: .5rem; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl form { margin: 0; }
.scroll { overflow-x: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line);
       background: var(--card); color: var(--ink); padding: .5rem .95rem; border-radius: 8px; font: inherit;
       font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand2); text-decoration: none; }
.btn.primary { background: var(--brand2); border-color: var(--brand2); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn.small { padding: .25rem .6rem; font-size: .82rem; }
.btn.full { width: 100%; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--ink); }
input, select, textarea { font: inherit; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px;
                          background: var(--bg); color: var(--ink); font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand2); outline-offset: -1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; align-items: end; margin-bottom: .6rem; }
.form-grid .span2 { grid-column: span 2; }
.form-grid.danger { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
[hidden] { display: none !important; }
.search { display: flex; gap: .5rem; margin-bottom: 1.2rem; } .search input { flex: 1; }
details summary { cursor: pointer; list-style: none; } details[open] summary { margin-bottom: 1rem; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.flash.ok { background: rgba(4,120,87,.1); color: var(--pos); border: 1px solid rgba(4,120,87,.25); }
.flash.err { background: rgba(185,28,28,.08); color: var(--neg); border: 1px solid rgba(185,28,28,.25); }
.err-text { color: var(--neg); font-size: .9rem; }
.tag { font-size: .72rem; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: .05rem .5rem; color: var(--muted); }

.auth { display: grid; place-items: center; min-height: 100vh;
        background: radial-gradient(circle at 20% 10%, rgba(37,99,235,.12), transparent 45%), var(--bg); }
.auth-card { width: min(420px, 92vw); background: var(--card); border: 1px solid var(--line); border-radius: 16px;
             padding: 2rem; box-shadow: var(--shadow); }
.auth-card.wide { width: min(520px, 94vw); }
.auth-card form { display: grid; gap: .9rem; }
.auth-logo { display: block; margin-bottom: .6rem; }
.divider { display: flex; align-items: center; gap: .8rem; color: var(--muted); font-size: .8rem; margin: 1.2rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.qr { display: flex; justify-content: center; margin: 1rem 0; }
.secret { word-break: break-all; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; padding: 0; list-style: none; }
.codes code { display: block; background: var(--bg); padding: .5rem; border-radius: 6px; text-align: center; font-size: 1rem; user-select: all; }
.list { list-style: none; padding: 0; } .list li { display: flex; justify-content: space-between; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); }
pre { background: var(--bg); padding: .7rem; border-radius: 8px; overflow-x: auto; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 60px; gap: .7rem; align-items: center; margin-bottom: .45rem; font-size: .88rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--bg); border-radius: 99px; height: 10px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; }
.bar-val { text-align: right; color: var(--muted); }

@media (max-width: 700px) {
  .wrap { padding: 1rem; } .form-grid .span2 { grid-column: auto; } .top { gap: .6rem; padding: .6rem 1rem; }
  .bar-row { grid-template-columns: 100px 1fr 50px; }
}
