/* Hand-written stylesheet for v1.
 * TODO(v1): replace with a real Tailwind build (docs/architecture.md section 7).
 * For now this is a small utility set covering the templates that exist. */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --good: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); }
h1 { font-size: 1.3rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 1rem 0 .5rem; }

.app-header {
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .6rem 1rem;
}
.app-header .sep { color: var(--muted); }
.app-header .spacer { margin-left: auto; }
/* Scoped to the kiosk's bare <main> (a direct child of <body> there) so it
 * doesn't leak into the app shell's <main>, which lives inside .content and
 * must stretch to fill the sidebar's remaining width instead of centering. */
body > main { padding: 1rem; max-width: 1100px; margin: 0 auto; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.stack > * + * { margin-top: .75rem; }
.muted { color: var(--muted); }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: .75rem; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: .4rem .5rem; }
td { padding: .4rem .5rem; border-top: 1px solid var(--border); }

.btn {
  display: inline-block; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: .5rem .9rem; border-radius: 8px; cursor: pointer;
  font-size: 1rem; text-decoration: none;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-lg { padding: .9rem 1.4rem; font-size: 1.15rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select {
  font: inherit; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
input.pin { width: 8rem; text-align: center; letter-spacing: .3em; font-size: 1.6rem; }

.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; background: #e2e8f0; }
.pill.good { background: #dcfce7; color: var(--good); }
.pill.warn { background: #fef3c7; color: var(--warn); }
.pill.bad { background: #fee2e2; color: var(--bad); }

.kiosk { max-width: 720px; margin: 0 auto; }
.kiosk .card { padding: 1.5rem; }
.big-num { font-size: 2rem; font-weight: 700; }
.error { color: var(--bad); }
.param-ok { color: var(--good); }
.param-bad { color: var(--bad); font-weight: 700; }

/* --- App shell (staff) --- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; padding: 1rem .75rem;
}
.sidebar .brand { color: #fff; font-weight: 700; font-size: 1.1rem; text-decoration: none; padding: .25rem .5rem 1rem; display: block; }
.sidebar nav { flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: 1rem; }
.nav-group-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: .25rem .5rem; }
.nav-item { display: block; padding: .45rem .5rem; border-radius: 6px; color: #cbd5e1; text-decoration: none; font-size: .92rem; }
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-top { font-weight: 600; margin-bottom: 1rem; }
.sidebar-foot { border-top: 1px solid #1e293b; padding-top: .75rem; font-size: .85rem; }
.sidebar-foot form { margin-top: .4rem; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: .75rem 1.25rem;
}
.topbar-title { font-size: 1.15rem; font-weight: 600; }
.content main { padding: 1.25rem; max-width: 1440px; margin: 0; width: 100%; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.stat-row { display: flex; gap: 1.5rem; margin: .5rem 0; }
.stat-row .big-num { font-size: 1.6rem; }
h3 { font-size: .95rem; margin: .75rem 0 .25rem; }

/* --- dashboard visualizations --- */
.stack-bar { display: flex; height: .6rem; border-radius: 999px; overflow: hidden; background: var(--border); margin-top: .6rem; }
.stack-seg { height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: .1rem .9rem; margin-top: .5rem; font-size: .82rem; color: var(--muted); }
.legend-col { flex-direction: column; gap: .35rem; }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.legend-dot { width: .55rem; height: .55rem; border-radius: 999px; display: inline-block; flex: none; }

.donut-row { display: flex; align-items: center; gap: 1.25rem; margin: .5rem 0 .75rem; }
.donut { width: 92px; height: 92px; border-radius: 50%; flex: none; display: grid; place-items: center; }
.donut-hole {
  width: 62px; height: 62px; border-radius: 50%; background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut-hole .big-num { font-size: 1.3rem; line-height: 1; }

.bar-rows { display: flex; flex-direction: column; gap: .4rem; margin: .4rem 0; }
.bar-row { display: grid; grid-template-columns: 5.5rem 1fr 3rem; align-items: center; gap: .6rem; font-size: .85rem; }
.bar-label { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--border); border-radius: 999px; height: .55rem; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.bar-fill.good { background: var(--good); }
.bar-fill.bad { background: var(--bad); }
.bar-fill.warn { background: var(--warn); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }

.flash { padding: .5rem .75rem; border-radius: 6px; background: #e0f2fe; margin-bottom: .75rem; }
.flash.error { background: #fee2e2; }
.row-bad td { background: #fef2f2; }
.btn-sm { padding: .3rem .6rem; font-size: .85rem; }
.login-wrap { max-width: 360px; margin: 12vh auto; }

@media (max-width: 700px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex-basis: auto; }
}

/* --- settings form --- */
.stack label:not(.row) { display: block; font-size: .85rem; }
.stack label:not(.row) input, .stack label:not(.row) select {
  display: block; width: 100%; margin-top: .25rem; margin-bottom: .1rem;
}
.stack label.row input[type="checkbox"] { width: auto; }
