:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --panel2: #18233a;
  --line: #243049;
  --text: #e8eefc;
  --muted: #93a0b8;
  --accent: #3b82f6;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --chip: #1e293b;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.app-shell { max-width: 980px; margin: 0 auto; padding: 16px 16px 96px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.brand { font-weight: 700; letter-spacing: .2px; }
.brand span { color: var(--muted); font-weight: 500; margin-left: 8px; font-size: 13px; }
.userpill { background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--muted); }

.login {
  max-width: 420px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login h1 { margin: 0 0 6px; font-size: 24px; }
.login p { margin: 0 0 18px; color: var(--muted); line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field textarea, .field select {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 12px 12px; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; background: var(--accent); color: white; font-weight: 600;
}
.btn.secondary { background: var(--chip); border: 1px solid var(--line); color: var(--text); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.block { width: 100%; }
.btn.row { display: inline-flex; align-items: center; gap: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .grid.two { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.statrow { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 110px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px;
}
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }

.flag {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line);
}
.flag:first-of-type { border-top: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: 0 0 auto; }
.dot.expired, .dot.penalty { background: var(--bad); }
.dot.open_ticket { background: var(--warn); }
.dot.due_soon { background: #38bdf8; }
.list-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.list-item:first-of-type { border-top: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--chip);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted);
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 4px; justify-content: center;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(11,18,32,.92); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 140px; border: 0; background: transparent; color: var(--muted);
  padding: 10px 8px; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.tab.on { background: var(--panel2); color: var(--text); }
.tab .ico { display: block; font-size: 16px; margin-bottom: 2px; }

.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center;
  z-index: 40; padding: 12px;
}
.sheet .panel {
  width: min(640px, 100%); max-height: 90vh; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px 18px 14px 14px; padding: 16px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.err { color: #fecaca; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: 13px; }
.ok { color: #bbf7d0; background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.35); padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: 13px; }
.sources { font-size: 12px; color: var(--muted); line-height: 1.5; }
.sources code { color: #cbd5e1; }
.drop {
  border: 1.5px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted);
  background: var(--panel2);
}
.preview { max-width: 100%; max-height: 180px; border-radius: 10px; margin-top: 10px; border: 1px solid var(--line); }
