/* SHN Platform design system — current Shopify Polaris (2026) tokens.
   Values sourced from polaris-react.shopify.com/tokens/color.
   Shared tokens + components for the admin app; the public site mirrors these. */
:root {
  --shn-brand: #303030;         /* primary action / brand fill (color-bg-fill-brand) */
  --shn-brand-hover: #1a1a1a;   /* color-bg-fill-brand-hover/active */
  --ink: #303030;               /* color-text */
  --ink-subdued: #616161;       /* color-text-secondary */
  --interactive: #005bd3;       /* color-text-link / focus */
  --bg: #f1f1f1;                /* color-bg (page) */
  --surface: #ffffff;           /* color-bg-surface (card) */
  --border: #e3e3e3;            /* color-border */
  --border-secondary: #ebebeb;  /* color-border-secondary */
  --critical: #c70a24;          /* color-bg-fill-critical */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.08);
  --shadow-card: 0 0 0 1px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--interactive); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.muted { color: var(--ink-subdued); font-size: 13px; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.container { max-width: 1040px; margin: 0 auto; padding: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.btn-primary { background: var(--shn-brand); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--shn-brand-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); box-shadow: var(--shadow); }
.btn-secondary:hover { background: #fafafa; text-decoration: none; }

/* Forms (also styles allauth's default markup) */
label { display: block; font-weight: 500; margin: 0 0 4px; }
input[type=text], input[type=email], input[type=password], input:not([type]) {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
}
input:focus { outline: none; border-color: var(--interactive); box-shadow: 0 0 0 2px rgba(0,91,211,.25); }
button[type=submit], input[type=submit] {
  background: var(--shn-brand); color: #fff; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 10px 16px; font-family: inherit;
  font-size: 14px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow);
}
button[type=submit]:hover, input[type=submit]:hover { background: var(--shn-brand-hover); }
.form-row { margin-bottom: 14px; }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }

/* ============================================================
   App shell — authenticated area (left sidebar, Shopify-admin style)
   ============================================================ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); padding: 14px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { font-weight: 600; font-size: 16px; letter-spacing: -.01em; padding: 6px 10px 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink); font-weight: 500; font-size: 14px;
}
.nav-item:hover { background: #f6f6f6; text-decoration: none; }
.nav-item.is-active { background: #f1f1f1; color: var(--ink); }
.nav-item.is-active .nav-icon { color: var(--interactive); }
.nav-item.is-disabled { color: #9c9c9c; cursor: default; }
.nav-item.is-disabled:hover { background: transparent; }
.nav-item em { margin-left: auto; font-style: normal; font-size: 10px; text-transform: uppercase;
  letter-spacing: .04em; color: #9c9c9c; border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }
.nav-icon { flex-shrink: 0; color: var(--ink-subdued); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.app-topbar-title { font-weight: 600; font-size: 15px; }
.app-content { padding: 24px 28px; max-width: 1180px; width: 100%; }

/* Analytics header: tabs + range picker */
.an-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.an-sub { margin: 6px 0 20px; }
.tabs { display: flex; gap: 4px; background: #eaeaea; padding: 3px; border-radius: var(--radius-sm); }
.tab { padding: 6px 14px; border-radius: 6px; font-weight: 500; font-size: 13px; color: var(--ink-subdued); }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.an-range select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding: 8px 34px 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23616161' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}

/* Analytics section sub-nav */
.an-secnav { display: flex; gap: 20px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.secnav-item { padding: 8px 2px 12px; font-size: 14px; font-weight: 500; color: var(--ink-subdued);
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.secnav-item:hover { text-decoration: none; color: var(--ink); }
.secnav-item.is-active { color: var(--ink); border-bottom-color: var(--interactive); }

/* Flash messages */
.msgs { list-style: none; margin: 0 0 16px; padding: 0; }
.msg { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 8px; }
.msg.success { background: #e3f3ea; color: #0a6b3b; }
.msg.error { background: #fde7ea; color: var(--critical); }

/* Settings tab */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 16px; }
.settings-card h2 { margin-bottom: 14px; }
.settings-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; margin-bottom: 16px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }

/* Per-order simulation panel */
.sim { background: var(--surface-subdued, #f7f7f7); border: 1px solid var(--border-secondary);
  border-radius: var(--radius-sm); padding: 14px 16px; align-self: start; }
.sim h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-subdued);
  margin: 0 0 10px; }
.sim-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 4px 0; white-space: nowrap; }
.sim-row span { color: var(--ink-subdued); }
.sim-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.sim-row b i { font-style: normal; font-weight: 400; font-size: 10px; color: var(--ink-subdued); margin-left: 2px; }
.sim-row.hl { border-top: 1px solid var(--border-secondary); border-bottom: 1px solid var(--border-secondary);
  margin: 4px 0; padding: 7px 0; }
.sim-row.hl b { font-size: 13px; }

@media (max-width: 620px) { .settings-body { grid-template-columns: 1fr; } }
.field { font-weight: 500; }
.field > span { display: block; font-size: 12px; color: var(--ink-subdued); margin-bottom: 4px; }
.field .hint { display: block; font-weight: 400; font-size: 11px; color: var(--ink-subdued); margin-top: 3px; font-style: normal; }
.field .err { display: block; font-weight: 500; font-size: 11px; color: var(--critical); margin-top: 3px; font-style: normal; }
.inp { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; }
.inp:focus { outline: none; border-color: var(--interactive); box-shadow: 0 0 0 2px rgba(0,91,211,.25); }
.inp-sm { max-width: 90px; }

/* Goals grid */
.goals-tbl .inp { text-align: right; }
.goals-tbl td.num { padding: 6px 8px; }
.goals-tbl th, .goals-tbl td:first-child { white-space: nowrap; }
.goals-tbl .js-adspend { max-width: 150px; display: inline-block; margin-left: auto; }
.goals-tbl .roas-cell { white-space: nowrap; color: var(--ink-subdued); }
.goals-tbl .js-roas { max-width: 80px; display: inline-block; }
.goals-tbl .goal-ns { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* KPI cards (overview) */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 18px; color: var(--ink); display: block;
  transition: box-shadow .15s, border-color .15s;
}
.kpi-card:hover { text-decoration: none; border-color: #d0d0d0; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.kpi-card-head { display: flex; align-items: center; justify-content: space-between; }
.kpi-seg { font-weight: 600; font-size: 14px; }
.kpi-hero { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin-top: 10px; }
.kpi-hero .cur { font-size: 14px; font-weight: 500; color: var(--ink-subdued); }
.kpi-hero-label { font-size: 12px; color: var(--ink-subdued); text-transform: uppercase; letter-spacing: .04em; }
.kpi-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin-top: 14px;
  border-top: 1px solid var(--border-secondary); padding-top: 12px; }
.kpi-mini > div { display: flex; justify-content: space-between; font-size: 13px; }
.kpi-mini span { color: var(--ink-subdued); }
.kpi-mini b { font-weight: 600; }

/* Comparison indicator — Shopify admin style: a small coloured triangle + a
   plain percentage. No background pill, no italics. The triangle carries the
   direction, so the number is the absolute value. */
.cmp { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; line-height: 1.2; }
.cmp::before { font-size: 8px; line-height: 1; }
.cmp.up { color: #047b5d; }
.cmp.up::before { content: "\25B2"; }      /* ▲ */
.cmp.down { color: #e22c38; }
.cmp.down::before { content: "\25BC"; }     /* ▼ */
.cmp.flat { color: var(--ink-subdued); }
.cmp.flat::before { content: "\2013"; }     /* – */
.cmp-lbl { color: var(--ink-subdued); font-weight: 400; margin-left: 1px; }

/* Comparison rows */
.kpi-cmprow { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; min-height: 16px; }
.stat-cmp { margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.stat-cmp.muted { font-size: 12px; color: var(--ink-subdued); }

/* Contribution margin block on the overview card. */
.kpi-cm { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-secondary); }
.kpi-cm span { color: var(--ink-subdued); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi-cm b { font-size: 18px; font-weight: 600; }

/* Target-CAC annotation. */
.kpi-mini .tgt { color: var(--ink-subdued); font-weight: 500; font-style: normal; margin-left: 3px; }

/* Sparkline */
.spark-wrap { position: relative; margin: 14px 0 2px; }
.spark { width: 100%; height: 42px; display: block; }
.spark-line { fill: none; stroke: var(--interactive); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark-area { fill: rgba(0,91,211,.08); stroke: none; }
.spark-dot { position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: var(--interactive); transform: translate(-50%, -50%); }

/* Country flag on KPI cards */
.flag { font-size: 18px; line-height: 1; }

/* Analytics head controls (range + refresh) */
.an-controls { display: flex; align-items: flex-start; gap: 8px; }
.an-refresh { margin: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.an-refresh .btn { padding: 8px 14px; font-size: 13px; }
.refresh-time { font-size: 11px; color: var(--ink-subdued); }
.msg.refreshing { background: #eef4ff; color: #1f4fbf; display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 14px 0; padding: 12px 16px; }

/* ROAS slider (goals) */
.roas-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.js-roas { flex: 1; accent-color: #005bd3; cursor: pointer; }
.roas-val { min-width: 34px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Daily table (segment detail) — compact, profitsheet-like */
.tbl-scroll { max-height: 640px; overflow-y: auto; }
.daily-legend { margin: 0 0 12px; font-size: 12px; }
.daily-tbl { font-size: 13px; }
.daily-tbl thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.daily-tbl td, .daily-tbl th { padding: 6px 10px; }
.daily-tbl .key { font-weight: 600; }
.daily-tbl th i { font-style: normal; font-weight: 400; color: var(--ink-subdued); font-size: 11px; }
.daily-tbl .dev { font-style: normal; font-weight: 500; font-size: 11px; margin-left: 3px; }
.daily-tbl .dev.pos { color: #047b5d; }
.daily-tbl .dev.neg { color: #e22c38; }
.pos { color: #047b5d; }
.neg { color: #e22c38; }
.daily-tbl tfoot td { border-top: 2px solid var(--border); font-weight: 600; background: var(--surface); position: sticky; bottom: 0; }
.nowrap { white-space: nowrap; }

/* Single-segment detail */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 14px 16px; }
.stat span { display: block; font-size: 11px; color: var(--ink-subdued); text-transform: uppercase; letter-spacing: .03em; }
.stat b { display: block; font-size: 17px; font-weight: 600; letter-spacing: -.01em; margin-top: 4px; white-space: nowrap; }

.chart-card { margin-bottom: 16px; }
.chart-card h2 { margin-bottom: 14px; }
.chart { display: flex; gap: 10px; }
.chart-plot { flex: 1; position: relative; }
.chart-plot svg { display: block; height: 240px; width: 100%; }
.chart-line { fill: none; stroke: var(--interactive); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-area { fill: rgba(0,91,211,.07); stroke: none; }
.grid { stroke: var(--border-secondary); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* Chart hover cursor + tooltip */
.chart-cursor { position: absolute; inset: 0; pointer-events: none; }
.chart-vline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); transform: translateX(-0.5px); }
.chart-dot { position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: var(--interactive); border: 2px solid var(--surface);
  transform: translate(-50%, -50%); box-shadow: 0 0 0 1px var(--interactive); }
.chart-tip { position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: #fff; border-radius: 6px; padding: 6px 9px;
  font-size: 12px; line-height: 1.35; white-space: nowrap; box-shadow: var(--shadow); }
.chart-tip b { display: block; font-weight: 600; }
.chart-tip span { color: rgba(255,255,255,.8); }
.chart-yaxis { display: flex; flex-direction: column; justify-content: space-between; width: 46px;
  font-size: 11px; color: var(--ink-subdued); text-align: right; padding: 4px 0; }

/* Table */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; color: var(--ink-subdued); padding: 8px 10px;
  border-bottom: 1px solid var(--border); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border-secondary); }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .sidebar { width: 60px; }
  .sidebar-brand, .nav-item span, .nav-item em { display: none; }
  .nav-item { justify-content: center; }
}
