/*
 * Shared styles for the sample apps on sg.anyori.com (copied into each app as public/base.css).
 * Design tokens, the page frame (header, main, footer) and a few components: cards, KPI tiles,
 * tables, badges, buttons, forms, progress bars, steps and timelines. App-specific rules go in
 * the app's own public/app.css. Light and dark follow the system setting. No external resources.
 */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1a2332;
  --muted: #5f6b7a;
  --border: #e2e7ed;
  --accent: #1463d6;
  --on-accent: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #dc2626;
  --info: #0e7490;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #171d26;
    --text: #e7ecf2;
    --muted: #9aa6b5;
    --border: #2a3441;
    --accent: #5b9dff;
    --on-accent: #0b1220;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --info: #22d3ee;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--accent); }
h1 { font-size: 24px; line-height: 1.25; margin: 0; }
h2 { font-size: 18px; margin: 24px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
p { margin: 0 0 12px; }

/* ── frame ── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.site-header .bar { max-width: 1120px; margin: 0 auto; padding: 8px 16px; min-height: 56px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 650; font-size: 17px; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); }
.nav a[aria-current] { color: var(--text); background: var(--bg); }
.spacer { flex: 1; }
.lang { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang a { padding: 4px 10px; font-size: 13px; color: var(--muted); text-decoration: none; }
.lang a[aria-current] { background: var(--accent); color: var(--on-accent); }
.all-samples { font-size: 13px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.all-samples:hover { color: var(--text); }
main.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; padding: 16px; text-align: center; }

/* ── layout helpers ── */
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.right { text-align: right; }

/* ── components ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.kpi .value { font-size: 28px; font-weight: 650; line-height: 1.1; }
.kpi .label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.kpi .delta { font-size: 13px; margin-top: 4px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--bg); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5; background: var(--bg); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.badge.info { color: var(--info); background: color-mix(in srgb, var(--info) 10%, var(--surface)); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.badge.accent { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; line-height: 1.4; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--border)); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.5; cursor: default; }

.form { display: grid; gap: 14px; max-width: 640px; }
.field { display: grid; gap: 4px; }
.field label { font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; border-color: var(--accent); }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input { width: 5.5em; }

.notice { padding: 10px 14px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); margin: 0 0 16px; }
.notice.bad { background: color-mix(in srgb, var(--bad) 8%, var(--surface)); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.notice.ok { background: color-mix(in srgb, var(--ok) 8%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }

.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.6s ease; }
.progress.ok > span { background: var(--ok); }
.progress.warn > span { background: var(--warn); }

/* order status steps: <ol class="steps"><li data-done="true" data-current="true">…</li></ol> */
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 20px; }
.steps li { flex: 1; font-size: 13px; color: var(--muted); padding-top: 8px; border-top: 4px solid var(--border); }
.steps li[data-done="true"] { color: var(--text); border-top-color: var(--ok); }
.steps li[data-current="true"] { border-top-color: var(--accent); font-weight: 600; }
.steps li[data-cancelled="true"] { border-top-color: var(--bad); color: var(--bad); }

/* event history: <ul class="timeline"><li class="done">…</li></ul> */
.timeline { list-style: none; padding: 0; margin: 0 0 0 8px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 16px 20px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); box-sizing: border-box; }
.timeline li.done::before { background: var(--accent); border-color: var(--accent); }
.timeline li:last-child { padding-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 13px; }

@media (max-width: 640px) {
  main.container { padding: 16px 12px 40px; }
  .site-header .bar { gap: 10px; }
  .table th, .table td { padding: 8px 10px; }
  .kpi .value { font-size: 24px; }
}
