/* Design tokens mirror the Pencil document (pencil-new.pen). */
:root {
  --accent: #f7931a;
  --accent-soft: #f7931a1f;
  --bad: #f87171;
  --bg: #121417;
  --border: #2a2e35;
  --fg: #ffffff;
  --muted: #868c97;
  --ok: #4ade80;
  --on-accent: #121417;
  --sidebar-bg: #181b1f;
  --surface: #1b1e23;
  --radius: 8px;
  --radius-card: 12px;
}

* { box-sizing: border-box; }
/* .card sets display:flex, which would otherwise win over the UA rule for
   [hidden] and show every card the panel means to keep back */
[hidden] { display: none !important; }

body {
  margin: 0;
  /* --bg-image is set by theme.js; the flat colour shows through when it is
     absent, and stays behind a transparent image */
  background: var(--bg-image, none) center / cover no-repeat fixed var(--bg);
  color: var(--fg);
  font: 400 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* --- shell: 240px sidebar + main column --- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  flex: 0 0 240px;
  width: 240px;
  padding: 24px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 800; }
.brand .i { width: 22px; height: 22px; color: var(--accent); }
.brand-logo { width: 22px; height: 22px; object-fit: contain; flex: none; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}
.nav a .i { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: #ffffff0a; color: var(--fg); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.nav-spacer { flex: 1; }

/* language picker: in the sidebar, and on the admin login screen */
.lang-row, label.lang { display: flex; align-items: center; gap: 8px; color: var(--muted); }
label.lang { padding: 0 4px; }
select.lang { flex: 1; padding: 7px 10px; font-size: 13px; }
.nav-out { color: var(--bad); background: none; border: 0; }
.nav-out:hover { background: #f871711a; color: var(--bad); }

.main {
  flex: 1;
  min-width: 0;
  max-width: 1000px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

h1 { margin: 0; font-size: 24px; font-weight: 800; }
.topbar { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
}

/* --- card --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-margin-top: 24px;
}
.card > h2,
.card > h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--muted);
}
.card > h3 { margin-top: 6px; }

/* --- controls --- */

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > label { flex: none; }

label { display: flex; align-items: center; gap: 8px; color: var(--muted); }
label.stack { flex-direction: column; align-items: stretch; gap: 6px; font-size: 13px; }

input, select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--fg);
  font: inherit;
  min-width: 0;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type=number] { width: 5.5rem; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
.grow { flex: 1 1 12rem; }

button {
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: var(--radius);
  padding: 11px 20px;
  font: 600 14px/1.2 inherit;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  font-weight: 500;
}
button.secondary:hover { background: #ffffff0a; filter: none; }
button.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
button.link:hover { filter: none; text-decoration: underline; }
button.link.danger { color: var(--bad); }
button.link + button.link { margin-left: 12px; }

/* --- tables: Table > Row > Cell, one column width per cell --- */

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
/* below this the fixed columns squeeze the flexible ones to nothing; scroll
   the table instead of shrinking the cells */
.table-scroll table { min-width: 720px; }
.table-scroll #groups { min-width: 960px; }
th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 8px 10px 8px 0;
}
td {
  font-size: 13px;
  padding: 10px 10px 10px 0;
  border-top: 1px solid var(--border);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
td:last-child, th:last-child { padding-right: 0; }
td input, td select { padding: 7px 10px; font-size: 13px; width: 100%; }
td input[type=checkbox] { width: 16px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); }

/* key/value table used by the stats card and the price list */
.kv th { font-weight: 400; font-size: 14px; padding: 8px 10px 8px 0; border-top: 1px solid var(--border); }
.kv tr:first-child th, .kv tr:first-child td { border-top: 0; }
.kv td { font-weight: 700; font-size: 14px; }

/* --- chips --- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
.chip .sub { font-size: 12px; color: var(--muted); }
.chip .i { width: 13px; height: 13px; color: var(--muted); cursor: pointer; }

/* --- misc --- */

.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.error { color: var(--bad); min-height: 1.2em; }

.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.bar span { display: block; height: 100%; background: var(--accent); }

.qr { border-radius: var(--radius-card); border: 1px solid var(--border); background: #fff; }

#login { display: flex; flex-direction: column; gap: 18px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.qr-box {
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.qr-box img { width: 176px; height: 176px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 4px; }

/* --- login screen (its own centred layout, no sidebar) --- */

.login {
  max-width: 600px;
  margin: 0 auto;
  padding: 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}
.login h1 { font-size: 28px; }

.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; flex: none; min-height: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-spacer { display: none; }
  .main { padding: 24px; }
}
