/* ============================================================
   DESIGN SYSTEM — "Token Counter"
   Subject: a print-shop counter that hands you a paper token.
   The whole UI borrows the vocabulary of a receipt printer —
   perforated edges, a running job number, monospace amounts —
   because that is the one object every shop owner already trusts.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    /* Color */
    --paper:        #FAF8F3;
    --paper-alt:     #F0ECE1;
    --ink:           #201E1B;
    --ink-soft:      #6B6659;
    --indigo:        #33379E;
    --indigo-dark:   #23265F;
    --stamp:         #C1442B;
    --success:       #2E7D46;
    --line:          #DEDACD;

    /* Type */
    --f-display: 'Space Grotesk', sans-serif;
    --f-body:    'Inter', sans-serif;
    --f-mono:    'JetBrains Mono', monospace;

    /* Radius / shadow — deliberately small, this is a paper world, not a glassy app */
    --r-sm: 4px;
    --r-md: 8px;
    --shadow-card: 0 1px 2px rgba(32,30,27,0.06), 0 8px 24px -12px rgba(32,30,27,0.18);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--f-body);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    background-color: var(--paper-alt);
    background-image: radial-gradient(circle, #E3DFCF 1px, transparent 1px);
    background-size: 18px 18px;
    min-height: 100vh;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes printOut {
    0%   { opacity: 0; transform: translateY(-16px) scaleY(0.9); }
    60%  { opacity: 1; }
    100% { opacity: 1; transform: translateY(0) scaleY(1); }
}
@keyframes tapBounce {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(0.97); }
}
@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}

h1, h2, h3, .display {
    font-family: var(--f-display);
    letter-spacing: -0.01em;
    margin: 0;
}

.mono { font-family: var(--f-mono); font-weight: 600; }

a { color: var(--indigo); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--indigo);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Layout shell ---------- */
.shell {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--paper);
    box-shadow: var(--shadow-card);
    position: relative;
    padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 560px) {
    body { display: flex; justify-content: center; padding: 32px 16px; box-sizing: border-box; }
    .shell {
        min-height: auto;
        border-radius: 18px;
        overflow: hidden;
        box-shadow: 0 2px 4px rgba(32,30,27,0.08), 0 24px 48px -16px rgba(32,30,27,0.28);
    }
}

.topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.topbar .mark {
    width: 30px; height: 30px;
    border-radius: var(--r-sm);
    background: var(--indigo);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-family: var(--f-display); font-weight: 700; font-size: 15px;
}

.topbar .shopname {
    font-family: var(--f-display);
    font-weight: 600;
    font-size: 15px;
}

.topbar .shopname small {
    display: block;
    font-family: var(--f-body);
    font-weight: 400;
    color: var(--ink-soft);
    font-size: 11px;
}

/* ---------- Step indicator ---------- */
.steps {
    display: flex;
    padding: 14px 20px 0;
    gap: 6px;
}
.steps .seg {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: var(--line);
}
.steps .seg.done { background: var(--indigo); }

.stepnum {
    font-family: var(--f-mono);
    font-size: 11px;
    color: var(--indigo);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 14px 20px 4px;
}

/* ---------- Content ---------- */
.content { padding: 4px 20px 24px; }

.stepsection { animation: fadeSlideIn 0.32s ease both; }

.pagehead { margin: 6px 0 18px; }
.pagehead h1 { font-size: 22px; font-weight: 600; }
.pagehead p { margin: 6px 0 0; color: var(--ink-soft); font-size: 14px; }

/* ---------- Dropzone ---------- */
.dropzone {
    border: 1.5px dashed var(--line);
    border-radius: var(--r-md);
    padding: 28px 16px;
    text-align: center;
    background: var(--paper-alt);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.dropzone:hover { border-color: var(--indigo); background: #EFEEFB; }
.dropzone.drag { border-color: var(--indigo); background: #EFEEFB; transform: scale(1.015); }
.dropzone .icon { font-size: 26px; margin-bottom: 8px; display: inline-block; }
.dropzone.drag .icon { animation: iconFloat 0.6s ease-in-out infinite; }
.dropzone .title { font-weight: 600; font-size: 14px; }
.dropzone .sub { color: var(--ink-soft); font-size: 12px; margin-top: 4px; }
.dropzone input[type=file] { display: none; }

.filelist { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.fileitem {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm);
    padding: 10px 12px; font-size: 13px;
    animation: fadeSlideIn 0.25s ease both;
}
.fileitem .name { display: flex; align-items: center; gap: 8px; overflow: hidden; }
.fileitem .name span:first-child { flex-shrink: 0; }
.fileitem .name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.fileitem .rm { color: var(--stamp); cursor: pointer; font-family: var(--f-mono); font-size: 12px; background:none; border:none; }

/* ---------- Option groups ---------- */
.optgroup { margin-top: 20px; }
.optgroup label.grouplabel {
    display: block; font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft);
    margin-bottom: 8px;
}
.pillrow { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
    border: 1.5px solid var(--line);
    background: #fff;
    padding: 9px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: border-color .12s ease, background .12s ease, color .12s ease, transform .08s ease;
}
.pill:active { transform: scale(0.95); }
.pill.active { border-color: var(--indigo); background: var(--indigo); color: #fff; }

.stepper {
    display: flex; align-items: center; gap: 14px;
    border: 1.5px solid var(--line); border-radius: var(--r-md);
    padding: 10px 14px; width: fit-content;
}
.stepper button {
    width: 26px; height: 26px; border-radius: 50%;
    border: 1px solid var(--line); background: #fff;
    font-family: var(--f-mono); font-size: 14px; cursor: pointer;
    transition: background .12s ease, transform .08s ease;
}
.stepper button:hover { background: var(--paper-alt); }
.stepper button:active { transform: scale(0.9); }
.stepper .val { font-family: var(--f-mono); font-weight: 700; min-width: 18px; text-align: center; }

/* ---------- Summary / receipt card ---------- */
.receipt {
    margin-top: 22px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    position: relative;
    overflow: hidden;
}
.receipt::before, .receipt::after {
    content: "";
    position: absolute;
    left: 0; right: 0; height: 10px;
    background:
      radial-gradient(circle at 8px 5px, var(--paper-alt) 4px, transparent 4.5px) repeat-x;
    background-size: 16px 10px;
}
.receipt::before { top: -1px; }
.receipt::after { bottom: -1px; transform: rotate(180deg); }

.receipt .row {
    display: flex; justify-content: space-between;
    padding: 10px 18px; font-size: 13px;
    border-bottom: 1px dashed var(--line);
}
.receipt .row:last-child { border-bottom: none; }
.receipt .row .k { color: var(--ink-soft); }
.receipt .row .v { font-family: var(--f-mono); font-weight: 600; }
.receipt .row.total .v { font-size: 16px; color: var(--indigo); }

/* ---------- Buttons ---------- */
.btn {
    display: block; width: 100%;
    padding: 14px 18px;
    border-radius: var(--r-md);
    border: none;
    font-family: var(--f-body);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background .15s ease, transform .08s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: linear-gradient(180deg, #3B3FAE 0%, var(--indigo) 100%);
    color: #fff;
    box-shadow: 0 1px 2px rgba(35,38,95,0.15), 0 8px 16px -6px rgba(35,38,95,0.45);
}
.btn-primary:hover { background: var(--indigo-dark); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1.5px solid var(--line); box-shadow: none; }
.btn-ghost:hover { border-color: var(--ink-soft); }
.btn-block-gap { margin-top: 16px; }

.actionbar {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(250,248,243,0) 0%, var(--paper) 28%);
    padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
    margin: 0 -20px;
}

/* ---------- Token / success screen — the signature moment ---------- */
.token-card {
    margin-top: 8px;
    background: #fff;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    text-align: center;
    padding: 28px 20px 22px;
    position: relative;
    overflow: hidden;
    animation: printOut 0.5s cubic-bezier(.2,.8,.3,1) both;
    transform-origin: top center;
}
.token-card::before {
    content: "";
    position: absolute; bottom: -1px; left: 0; right: 0; height: 10px;
    background: radial-gradient(circle at 8px 5px, var(--paper-alt) 4px, transparent 4.5px) repeat-x;
    background-size: 16px 10px;
}
.token-card .eyebrow {
    font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--success);
}
.token-card .number {
    font-family: var(--f-mono);
    font-size: 52px;
    font-weight: 700;
    color: var(--indigo);
    margin: 6px 0 2px;
    line-height: 1;
    animation: fadeSlideIn 0.4s ease 0.15s both;
}
.token-card .sub { color: var(--ink-soft); font-size: 13px; }

/* ---------- Dashboard ---------- */
.dash-shell { max-width: 1120px; margin: 0 auto; padding: 0 20px 40px; }
.dash-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 22px 0; border-bottom: 1px solid var(--line); margin-bottom: 24px;
    flex-wrap: wrap; gap: 12px;
}
.dash-header .brand { display: flex; align-items: center; gap: 10px; }
.dash-header .brand .mark {
    width: 34px; height: 34px; border-radius: var(--r-sm);
    background: var(--indigo); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--f-display); font-weight: 700;
}
.dash-header .shopline b { display:block; font-family: var(--f-display); font-size: 15px; }
.dash-header .shopline span { font-size: 12px; color: var(--ink-soft); }

.dashtabs {
    display: flex; gap: 4px; margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
}
.dashtabs a {
    padding: 10px 16px; font-size: 13px; font-weight: 500;
    color: var(--ink-soft); text-decoration: none; white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.dashtabs a.active { color: var(--indigo); border-bottom-color: var(--indigo); }

.settingsform { padding: 18px; }
.settingsform .field { max-width: 380px; }
.settingsform .hint { font-size: 12px; color: var(--ink-soft); margin: -8px 0 14px; }
.savebar { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.savebar .btn { width: auto; padding: 10px 20px; }
.savemsg { font-size: 13px; color: var(--success); }

.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
@media (max-width: 800px) { .statgrid { grid-template-columns: repeat(2, 1fr); } }

.statcard {
    background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
    padding: 16px 18px;
    transition: transform .15s ease, box-shadow .15s ease;
}
.statcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.statcard .label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.statcard .value { font-family: var(--f-mono); font-size: 26px; font-weight: 700; margin-top: 6px; }
.statcard .value.indigo { color: var(--indigo); }
.statcard .value.success { color: var(--success); }
.statcard .value.stamp { color: var(--stamp); }

.panel {
    background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
    margin-bottom: 20px;
}
.panel .panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel .panel-head h2 { font-size: 15px; font-weight: 600; }

table.queue { width: 100%; border-collapse: collapse; font-size: 13px; }
table.queue th {
    text-align: left; padding: 10px 18px; color: var(--ink-soft);
    font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    border-bottom: 1px solid var(--line);
}
table.queue td { padding: 12px 18px; border-bottom: 1px solid var(--line); }
table.queue tr:last-child td { border-bottom: none; }
table.queue .tok { font-family: var(--f-mono); font-weight: 700; color: var(--indigo); }

@media (max-width: 700px) {
    table.queue thead { display: none; }
    table.queue, table.queue tbody, table.queue tr, table.queue td { display: block; width: 100%; }
    table.queue tr {
        padding: 12px 18px; border-bottom: 1px solid var(--line);
        display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 4px;
    }
    table.queue td { padding: 0; border: none; }
    table.queue td::before {
        content: attr(data-label);
        display: block; font-size: 10px; text-transform: uppercase;
        letter-spacing: .05em; color: var(--ink-soft); margin-bottom: 2px;
    }
    table.queue td:first-child { grid-column: 1 / 2; }
    table.queue td:nth-child(4) { grid-column: 2 / 3; grid-row: 1; text-align: right; }
    table.queue td:nth-child(2) { grid-column: 1 / 3; }
    table.queue td:nth-child(3) { grid-column: 1 / 2; }
    table.queue td:nth-child(5) { grid-column: 2 / 3; text-align: right; }
}

table.queue tr:hover td { background: var(--paper-alt); }

.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.badge.pending { background: #FBEFE9; color: var(--stamp); }
.badge.printing { background: #EAEAF8; color: var(--indigo); }
.badge.printed { background: #E8F3EB; color: var(--success); }

/* ---------- Landing / Homepage ---------- */
.land-shell { max-width: 1080px; margin: 0 auto; padding: 0 20px 60px; }
.land-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 22px 0;
}
.land-nav .brand { display: flex; align-items: center; gap: 10px; }
.land-nav .brand .mark {
    width: 34px; height: 34px; border-radius: var(--r-sm);
    background: var(--indigo); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--f-display); font-weight: 700;
}
.land-nav .brand b { font-family: var(--f-display); font-size: 16px; }
.land-nav a.btn { width: auto; padding: 9px 18px; font-size: 13px; }

.hero { padding: 48px 0 40px; text-align: center; }
.hero .eyebrow {
    display: inline-block; font-family: var(--f-mono); font-size: 11px;
    letter-spacing: .1em; text-transform: uppercase; color: var(--indigo);
    background: #EAEAF8; padding: 5px 12px; border-radius: 999px; margin-bottom: 16px;
}
.hero h1 {
    font-size: clamp(28px, 5vw, 44px); font-weight: 700; line-height: 1.15;
    max-width: 640px; margin: 0 auto;
    animation: fadeSlideIn .4s ease both;
}
.hero p.lead {
    max-width: 480px; margin: 16px auto 0; color: var(--ink-soft); font-size: 15px;
    animation: fadeSlideIn .4s ease .05s both;
}
.hero .cta-row {
    display: flex; gap: 12px; justify-content: center; margin-top: 26px; flex-wrap: wrap;
    animation: fadeSlideIn .4s ease .1s both;
}
.hero .cta-row .btn { width: auto; padding: 13px 24px; }

.flowstrip {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    flex-wrap: wrap; margin: 40px 0; font-family: var(--f-mono); font-size: 13px; color: var(--ink-soft);
}
.flowstrip .step { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; }
.flowstrip .arrow { color: var(--line); }

.featgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 10px; }
@media (max-width: 800px) { .featgrid { grid-template-columns: 1fr; } }
.featcard {
    background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
    padding: 20px 18px; transition: transform .15s ease, box-shadow .15s ease;
}
.featcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.featcard .ic { font-size: 22px; margin-bottom: 10px; }
.featcard h3 { font-size: 15px; font-weight: 600; }
.featcard p { font-size: 13px; color: var(--ink-soft); margin: 6px 0 0; line-height: 1.5; }

.land-footer {
    margin-top: 50px; padding-top: 20px; border-top: 1px solid var(--line);
    text-align: center; font-size: 12px; color: var(--ink-soft);
}

.emptystate { padding: 40px 18px; text-align: center; color: var(--ink-soft); font-size: 13px; }

/* ---------- Login ---------- */
.login-shell {
    max-width: 380px; margin: 60px auto; padding: 0 20px;
}
@media (max-width: 480px) { .login-shell { margin: 32px auto; } }
.login-card {
    background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
    padding: 32px 26px; box-shadow: var(--shadow-card);
    animation: fadeSlideIn 0.35s ease both;
}
.login-card .mark {
    width: 40px; height: 40px; border-radius: var(--r-sm);
    background: var(--indigo); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--f-display); font-weight: 700; margin-bottom: 16px;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input {
    width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
    font-family: var(--f-body); font-size: 14px;
}
.field input:focus { border-color: var(--indigo); }
.error-box {
    background: #FBEFE9; color: var(--stamp); border-radius: var(--r-sm);
    padding: 10px 12px; font-size: 13px; margin-bottom: 14px;
}
