/* Shopify Store Manager — one stylesheet for every page. Light and dark follow the system. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1b1f24;
  --muted: #5d6673;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #e1f3f1;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --ok: #1a7f37;
  --ok-soft: #e3f4e8;
  --focus: #2563eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232b;
    --border: #2c333d;
    --text: #e7eaee;
    --muted: #9aa4b1;
    --accent: #2dd4bf;
    --accent-text: #04201d;
    --accent-soft: #123532;
    --danger: #ff7b72;
    --danger-soft: #3a1d1b;
    --warn: #e3b341;
    --warn-soft: #362b10;
    --ok: #56d364;
    --ok-soft: #12301a;
    --focus: #79a8ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- buttons and forms ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.field { display: grid; gap: 4px; margin-bottom: 14px; }
.field > label, .label { font-weight: 600; font-size: .9rem; }
.field .help { color: var(--muted); font-size: .83rem; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
input.code { font-family: var(--mono); font-size: 1.35rem; letter-spacing: .3em; text-align: center; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }

.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; border: 1px solid transparent; }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--accent-soft); color: var(--text); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---- cards, tables ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .85rem; font-weight: 500; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }

/* ---- sign-in pages ---- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 410px; }
.auth-box .card { padding: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 18px; justify-content: center; }
.brand img { width: 34px; height: 34px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; margin: 16px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.captcha { min-height: 65px; margin-bottom: 14px; display: flex; justify-content: center; }
.qr { background: #fff; border-radius: 8px; padding: 8px; width: 200px; margin: 8px auto 12px; }
.qr svg { display: block; width: 100%; height: auto; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-family: var(--mono); background: var(--surface-2); padding: 14px; border-radius: 8px; margin-bottom: 12px; }
.secret { font-family: var(--mono); word-break: break-all; background: var(--surface-2); padding: 6px 10px; border-radius: 6px; text-align: center; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 14px; }

/* ---- app layout ---- */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.sidebar .brand { justify-content: flex-start; padding: 4px 8px 14px; margin: 0; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .me { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 8px 0; font-size: .88rem; }
.sidebar .me .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 24px 28px 48px; min-width: 0; max-width: 1180px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.topbar { display: none; }
.beta-banner { background: var(--warn-soft); color: var(--warn); padding: 8px 28px; font-size: .9rem; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.beta-banner .btn { min-height: 28px; }
.app-wrap { display: flex; flex-direction: column; min-height: 100vh; }

/* settings: side tabs */
.split { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
.subnav { display: grid; gap: 2px; position: sticky; top: 16px; }
.subnav a { padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.subnav a.active { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.map-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 8px; }
.source { font-size: .78rem; color: var(--muted); }

/* dialogs and toasts */
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 14, 20, .5); }
dialog h2 { margin-top: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger); color: #fff; }
.copy-box { display: flex; gap: 8px; }
.copy-box input { font-family: var(--mono); font-size: .85rem; }

.changelog h3 { margin-bottom: .2em; }
.changelog ul { margin: .3em 0 1em; padding-left: 1.2em; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .main { padding: 16px 16px 40px; }
  .split { grid-template-columns: 1fr; }
  .subnav { position: static; display: flex; overflow-x: auto; }
  .beta-banner { padding: 8px 16px; }
  .map-row { grid-template-columns: 1fr; }
}

/* utilities (no inline styles: the Content-Security-Policy blocks them) */
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.end { justify-content: flex-end; }
.grow { flex: 1; }
.center { text-align: center; }
.btn-row > input, .btn-row > select { width: auto; }
.btn-row > .grow { flex: 1 1 220px; min-width: 0; }
dialog input { background: var(--surface-2); }
