:root {
  --bg: #0f1419; --panel: #1a2029; --text: #e6e9ef; --muted: #8b94a3;
  --info: #3b82f6; --warn: #f59e0b; --urgent: #ef4444; --expired: #6b7280;
  --accent: #22c55e;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: flex; align-items: center; gap: 2rem; padding: .8rem 1.5rem;
  background: var(--panel); border-bottom: 1px solid #2a3340;
}
.brand { font-weight: 700; font-size: 1.1rem; }
nav a { margin-right: 1.2rem; color: var(--muted); }
nav a:hover { color: var(--text); }
main { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
h1, h2 { font-weight: 600; }
.muted { color: var(--muted); font-size: .9rem; }
.empty { color: var(--muted); padding: 1rem 0; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.card { background: var(--panel); border-radius: 10px; padding: 1rem; border-left: 4px solid var(--muted); }
.card .num { font-size: 1.8rem; font-weight: 700; display: block; }

.toolbar { display: flex; align-items: center; gap: 1rem; margin: 1rem 0; flex-wrap: wrap; }
button {
  background: var(--accent); color: #06240f; border: 0; border-radius: 8px;
  padding: .5rem .9rem; font-weight: 600; cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button.danger { background: var(--urgent); color: #fff; padding: .2rem .5rem; }

.alert-list, .notif-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.alert, .notif {
  display: flex; align-items: center; gap: .8rem; padding: .6rem .9rem;
  background: var(--panel); border-radius: 8px; margin-bottom: .4rem; border-left: 4px solid var(--muted);
}
.notif { align-items: flex-start; }
.notif .body { flex: 1; }
.notif.read { opacity: .5; }
.badge {
  font-size: .75rem; text-transform: uppercase; font-weight: 700;
  padding: .15rem .5rem; border-radius: 999px; background: #2a3340; white-space: nowrap;
}
.headline { flex: 1; }
.qty { color: var(--muted); font-variant-numeric: tabular-nums; }
.quote { color: var(--info); font-size: .85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.alert-row { display: flex; align-items: center; gap: .8rem; width: 100%; }
.roll-form { display: none; margin-top: .6rem; padding-top: .6rem; border-top: 1px solid #2a3340; }
.roll-form.open { display: block; }
.roll-form form { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; }
.roll-form label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .2rem; }
.roll-ticket { margin-top: .8rem; background: var(--bg); border: 1px solid #2a3340; border-radius: 8px; padding: .8rem; }
.roll-ticket h3 { margin: 0 0 .5rem; }
.alert.lvl-urgent, .alert.lvl-warn, .alert.lvl-expired, .alert.lvl-info { flex-direction: column; align-items: stretch; }

.lvl-info { border-left-color: var(--info); }
.lvl-warn { border-left-color: var(--warn); }
.lvl-urgent { border-left-color: var(--urgent); }
.lvl-expired { border-left-color: var(--expired); }
td.lvl-urgent { color: var(--urgent); font-weight: 700; }
td.lvl-warn { color: var(--warn); font-weight: 600; }
td.lvl-expired { color: var(--expired); }

.panel { background: var(--panel); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.panel summary { cursor: pointer; font-weight: 600; }
.grid-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-top: 1rem; }
.grid-form label { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); gap: .2rem; }
.grid-form .wide { grid-column: span 2; }
.grid-form button { grid-column: 1 / -1; }
input, select {
  background: var(--bg); color: var(--text); border: 1px solid #2a3340;
  border-radius: 6px; padding: .4rem .5rem; font: inherit;
}
form.inline { display: inline; margin: 0; }

table.positions { width: 100%; border-collapse: collapse; margin-top: 1rem; }
table.positions th, table.positions td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid #2a3340; }
table.positions th { color: var(--muted); font-weight: 600; font-size: .85rem; }
table.positions td { font-variant-numeric: tabular-nums; }

/* Auth */
.topbar .logout-form { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.link-btn { background: none; color: var(--muted); padding: .2rem .4rem; font-weight: 600; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.auth-card {
  max-width: 360px; margin: 4rem auto; background: var(--panel);
  padding: 2rem; border-radius: 12px; border: 1px solid #2a3340;
}
.auth-card h1 { margin-top: 0; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.2rem; }
.auth-form label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
.auth-error {
  background: rgba(239, 68, 68, .15); color: #fca5a5;
  padding: .6rem .8rem; border-radius: 8px; border-left: 4px solid var(--urgent);
}

@media (max-width: 700px) {
  .summary, .grid-form { grid-template-columns: repeat(2, 1fr); }
}
