:root, :root[data-theme="light"] {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --ink: #1c1a17;
  --muted: #6b6459;
  --line: #e0dacf;
  --accent: #c94a2c;
  --accent-ink: #ffffff;
  --field: #faf8f3;
  --ok: #2f7d32;
  --accent-tint: #fbeee9;
  --pill-on-bg: #e7f2e8;
  --pill-off-bg: #f0e5e2;
  --logo-invert: 0;
  --radius: 10px;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
}

:root[data-theme="dark"] {
  --bg: #0d0e10;
  --panel: #17181c;
  --ink: #e9e9ec;
  --muted: #9a9aa2;
  --line: #2a2b31;
  --accent: #e0603f;
  --accent-ink: #ffffff;
  --field: #1e1f24;
  --ok: #5cc46a;
  --accent-tint: #2a1a15;
  --pill-on-bg: #163019;
  --pill-off-bg: #331d18;
  --logo-invert: 1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}

header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.95rem 1.6rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
header .brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
header .header-logo { height: 19px; width: auto; display: block; filter: invert(var(--logo-invert)); }
header .app-name {
  font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; color: var(--ink);
  padding-left: 0.6rem; border-left: 1px solid var(--line); line-height: 1;
}
.theme-toggle {
  background: none; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); padding: 0;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
header nav { margin-left: auto; display: flex; gap: 1.3rem; font-size: 0.85rem; }
header nav button {
  background: none; border: none; cursor: pointer; padding: 0 0 0.2rem;
  color: var(--muted); font-size: 0.85rem; font-family: inherit;
  border-bottom: 2px solid transparent;
}
header nav button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
header .logout { color: var(--muted); text-decoration: none; font-size: 0.8rem; }

.wrap { max-width: 1040px; margin: 1.6rem auto; padding: 0 1.6rem; }
.studio { display: grid; grid-template-columns: 1fr 380px; gap: 1.4rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card h2 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); margin: 0; padding: 1rem 1.2rem 0.2rem;
}
.card .body { padding: 0.6rem 1.2rem 1.2rem; }

label { display: block; font-size: 0.78rem; color: var(--muted); margin: 0.85rem 0 0.3rem; }
input[type=text], input[type=url], input[type=password], select {
  width: 100%; padding: 0.55rem 0.65rem; border: 1px solid var(--line);
  background: var(--field); border-radius: 8px; font-size: 0.9rem;
  color: var(--ink); font-family: inherit;
}
.row { display: flex; gap: 0.8rem; }
.row > div { flex: 1; }

.slugline { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); margin-top: 0.4rem; }
.slugline b { color: var(--accent); }

.swatches { display: flex; gap: 0.5rem; margin-top: 0.3rem; }
.sw { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; padding: 0; }
.sw.sel { outline: 2px solid var(--ink); outline-offset: 1px; }

.toggle { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.9rem; font-size: 0.85rem; }
.logo-drop {
  margin-top: 0.35rem; border: 1px dashed var(--line); border-radius: 8px;
  padding: 0.7rem; font-size: 0.8rem; color: var(--muted);
  background: var(--field); text-align: center; cursor: pointer;
}

.preview { position: sticky; top: 1.6rem; text-align: center; align-self: start; }
.preview .qrbox { padding: 1.4rem; display: flex; justify-content: center; min-height: 240px; align-items: center; }
.preview img { width: 230px; height: auto; }
.status { font-size: 0.75rem; margin: 0.2rem 0 0; }
.status.ok::before { content: "•"; color: var(--ok); margin-right: 0.3rem; }
.status.bad { color: var(--accent); }
.status.bad::before { content: "•"; color: var(--accent); margin-right: 0.3rem; }

.btns { display: flex; gap: 0.6rem; padding: 0.4rem 1.2rem 1.2rem; }
.btn {
  flex: 1; padding: 0.6rem; border-radius: 8px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg); font-size: 0.85rem; cursor: pointer;
  text-align: center; font-family: inherit;
}
.btn.alt { background: transparent; color: var(--ink); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.branding { margin-top: 1.4rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
td .mono { font-family: var(--mono); font-size: 0.8rem; }
td .link-actions button {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  padding: 0.25rem 0.5rem; font-size: 0.75rem; cursor: pointer; margin-right: 0.3rem;
  color: var(--ink); font-family: inherit;
}
td .link-actions button.danger { color: var(--accent); border-color: var(--accent); }

/* Links gallery (cards) */
.links-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem 0; }
.links-head h2 { padding: 0; }
.links-head input { max-width: 260px; padding: 0.45rem 0.65rem; border: 1px solid var(--line); background: var(--field); border-radius: 8px; font-size: 0.85rem; color: var(--ink); font-family: inherit; }
.link-card { display: grid; grid-template-columns: 68px 1fr auto; grid-template-areas: "qr main scans" "actions actions actions"; gap: 0.7rem 1rem; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.link-card:last-child { border-bottom: none; }
.lc-qr { grid-area: qr; width: 68px; height: 68px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px; object-fit: contain; }
.lc-main { grid-area: main; min-width: 0; }
.lc-dest { font-size: 0.95rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-sub { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.lc-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.45rem; align-items: center; }
.lc-tags .tag { font-size: 0.7rem; background: var(--field); border: 1px solid var(--line); border-radius: 999px; padding: 0.12rem 0.55rem; color: var(--muted); }
.lc-date { font-size: 0.72rem; color: var(--muted); font-family: var(--mono); }
.lc-scans { grid-area: scans; text-align: right; }
.lc-scans .lc-n { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.lc-scans .lc-l { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.lc-actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.lc-actions button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 0.3rem 0.65rem; font-size: 0.78rem; cursor: pointer; color: var(--ink); font-family: inherit; }
.lc-actions button.lc-download { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.lc-actions button.danger { color: var(--accent); border-color: var(--accent); }
.pill { font-size: 0.72rem; padding: 0.1rem 0.5rem; border-radius: 999px; }
.pill.on { background: var(--pill-on-bg); color: var(--ok); }
.pill.off { background: var(--pill-off-bg); color: var(--accent); }

.bars { margin-top: 0.6rem; }
.bar-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.25rem 0; font-size: 0.8rem; }
.bar-row .lab { width: 90px; color: var(--muted); }
.bar-row .track { flex: 1; background: var(--line); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-row .fill { display: block; background: var(--accent); height: 100%; min-width: 2px; }
.bar-row .n { width: 34px; text-align: right; font-family: var(--mono); }

.artist-row { display: flex; align-items: center; gap: 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.artist-row:last-child { border-bottom: none; }
.artist-thumb { width: 96px; height: 48px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.artist-meta { flex: 1; display: flex; flex-direction: column; gap: 0.15rem; }
.artist-meta .mono { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.artist-row button.danger { background: none; border: 1px solid var(--accent); color: var(--accent); border-radius: 6px; padding: 0.35rem 0.8rem; font-size: 0.8rem; cursor: pointer; font-family: inherit; }

.hidden { display: none; }
.empty { color: var(--muted); font-size: 0.85rem; padding: 1rem 0; }
.bignum { font-size: 2rem; font-weight: 700; }

/* Scans analytics dashboard */
.scope-line { font-size: 0.8rem; color: var(--muted); margin: 0 0 1rem; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; margin-bottom: 1.1rem; }
.kpi { background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; }
.kpi .n { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.kpi .l { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-top: 0.2rem; }
.kpi .sub { font-size: 0.76rem; color: var(--muted); margin-top: 0.1rem; }
.geo-flag { display: inline-block; background: var(--pill-off-bg); color: var(--accent); font-size: 0.66rem; padding: 0.1rem 0.45rem; border-radius: 999px; margin-left: 0.3rem; vertical-align: middle; }
.scan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.scan-card { background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1.1rem 1.1rem; }
.scan-card h2 { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 0 0 0.6rem; padding: 0; }
.scan-card.wide { grid-column: 1 / -1; }
.hours { display: flex; align-items: flex-end; gap: 3px; height: 84px; }
.hours .h { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0.85; }
.days { display: flex; align-items: flex-end; gap: 5px; height: 84px; }
.days .d { flex: 1; background: var(--ink); border-radius: 2px 2px 0 0; }
.axis { display: flex; justify-content: space-between; font-size: 0.66rem; color: var(--muted); margin-top: 0.25rem; font-family: var(--mono); }

footer { position: fixed; bottom: 0.5rem; right: 0.9rem; font-size: 0.72rem; color: var(--muted); }

/* How it works */
.help { max-width: 720px; margin: 0 auto; }
.help-title { font-size: 1.5rem; letter-spacing: -0.02em; margin: 0 0 0.4rem; }
.help-lead { font-size: 1.02rem; color: var(--muted); margin: 0 0 1.4rem; }
.help-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.4rem; margin-bottom: 1rem; }
.help-card h2 { font-size: 0.95rem; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
.help-card p { margin: 0.5rem 0; font-size: 0.92rem; }
.help-quickstart { border-color: var(--accent); background: var(--accent-tint); }
.faq { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.faq:last-child { border-bottom: none; }
.faq .q { font-weight: 650; font-size: 0.9rem; margin: 0 0 0.2rem; }
.faq .a { color: var(--muted); font-size: 0.88rem; margin: 0; }
.help-note { background: var(--field); border-radius: 8px; padding: 0.7rem 0.9rem; font-size: 0.88rem; color: var(--muted); margin-top: 0.9rem; }
.help-steps { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.help-steps li { margin: 0.4rem 0; font-size: 0.92rem; }
.flow { margin: 1rem 0; }
.flow-step { position: relative; background: var(--field); border: 1px solid var(--line); border-radius: 9px; padding: 0.7rem 0.9rem 0.7rem 2.6rem; font-size: 0.9rem; }
.flow-step.accent { border-color: var(--accent); background: var(--accent-tint); }
.flow-step small { color: var(--muted); }
.flow-n { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); width: 1.3rem; height: 1.3rem; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 0.75rem; display: flex; align-items: center; justify-content: center; }
.flow-step.accent .flow-n { background: var(--accent); }
.flow-arrow { text-align: center; color: var(--muted); font-size: 1.1rem; line-height: 1.6; }

.login-wrap { max-width: 320px; margin: 18vh auto; text-align: center; }
.login-wrap .login-logo { height: 26px; width: auto; margin-bottom: 0.9rem; filter: invert(var(--logo-invert)); }
.login-wrap h1 { font-size: 1.2rem; margin: 0.2rem 0; }
.login-wrap .err { color: var(--accent); font-size: 0.85rem; }
.login-wrap button { width: 100%; margin-top: 0.9rem; }
