:root {
  --red: #da291c;
  --red-dark: #b71f14;
  --yellow: #ffc72c;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --text: #1d1b19;
  --muted: #6f6a64;
  --border: #e7e3dd;
  --ok: #1f8a4c;
  --ok-bg: #e6f4ec;
  --warn: #b25e00;
  --warn-bg: #fff1dc;
  --bad: #c62828;
  --bad-bg: #fdeaea;
  --idle: #6f6a64;
  --idle-bg: #efedea;
  --info: #2457c5;
  --info-bg: #e8eefc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 27, 25, 0.06), 0 4px 16px rgba(29, 27, 25, 0.05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Be Vietnam Pro", system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.error-text { color: var(--bad); min-height: 1.2em; margin: 0; font-size: 13px; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1440px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--red); color: var(--yellow); font-weight: 700; font-size: 24px; display: grid; place-items: center; flex: none; }
.brand-title { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-size: 12.5px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); border-color: #d6d0c7; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-icon { padding: 8px 12px; font-size: 16px; line-height: 1; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 250px; padding: 6px; z-index: 30; }
.menu-item { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 7px; background: none; border: 0; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.mobile-only { display: none; }

/* Layout */
.container { max-width: 1440px; margin: 0 auto; padding: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); cursor: default; }
.card.clickable { cursor: pointer; }
.card-label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; justify-content: space-between; }
.card-value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.card-value small { font-size: 14px; color: var(--muted); font-weight: 500; }
.card-foot { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.card { min-width: 0; overflow-wrap: anywhere; }
.card .clickable { cursor: pointer; }
.card-split { display: grid; grid-template-columns: 1fr 1fr; }
.card-split > div { padding-right: 8px; border-radius: 8px; }
.card-split > div + div { padding-left: 12px; border-left: 1px solid var(--border); }
.card-split > div:hover .card-foot { color: var(--text); }
.bar { height: 6px; border-radius: 99px; background: var(--idle-bg); margin-top: 10px; overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; }

.runs { display: flex; gap: 16px; flex-wrap: wrap; margin: 14px 2px 4px; color: var(--muted); font-size: 12.5px; }
.runs .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0 12px; }
.search, .select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.search { flex: 1 1 240px; max-width: 340px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; }
.chip .count { color: var(--muted); margin-left: 4px; }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.chip.active .count { color: #d9d4cd; }

/* Table */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 980px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: #fcfbf9; }
.table tbody tr:last-child td { border-bottom: 0; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 40px !important; }
.store-name { font-weight: 600; }
.store-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.hours { font-variant-numeric: tabular-nums; font-size: 13px; line-height: 1.5; }
.hours .grp { display: block; }
.hours .lbl { color: var(--muted); display: inline-block; min-width: 46px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.match { background: var(--ok-bg); color: var(--ok); }
.pill.mismatch { background: var(--warn-bg); color: var(--warn); }
.pill.missing { background: var(--bad-bg); color: var(--bad); }
.pill.nohours, .pill.nodata, .pill.review { background: var(--idle-bg); color: var(--idle); }
.pill.upcoming { background: var(--info-bg); color: var(--info); }
.pill.closed { background: var(--idle-bg); color: var(--idle); }
.pill.manual { background: var(--info-bg); color: var(--info); }
.sub { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; max-width: 220px; }
.mop { font-weight: 700; font-size: 12.5px; }
.mop.on { color: var(--ok); }
.mop.off { color: var(--bad); }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(29, 27, 25, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(760px, 100%); background: var(--bg); z-index: 50; transform: translateX(100%); transition: transform .2s ease; overflow-y: auto; box-shadow: -8px 0 32px rgba(0,0,0,.12); }
.drawer.open { transform: none; }
.drawer-head { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 16px 20px; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; z-index: 2; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { padding: 16px 20px 40px; display: grid; gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.panel h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.cmp { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cmp th, .cmp td { padding: 7px 6px; border-bottom: 1px solid var(--border); text-align: center; }
.cmp th:first-child, .cmp td:first-child { text-align: left; font-weight: 600; white-space: nowrap; }
.cmp thead th { color: var(--muted); font-weight: 600; }
.cmp td.diff { background: var(--warn-bg); color: var(--warn); font-weight: 600; border-radius: 4px; }
.cmp tr:last-child td { border-bottom: 0; }
.cmp-wrap { overflow-x: auto; }

.src-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.src-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; background: var(--surface-2); }
.src-card b { display: block; margin-bottom: 4px; font-size: 13px; }
.src-card .raw { white-space: pre-line; color: var(--muted); margin-top: 6px; }

.raw-text { white-space: pre-line; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 4px 0 8px; }
.warn-list { margin: 6px 0 0; padding-left: 18px; color: var(--warn); font-size: 12.5px; }

.hours-form { display: grid; gap: 6px; }
.hours-row { display: grid; grid-template-columns: 40px 1fr 1fr auto; gap: 8px; align-items: center; }
.hours-row input[type="time"], .field input, .field select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); width: 100%; }
.hours-row label { font-size: 12.5px; color: var(--muted); display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.field { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* Login */
.login { position: fixed; inset: 0; background: var(--bg); z-index: 100; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: min(360px, 100%); display: grid; gap: 12px; box-shadow: var(--shadow); text-align: center; justify-items: center; }
.login-card h1 { margin: 4px 0 0; font-size: 20px; }
.login-card p { margin: 0; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; }
.login-card .btn { width: 100%; justify-content: center; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 200; max-width: min(560px, calc(100% - 32px)); box-shadow: var(--shadow); font-size: 13.5px; white-space: pre-line; }
.toast.error { background: var(--bad); }

@media (max-width: 720px) {
  .container { padding: 16px; }
  .topbar-inner { padding: 10px 16px; }
  .actions .btn:not(.btn-primary):not(.btn-icon) { display: none; }
  .menu-item.mobile-only { display: block; }
  .kv { grid-template-columns: 100px 1fr; }
}
