/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
input, textarea { font: inherit; }

/* ─── Tokens ─── */
:root {
  --bg:          #10161F;
  --sidebar:     #0B1018;
  --surface:     #172030;
  --raised:      #1F2D40;
  --border:      #2D3F55;
  --text:        #D8E8F5;
  --muted:       #6B8299;
  --faint:       #3A5068;
  --accent:      #5B8DEF;
  --accent-dim:  #1B2D50;
  --accent-glow: rgba(91, 141, 239, .15);
  --green:       #34D399;
  --green-dim:   #0D3324;
  --amber:       #FBBF24;
  --amber-dim:   #3B2A04;
  --red:         #F87171;
  --red-dim:     #3B0D0D;
  --radius:      6px;
  --radius-lg:   10px;
  --sidebar-w:   240px;
  --topbar-h:    56px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #ECF0F8;
    --sidebar:     #1A2B40;
    --surface:     #FFFFFF;
    --raised:      #F2F6FC;
    --border:      #C8D5E8;
    --text:        #0D1B2A;
    --muted:       #526578;
    --faint:       #A8BDD0;
    --accent:      #2563EB;
    --accent-dim:  #DBEAFE;
    --accent-glow: rgba(37, 99, 235, .1);
    --green:       #059669;
    --green-dim:   #D1FAE5;
    --amber:       #D97706;
    --amber-dim:   #FEF3C7;
    --red:         #DC2626;
    --red-dim:     #FEE2E2;
  }
}

:root[data-theme="light"] {
  --bg:          #ECF0F8;
  --sidebar:     #1A2B40;
  --surface:     #FFFFFF;
  --raised:      #F2F6FC;
  --border:      #C8D5E8;
  --text:        #0D1B2A;
  --muted:       #526578;
  --faint:       #A8BDD0;
  --accent:      #2563EB;
  --accent-dim:  #DBEAFE;
  --accent-glow: rgba(37, 99, 235, .1);
  --green:       #059669;
  --green-dim:   #D1FAE5;
  --amber:       #D97706;
  --amber-dim:   #FEF3C7;
  --red:         #DC2626;
  --red-dim:     #FEE2E2;
}

:root[data-theme="dark"] {
  --bg:          #10161F;
  --sidebar:     #0B1018;
  --surface:     #172030;
  --raised:      #1F2D40;
  --border:      #2D3F55;
  --text:        #D8E8F5;
  --muted:       #6B8299;
  --faint:       #3A5068;
  --accent:      #5B8DEF;
  --accent-dim:  #1B2D50;
  --accent-glow: rgba(91, 141, 239, .15);
  --green:       #34D399;
  --green-dim:   #0D3324;
  --amber:       #FBBF24;
  --amber-dim:   #3B2A04;
  --red:         #F87171;
  --red-dim:     #3B0D0D;
}

/* ─── Base ─── */
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}

/* ─── Login ─── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-screen::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% 40%, var(--accent-glow), transparent);
  pointer-events: none;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 360px;
  position: relative;
}

.login-wordmark {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 28px;
  letter-spacing: -0.02em;
}

.login-title span { color: var(--accent); }

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.field-wrap { position: relative; }

.field input {
  width: 100%;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 150ms, box-shadow 150ms;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.pw-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px;
}

.pw-toggle:hover { color: var(--text); }

.login-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
  transition: opacity 150ms;
}

.login-btn:hover  { opacity: .9; }
.login-btn:active { opacity: .8; }
.login-btn:disabled { opacity: .6; cursor: not-allowed; }

.login-error {
  margin-top: 12px;
  font-size: 13px;
  color: var(--red);
  min-height: 20px;
}

/* ─── Dashboard shell ─── */
.dashboard { display: flex; min-height: 100vh; }

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.brand-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 8px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  transition: background 120ms, color 120ms;
  position: relative;
}

.nav-item:hover { background: var(--raised); color: var(--text); }

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--accent);
  border-radius: 1px;
}

.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  font-family: ui-monospace, 'SF Mono', monospace;
}

.nav-live-dot {
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.nav-item-disabled {
  opacity: .4;
  cursor: default;
}

.nav-soon-tag {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  margin-bottom: 6px;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.user-name  { font-size: 12px; font-weight: 600; color: var(--text); }
.user-role  { font-size: 11px; color: var(--muted); }

.sidebar-actions { display: flex; gap: 6px; }

.sidebar-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--raised);
  border: 1px solid var(--border);
  transition: color 120ms, background 120ms;
}

.sidebar-btn:hover { color: var(--text); }
.sidebar-btn.danger:hover { color: var(--red); }

/* ─── Main ─── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.view-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--faint);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 2px var(--green-dim);
}

/* ─── Panels ─── */
.panel { padding: 24px 28px 48px; }

.hidden { display: none !important; }

.section { margin-bottom: 32px; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-meta { font-size: 12px; color: var(--faint); }

/* ─── KPI row ─── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.kpi-card.alert { border-color: var(--amber); }

.kpi-card.alert::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--amber);
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-card.alert .kpi-value { color: var(--amber); }

.kpi-sub { font-size: 12px; color: var(--muted); }

/* ─── Tools grid ─── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: border-color 160ms, transform 120ms, box-shadow 160ms;
}

.tool-card.live {
  cursor: pointer;
}

.tool-card.live:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.tool-card.soon { opacity: .55; }

.tool-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.tool-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 20px;
  border: 1px solid;
}

.tool-badge.live  { color: var(--green); border-color: var(--green); background: var(--green-dim); }
.tool-badge.soon  { color: var(--muted); border-color: var(--border); background: var(--raised); }

.tool-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tool-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

.tool-arrow {
  position: absolute;
  right: 16px;
  bottom: 16px;
  color: var(--faint);
  transition: color 160ms, transform 160ms;
}

.tool-card.live:hover .tool-arrow { color: var(--accent); transform: translate(2px, -2px); }

/* ─── Data table ─── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-scroll { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--raised); }

.mono {
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.store-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-family: ui-monospace, 'SF Mono', monospace;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  color: var(--muted);
  text-transform: uppercase;
}

.days-badge {
  font-size: 11px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--red);
  background: var(--red-dim);
  border-radius: 4px;
  padding: 2px 7px;
}

.table-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.table-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ─── Stores ─── */
.stores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.store-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.store-code {
  width: 40px;
  height: 40px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  font-family: ui-monospace, monospace;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.store-info { flex: 1; min-width: 0; }
.store-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }

.store-domain {
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.store-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
}

.store-status.ok     { color: var(--green); }
.store-status.warn   { color: var(--amber); }
.store-status.err    { color: var(--red); }

.pip {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ok   .pip { background: var(--green); }
.warn .pip { background: var(--amber); }
.err  .pip { background: var(--red); }

/* ─── Docs & links ─── */
.docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.links-list { display: flex; flex-direction: column; gap: 10px; }

.link-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color 140ms;
}

.link-row:hover { border-color: var(--accent); }

.link-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}

.link-body { flex: 1; min-width: 0; }
.link-title { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.link-desc  { font-size: 12px; color: var(--muted); line-height: 1.5; }

.link-url {
  font-size: 11px;
  color: var(--faint);
  font-family: ui-monospace, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

.link-actions { display: flex; gap: 4px; flex-shrink: 0; }

.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  color: var(--muted);
  border: 1px solid transparent;
  transition: background 120ms, color 120ms, border-color 120ms;
}

.btn-ghost:hover { background: var(--raised); border-color: var(--border); color: var(--text); }
.btn-ghost.del:hover { color: var(--red); }

/* ─── Buttons ─── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 140ms;
}

.btn-primary:hover { opacity: .88; }

.btn-cancel {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--raised);
  border: 1px solid var(--border);
  transition: color 120ms;
}

.btn-cancel:hover { color: var(--text); }

.tag-admin {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  border-radius: 4px;
  padding: 2px 6px;
}

/* ─── Info box ─── */
.info-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.info-box svg { flex-shrink: 0; margin-top: 1px; }

.info-box code {
  background: var(--raised);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
}

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ─── Scopes reference box ─── */
.scopes-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.scope-row {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scope-row:last-child { border-bottom: none; }

.scope-row-all { background: var(--raised); }

.scope-meta { display: flex; flex-direction: column; gap: 2px; }

.scope-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.scope-sub {
  font-size: 11px;
  color: var(--muted);
}

.tag-recommended {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
}

.scope-copy {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.scope-string {
  flex: 1;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  word-break: break-all;
  background: none;
  padding: 0;
}

.copy-btn {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 4px 10px;
  transition: opacity 140ms;
  white-space: nowrap;
}

.copy-btn:hover  { opacity: .8; }
.copy-btn.copied { color: var(--green); border-color: var(--green); background: var(--green-dim); }

/* ─── Loading skeleton ─── */
.skeleton {
  background: linear-gradient(90deg, var(--raised) 25%, var(--border) 50%, var(--raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
  display: block;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Responsive ─── */
@media (max-width: 700px) {
  .sidebar  { display: none; }
  .main     { margin-left: 0; }
  .kpi-row  { grid-template-columns: 1fr 1fr; }
  .tools-grid { grid-template-columns: 1fr; }
  .stores-grid { grid-template-columns: 1fr; }
  .panel    { padding: 16px 16px 40px; }
  .topbar   { padding: 0 16px; }
}

/* ═══════════════════════════════════════
   ANALYTICS DASHBOARD
═══════════════════════════════════════ */

/* ─── Filter bar ─── */
.abar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.abar-left, .abar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.abar-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color 140ms;
}

.abar-select:hover, .abar-select:focus { border-color: var(--accent); outline: none; }

.abar-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  width: 140px;
  transition: border-color 140ms;
}

.abar-input:focus { border-color: var(--accent); outline: none; }

.abar-sep { font-size: 12px; color: var(--muted); }

.custom-dates { display: flex; align-items: center; gap: 6px; }

.abar-refresh {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: color 140ms, border-color 140ms;
}

.abar-refresh:hover { color: var(--accent); border-color: var(--accent); }
.abar-refresh.spinning svg { animation: spin 0.7s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Store filter dropdown ─── */
.store-filter { position: relative; }

.store-filter-toggle {
  height: 32px;
  padding: 0 12px;
  white-space: nowrap;
}

.store-filter-drop {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  min-width: 160px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}

.store-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: background 100ms;
}

.store-check-row:hover { background: var(--raised); }
.store-check-row:first-child { border-bottom: 1px solid var(--border); margin-bottom: 4px; padding-bottom: 8px; }

/* ─── Analytics status banner ─── */
.analytics-status {
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 12px;
  color: var(--amber);
  margin-bottom: 20px;
}

.analytics-status.error {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

/* ─── Metric cards ─── */
.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.metric-row-sm .metric-value { font-size: 22px; }

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 160ms;
}

.metric-card:hover { border-color: var(--faint); }

.metric-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.metric-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.metric-label-row .metric-label { margin-bottom: 0; }

.metric-value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 8px;
  font-family: ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
}

.metric-delta {
  font-size: 11px;
  line-height: 1.4;
  min-height: 16px;
}

.enter-spend-btn {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 8px;
  transition: opacity 140ms;
  flex-shrink: 0;
}

.enter-spend-btn:hover { opacity: .8; }

/* ─── Revenue chart ─── */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chart-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
}

.leg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chart-body {
  padding: 12px 8px 8px;
  min-height: 160px;
  position: relative;
}

.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  color: var(--muted);
  font-size: 13px;
}

/* ─── Products row ─── */
.products-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.prod-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.prod-card .section-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.prod-card .table-wrap {
  border: none;
  border-radius: 0;
}

/* ─── Platform bars (ad spend) ─── */
.platform-bars {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pbar-row {
  display: grid;
  grid-template-columns: 90px 1fr 80px;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.pbar-row:last-child { border-bottom: none; }

.pbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.pbar-track {
  height: 6px;
  background: var(--raised);
  border-radius: 3px;
  overflow: hidden;
}

.pbar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 400ms cubic-bezier(.25,.8,.25,1);
}

.pbar-fill.meta   { background: #1877F2; }
.pbar-fill.google { background: #EA4335; }
.pbar-fill.tiktok { background: #010101; }
.pbar-fill.other  { background: var(--amber); }

.pbar-value {
  font-size: 13px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--text);
  text-align: right;
}

/* ─── Pending strip ─── */
.pending-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 12px;
  color: var(--amber);
  margin-bottom: 20px;
}

.pending-strip-detail {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--amber);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
}

/* ─── Spend modal extras ─── */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.spend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── COGS field rows ─── */
.cogs-field-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.cogs-field-row:last-child { border-bottom: none; }

.cogs-store-label {
  font-size: 13px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: var(--text);
}

.cogs-last-edited {
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.cogs-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cogs-input {
  width: 70px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 5px 8px;
  text-align: right;
  transition: border-color 140ms;
}

.cogs-input:focus { border-color: var(--accent); outline: none; }

/* ─── Responsive analytics ─── */
@media (max-width: 900px) {
  .metric-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .metric-row { grid-template-columns: 1fr 1fr; }
  .products-row { grid-template-columns: 1fr; }
  .pbar-row { grid-template-columns: 70px 1fr 60px; }
  .spend-grid { grid-template-columns: 1fr; }
  .field-row  { grid-template-columns: 1fr; }
}
