:root {
    --bg: #f5f6f8; --card: #ffffff; --text: #1b1f24; --muted: #667080; --line: #e3e6ea;
    --brand: #0f6fde; --brand-ink: #ffffff; --brand-soft: #e7f0fc;
    --ok: #1b8a4b; --ok-soft: #e5f5ec; --err: #c62828; --err-soft: #fdecec; --warn: #a86400; --warn-soft: #fff4e0;
    --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111418; --card: #1a1e24; --text: #e8eaed; --muted: #9aa3ad; --line: #2c323a;
        --brand: #4c9bff; --brand-ink: #0b1220; --brand-soft: #18273b;
        --ok: #4cc27f; --ok-soft: #15291e; --err: #ff6b6b; --err-soft: #331a1a; --warn: #f0b04a; --warn-soft: #33270f;
        --shadow: none;
    }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .4rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .6rem; }
h2:first-child { margin-top: 0; }
code { background: var(--brand-soft); padding: 1px 6px; border-radius: 6px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand b { color: var(--brand); }
.nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.nav a { color: var(--text); }
.nav a.muted { color: var(--muted); }
.nav a.btn { color: var(--brand-ink); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 18px 16px 40px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px 16px 30px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.narrow { max-width: 460px; margin: 20px auto; }
.empty { text-align: center; color: var(--muted); padding: 30px 18px; }

.btn { display: inline-block; background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 9px; padding: 9px 16px;
    font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: .86rem; }
.btn-lg { padding: 12px 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn-danger { background: var(--err); color: #fff; }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; padding: 0 4px; }

.form label { display: block; margin-bottom: 12px; font-weight: 500; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
    border-radius: 8px; padding: 9px 11px; margin-top: 4px; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
input.invalid { border-color: var(--err); background: var(--err-soft); }
.form label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.form label.check input { width: auto; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid2.top { align-items: start; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { margin: 0; }

.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.note { background: var(--warn-soft); padding: 6px 10px; border-radius: 8px; margin: 8px 0; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--line); color: var(--text); white-space: nowrap; }
.st-new { background: var(--brand-soft); color: var(--brand); }
.st-received, .st-printing { background: var(--warn-soft); color: var(--warn); }
.st-printed, .fs-printed { background: var(--ok-soft); color: var(--ok); }
.st-failed, .st-rejected, .fs-failed { background: var(--err-soft); color: var(--err); }

.app-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 99px; font-size: .85rem; background: var(--line); }
.app-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.app-pill.on { background: var(--ok-soft); color: var(--ok); }
.app-pill.on .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(27,138,75,.2); }
.app-pill.off { color: var(--muted); }

/* home */
.hero { text-align: center; padding: 30px 0 20px; }
.hero h1 { font-size: 2.1rem; }
.accent { color: var(--brand); }
.lead { max-width: 640px; margin: 10px auto 20px; color: var(--muted); font-size: 1.05rem; }
.hero-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 24px 0; }
.step h3 { margin: 6px 0; }
.step p { margin: 0; color: var(--muted); font-size: .92rem; }
.step-n { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.find { max-width: 560px; margin: 0 auto; }

/* dashboard */
.dash-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { text-align: center; padding: 14px; }
.stat-v { font-size: 1.7rem; font-weight: 700; }
.stat-l { color: var(--muted); font-size: .85rem; }
.toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; margin: 6px 0 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border-radius: 8px; color: var(--text); }
.tab.active { background: var(--brand); color: var(--brand-ink); }
.tab:hover { text-decoration: none; }
.search input { min-width: 220px; }
.order { display: flex; gap: 14px; align-items: flex-start; color: var(--text); padding: 14px; }
.order:hover { text-decoration: none; border-color: var(--brand); }
.order-token { font-size: 1.4rem; font-weight: 700; color: var(--brand); min-width: 54px; }
.order-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.order-side { text-align: right; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table td { overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.pager { list-style: none; display: flex; gap: 4px; padding: 0; }
.pager li a, .pager li span { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); display: inline-block; }
.pager li.active a { background: var(--brand); color: var(--brand-ink); }

/* customer page */
.shop-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rates { margin-top: 6px; }
.recent { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.drop { position: relative; border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px 14px; text-align: center; cursor: pointer; margin-bottom: 14px; }
.drop.over, .drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.drop-icon { font-size: 2rem; }
.file-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.fcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); }
.fcard-top { display: flex; justify-content: space-between; gap: 8px; }
.fname { font-weight: 600; overflow-wrap: anywhere; }
.fopts { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px; align-items: flex-end; }
.fopts .opt { margin: 0; font-size: .85rem; font-weight: 500; }
.fopts .opt input, .fopts .opt select { width: auto; max-width: 140px; padding: 6px 8px; }
.fopts .o-range { width: 130px; }
.stepper { display: inline-flex; align-items: center; margin-top: 4px; }
.stepper button { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 1.1rem; cursor: pointer; }
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper input { width: 52px !important; margin: 0; border-radius: 0; text-align: center; height: 34px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--card); color: var(--text); padding: 7px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.progress { position: relative; height: 26px; background: var(--line); border-radius: 8px; overflow: hidden; margin-top: 12px; }
.progress .bar { height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.progress .ptext { position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; font-weight: 600; }

.track { text-align: center; max-width: 620px; margin: 10px auto; }
.token { font-size: 2.6rem; margin: 6px 0; }
.token b { color: var(--brand); }
.track-status { margin: 10px 0 4px; font-size: 1.2rem; }
.track-status .badge { font-size: 1rem; padding: 5px 16px; }
.timeline { list-style: none; padding: 0; display: flex; justify-content: space-between; margin: 20px 0; counter-reset: s; }
.timeline li { flex: 1; position: relative; color: var(--muted); font-size: .82rem; padding-top: 30px; }
.timeline li::before { counter-increment: s; content: counter(s); position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 24px; height: 24px; border-radius: 50%; background: var(--line); color: var(--muted); display: grid; place-items: center; font-weight: 700; }
.timeline li.done { color: var(--ok); }
.timeline li.done::before { background: var(--ok); color: #fff; content: "✓"; }
.track .table td { text-align: left; }

@media (max-width: 760px) {
    .steps { grid-template-columns: 1fr 1fr; }
    .grid2, .grid2.top { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.6rem; }
    .order { flex-wrap: wrap; }
    .order-side { width: 100%; flex-direction: row; justify-content: space-between; align-items: center; text-align: left; }
    .search input { min-width: 0; }
    .search, .toolbar form { width: 100%; }
    .table thead { display: none; }
    .table td { display: block; border: 0; padding: 3px 0; }
    .table tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
}
@media (max-width: 420px) { .steps { grid-template-columns: 1fr; } .stats { gap: 6px; } }
