/* Base styles and tokens. Owned by core. View-specific styles go in counter.css / manager.css. */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #1d2327;
  --muted: #5f6b73;
  --border: #d9d4c9;
  --primary: #1f3a4d;
  --primary-text: #ffffff;
  --accent: #2f7d6d;
  --ok: #2f7d4f;
  --ok-bg: #e4f2e8;
  --warn: #8a5a00;
  --warn-bg: #fdf1d6;
  --danger: #a12a2a;
  --danger-bg: #fbe3e1;
  --info-bg: #e5eef5;
  --focus: #2b6cb0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: var(--primary); }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.app { max-width: 1200px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.spacer { flex: 1; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--primary); color: var(--primary-text);
  padding: 8px 16px;
}
.topbar .brand { font-weight: 700; letter-spacing: 0.01em; }
.topbar .nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar .nav-link { color: var(--primary-text); text-decoration: none; padding: 6px 10px; border-radius: 6px; opacity: 0.85; }
.topbar .nav-link:hover { opacity: 1; background: rgba(255, 255, 255, 0.1); }
.topbar .nav-link.active { opacity: 1; background: rgba(255, 255, 255, 0.18); }
.topbar .who { display: flex; gap: 10px; align-items: center; }
.topbar .btn-ghost { color: var(--primary-text); border-color: rgba(255, 255, 255, 0.4); background: transparent; }
.topbar .btn-ghost:hover, .topbar .btn-ghost:focus-visible { background: rgba(255, 255, 255, 0.15); color: var(--primary-text); }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: #172d3c; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 0.9rem; }
.btn-lg { padding: 12px 20px; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* Forms */
label { display: block; font-weight: 600; margin: 10px 0 4px; }
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
input[type="checkbox"], input[type="radio"] { width: auto; }
.form-error { color: var(--danger); min-height: 1.2em; }
.field-inline { display: flex; gap: 8px; align-items: center; }
.field-inline label { margin: 0; font-weight: 500; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #faf8f4; }

/* Pills and notices */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--surface-2); color: var(--text); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-info { background: var(--info-bg); color: var(--primary); }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--info-bg); }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-danger { background: var(--danger-bg); color: var(--danger); }
.notice-ok { background: var(--ok-bg); color: var(--ok); }

/* Stats */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .stat-label { color: var(--muted); font-size: 0.85rem; }
.stat .stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); transition: opacity 0.35s, transform 0.35s; }
.toast-ok { background: var(--ok); }
.toast-warn { background: var(--warn); }
.toast-error { background: var(--danger); }
.toast-out { opacity: 0; transform: translateY(6px); }

/* Login */
.login-wrap { display: grid; place-items: center; min-height: 70vh; }
.login-card { width: min(380px, 100%); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 24, 28, 0.45); display: grid; place-items: center; z-index: 900; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 20px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }

@media print {
  .topbar, .toasts, .no-print { display: none !important; }
  body { background: #fff; }
  .app { max-width: none; padding: 0; }
}
