/*
 * Stokio's own look for the page outside Shopify (D-108) and the sign-in page: the colours and type of stokio.io
 * (stokio-site/src/styles/tokens.css), with a dark variant of the same ink and violet. Polaris may not be used outside
 * the Shopify admin, so standalone.js defines the s-* elements and this file styles them; it must not look like the admin.
 * The site self-hosts Inter through its bundler; this app has no copy, so the site's font stack is used as it is.
 */
:root {
  color-scheme: light dark;
  --page: #f3f2ff;
  --surface: #ffffff;
  --ink: #1f2240;
  --muted: #5d6185;
  --line: #e4e4f2;
  --line-strong: #c9cbe6;
  --accent: #5b45f0;
  --accent-hover: #4a35dc;
  --accent-ink: #ffffff;
  --accent-soft: #ebe8ff;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #8f4207;
  --warn-soft: #fff0dc;
  --bad: #b3261e;
  --bad-soft: #fde8e6;
  --bad-ink: #ffffff;
  --info: #2150a8;
  --info-soft: #e6eefc;
  --neutral: #4a4670;
  --neutral-soft: #eceaf6;
  --bar: rgba(255, 255, 255, 0.92);
  --shadow: 0 1px 2px rgba(31, 34, 64, 0.05), 0 8px 24px rgba(31, 34, 64, 0.05);
  --radius: 16px;
  --wrap: 1080px;
  --sans: 'Inter Variable', system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', 'Noto Sans KR', 'Noto Sans SC', 'Noto Sans TC', sans-serif;
  /* the page's own styles use these Polaris token names with fallbacks */
  --p-color-bg-surface-secondary: var(--surface);
  --p-color-text-secondary: var(--muted);
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #14162b;
    --surface: #1d2040;
    --ink: #ecebff;
    --muted: #a7abd3;
    --line: #31355c;
    --line-strong: #4a4f80;
    --accent: #9b8cff;
    --accent-hover: #b3a8ff;
    --accent-ink: #14162b;
    --accent-soft: #2c2a5c;
    --ok: #6fd6a2;
    --ok-soft: #17352a;
    --warn: #f6b26b;
    --warn-soft: #3b2a17;
    --bad: #ff9b91;
    --bad-soft: #42202a;
    --bad-ink: #14162b;
    --info: #9cbcff;
    --info-soft: #1d2c4d;
    --neutral: #c9c6ea;
    --neutral-soft: #2b2d50;
    --bar: rgba(20, 22, 43, 0.92);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 1rem/1.55 var(--sans); color: var(--ink); background: var(--page); overflow-wrap: break-word; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  max-width: 100%; padding: 8px 10px; font-size: 0.95rem; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
}
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; }

/* --- the top bar (s-app-nav) --- */
s-app-nav {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px;
  min-height: 64px; padding: 10px max(16px, calc((100% - var(--wrap)) / 2 + 20px));
  background: var(--bar); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.st-brand { display: inline-flex; align-items: center; gap: 8px; margin-right: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.35rem; letter-spacing: -0.03em; }
.st-mark { flex: none; }
s-app-nav s-link a { color: var(--muted); font-size: 0.95rem; font-weight: 500; text-decoration: none; padding-block: 4px; border-bottom: 2px solid transparent; }
s-app-nav s-link a:hover { color: var(--ink); }
s-app-nav s-link a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.st-signout { margin: 0 0 0 auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.st-account { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-account:empty { display: none; }
.st-signout button { flex: none; padding: 6px 2px; background: none; border: 0; color: var(--muted); font-size: 0.95rem; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.st-signout button:hover { color: var(--ink); }

/* --- the page (s-page): heading with the primary action beside it, then the content --- */
s-page { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; max-width: var(--wrap); margin: 0 auto; padding: 28px 20px 72px; }
s-page > * { grid-column: 1 / -1; min-width: 0; }
s-page > .st-page-title { grid-column: 1; grid-row: 1; margin: 0; font-size: 1.85rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.025em; text-wrap: balance; }
s-page > [slot="primary-action"] { grid-column: 2; grid-row: 1; }

/* --- blocks and text --- */
s-section { display: grid; gap: 12px; align-content: start; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
s-heading { display: block; font-size: 1.1rem; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; }
s-text { display: inline; }
s-text[tone="subdued"] { color: var(--muted); }
s-text[tone="critical"] { color: var(--bad); }
s-stack { display: flex; flex-direction: column; gap: 12px; }
s-stack[direction="inline"] { flex-direction: row; flex-wrap: wrap; align-items: center; }
s-stack[gap="small-200"] { gap: 4px 6px; }
s-stack[gap="small"] { gap: 8px; }
s-stack[gap="large"] { gap: 16px 28px; }
:is(s-page, s-section, s-heading, s-text, s-button, s-link, s-banner, s-badge, s-stack, s-table, s-table-row, s-table-cell)[hidden] { display: none; }

/* --- badges: the pills of the site's app preview --- */
s-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; line-height: 1.6; font-weight: 700; white-space: nowrap; color: var(--neutral); background: var(--neutral-soft); }
s-badge[tone="critical"] { color: var(--bad); background: var(--bad-soft); }
s-badge[tone="warning"] { color: var(--warn); background: var(--warn-soft); }
s-badge[tone="info"] { color: var(--info); background: var(--info-soft); }
s-badge[tone="success"] { color: var(--ok); background: var(--ok-soft); }

/* --- buttons: the site's pill buttons, smaller --- */
s-button {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; max-width: 100%;
  min-height: 38px; padding: 7px 16px; border: 1.5px solid var(--accent); border-radius: 999px;
  color: var(--accent); background: transparent; font-size: 0.9rem; font-weight: 600; line-height: 1.25; text-align: center;
  cursor: pointer; user-select: none; transition: background-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
s-button:hover { background: var(--accent-soft); }
s-button[variant="primary"] { color: var(--accent-ink); background: var(--accent); }
s-button[variant="primary"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 6px 16px rgba(91, 69, 240, 0.25); transform: translateY(-1px); }
/* the destructive action (Polaris' tone="critical"): red, never the violet of the primary button */
s-button[tone="critical"] { color: var(--bad); border-color: var(--bad); }
s-button[tone="critical"]:hover { background: var(--bad-soft); }
s-button[tone="critical"][variant="primary"] { color: var(--bad-ink); background: var(--bad); }
s-button[tone="critical"][variant="primary"]:hover { background: var(--bad); border-color: var(--bad); box-shadow: 0 6px 16px rgba(179, 38, 30, 0.25); filter: brightness(0.92); }
s-button[tone="critical"][variant="primary"]:is([disabled], [loading]):hover { background: var(--bad); border-color: var(--bad); filter: none; }
s-button[tone="critical"]:focus-visible { outline-color: var(--bad); }
s-button[variant="tertiary"] { border-color: transparent; padding-inline: 8px; text-decoration: underline; text-underline-offset: 3px; }
s-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 999px; }
s-button:is([disabled], [loading]) { cursor: not-allowed; opacity: 0.5; box-shadow: none; transform: none; }
s-button:is([disabled], [loading]):hover { background: transparent; }
s-button[variant="primary"]:is([disabled], [loading]):hover { background: var(--accent); border-color: var(--accent); }
s-button[loading] { color: transparent; }
s-button[loading]::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--accent); border-right-color: transparent; animation: st-spin 0.8s linear infinite;
}
s-button[variant="primary"][loading]::after { border-color: var(--accent-ink); border-right-color: transparent; }
@keyframes st-spin { to { transform: rotate(360deg); } }

/* --- banners --- */
s-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 14px 18px; border-radius: 12px; border-left: 4px solid var(--info); background: var(--info-soft); color: var(--ink);
}
s-banner[tone="info"] { border-left-color: var(--accent); background: var(--accent-soft); }
s-banner[tone="warning"] { border-left-color: var(--warn); background: var(--warn-soft); }
s-banner[tone="critical"] { border-left-color: var(--bad); background: var(--bad-soft); }

/* --- the table --- */
s-table { display: table; width: 100%; border-collapse: collapse; font-size: 0.92rem; }
s-table-header-row, s-table-row { display: table-row; }
s-table-body { display: table-row-group; }
s-table-header {
  display: table-cell; padding: 8px 12px 8px 0; text-align: start; vertical-align: bottom; border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
s-table-cell { display: table-cell; padding: 12px 12px 12px 0; vertical-align: top; border-bottom: 1px solid var(--line); }
s-table-row:last-child s-table-cell { border-bottom: 0; }
s-table-header[format="numeric"], s-table-cell[data-format="numeric"] { text-align: end; font-variant-numeric: tabular-nums; }
s-table-cell:first-child { font-weight: 600; }
/* phone width: each row becomes a card, each cell carries its column's name */
@media (max-width: 760px) {
  s-table, s-table-body, s-table-row, s-table-cell { display: block; }
  s-table-header-row { display: none; }
  s-table-row { display: grid; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  s-table-row:last-child { border-bottom: 0; }
  s-table-cell { padding: 0; border: 0; }
  s-table-cell[data-format="numeric"] { text-align: start; }
  s-table-cell:first-child { font-size: 1rem; }
  s-table-cell:empty { display: none; } /* an empty cell would print its column's name over nothing */
  s-table-cell:not(:first-child):not(:empty)::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
}

/* --- toast (App Bridge's shopify.toast) --- */
.st-toast-region { position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); }
.st-toast {
  padding: 12px 20px; border-radius: 14px; background: var(--ink); color: var(--page); font-size: 0.95rem; font-weight: 500;
  box-shadow: 0 12px 30px rgba(31, 34, 64, 0.25);
}
.st-toast-error { background: #b3261e; color: #ffffff; }

/* --- the page's own blocks, in Stokio colours (its inline styles are written for the Shopify admin) --- */
html .sup-card { border-color: var(--line); border-radius: 14px; }
html .sup-card.sup-focus { outline-color: var(--accent); }
html .money-tile { border-color: var(--line); border-radius: 12px; }
html .money-tile.risk { border-top-color: var(--bad); }
html .money-tile.excess { border-top-color: var(--warn); }
html .money-tile.dead { border-top-color: var(--line-strong); }
html .ord-hint { color: var(--muted); }
html .ord-warn { background: var(--warn-soft); color: var(--ink); }
html #progress { border: 1px solid var(--line); }
#counters s-heading, .money-tile s-heading { font-size: 1.6rem; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
/* wide tables of inputs scroll inside their card, never the page */
@media (max-width: 760px) { html .sup-skus { display: block; overflow-x: auto; } }

/* --- the sign-in page (login.html): one card with the logo --- */
body > main {
  max-width: 440px; margin: 56px auto; padding: 32px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
body > main::before {
  content: "stokio"; display: block; min-height: 26px; margin-bottom: 28px; padding-left: 34px; line-height: 26px;
  font-weight: 700; font-size: 1.35rem; letter-spacing: -0.03em;
  background: no-repeat left center / 26px 26px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='170 160 860 880'%3E%3Cg transform='translate(11 53)'%3E%3Crect x='190' y='560' width='400' height='400' rx='36' fill='%235b45f0'/%3E%3Crect x='630' y='602' width='358' height='358' rx='34' fill='%2347c1bf'/%3E%3Crect x='432' y='171' width='400' height='400' rx='34' fill='%23f49342' transform='rotate(12 632 371)'/%3E%3C/g%3E%3C/svg%3E");
}
body > main h1 { margin: 0 0 8px; font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.02em; }
body > main p { margin: 0 0 20px; color: var(--muted); }
body > main label { display: block; margin-bottom: 6px; font-weight: 600; }
body > main input { width: 100%; }
body > main button {
  margin-top: 16px; padding: 12px 24px; border: 2px solid var(--accent); border-radius: 999px; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer;
}
body > main button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
body > main button:disabled { opacity: 0.6; cursor: default; }
body > main #message { margin: 18px 0 0; color: var(--ink); }
body > main #message.error { color: var(--bad); }

@media (max-width: 480px) {
  s-page { padding: 20px 16px 56px; gap: 14px; }
  s-page > .st-page-title { font-size: 1.45rem; }
  s-section { padding: 16px; }
  .st-brand { font-size: 1.2rem; }
  body > main { margin: 16px; padding: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  s-button { transition: none; }
  s-button[variant="primary"]:hover { transform: none; }
  s-button[loading]::after { animation-duration: 2s; }
}
