/* =====================================================================
   QR Bar Ordering - admin & platform styles
   Clean, high-contrast, generous spacing. Brand colour is injected as
   --brand by the layout so each venue's admin picks up its own accent.
   ===================================================================== */

:root {
    --bg:            #f5f6f8;
    --surface:       #ffffff;
    --surface-2:     #fafbfc;
    --text:          #0f172a;
    --text-muted:    #64748b;
    --text-subtle:   #94a3b8;
    --border:        #e4e7ec;
    --border-strong: #cbd2dc;

    --brand:         #1d4ed8;
    --brand-ink:     #ffffff;
    --brand-soft:    color-mix(in srgb, var(--brand) 10%, white);
    --brand-border:  color-mix(in srgb, var(--brand) 28%, white);

    --green:   #067647;
    --green-bg:#ecfdf3;
    --amber:   #b54708;
    --amber-bg:#fffaeb;
    --red:     #b42318;
    --red-bg:  #fef3f2;

    --radius:    12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow:    0 1px 3px rgba(16, 24, 40, .10), 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);

    --sidebar-w: 248px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

.muted    { color: var(--text-muted); }
.subtle   { color: var(--text-subtle); }
.small    { font-size: 13px; }
.tiny     { font-size: 12px; }
.strong   { font-weight: 600; }
.nowrap   { white-space: nowrap; }
.right    { text-align: right; }
.center   { text-align: center; }
.mono     { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.mt-0 { margin-top: 0 } .mt-8 { margin-top: 8px } .mt-16 { margin-top: 16px } .mt-24 { margin-top: 24px }
.mb-0 { margin-bottom: 0 } .mb-8 { margin-bottom: 8px } .mb-16 { margin-bottom: 16px } .mb-24 { margin-bottom: 24px }
.hidden { display: none !important; }

/* ------------------------------------------------------------- layout */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: #ffffff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
    min-height: 64px;
}

.sidebar-brand img {
    width: 34px; height: 34px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.sidebar-brand .mark {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: var(--brand-ink);
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.sidebar-brand .name {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-brand .sub { font-size: 12px; color: var(--text-subtle); }

.nav { padding: 12px 10px; flex: 1; }
.nav-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-subtle);
    font-weight: 600;
    padding: 14px 10px 6px;
}
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: #344054;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    margin-bottom: 2px;
}
.nav a:hover { background: #f2f4f7; text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; }
.nav a .count {
    margin-left: auto;
    font-size: 11px;
    background: var(--border);
    color: var(--text-muted);
    padding: 1px 7px;
    border-radius: 99px;
    font-weight: 600;
}

.sidebar-foot {
    border-top: 1px solid var(--border);
    padding: 12px;
    font-size: 13px;
}
.sidebar-foot .who { font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar .spacer { flex: 1; }

.page { padding: 28px; max-width: 1200px; width: 100%; }
.page.wide { max-width: none; }

.page-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.page-head .spacer { flex: 1; }
.page-head p { color: var(--text-muted); margin: 4px 0 0; font-size: 14px; }

/* ------------------------------------------------------------- cards */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 20px; }
.card-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.card-head .spacer { flex: 1; }
.card-head h2 { font-size: 15px; }
.card-head p { font-size: 13px; color: var(--text-muted); margin: 2px 0 0; }
.card-body { padding: 20px; }
.card-body.tight { padding: 14px 20px; }
.card-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex;
    gap: 10px;
    align-items: center;
}
.card-foot .spacer { flex: 1; }

.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ------------------------------------------------------------- stats */

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.stat .label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-subtle);
    font-weight: 600;
}
.stat .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; }
.stat .foot { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ------------------------------------------------------------ buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: #344054;
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
    transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn:active { background: #f2f4f7; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-ink);
}
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, black); }

.btn-danger { color: var(--red); border-color: #fda29b; background: #fff; }
.btn-danger:hover { background: var(--red-bg); }

.btn-ghost { border-color: transparent; box-shadow: none; background: transparent; }
.btn-ghost:hover { background: #f2f4f7; }

.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* -------------------------------------------------------------- forms */

.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label,
.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #344054;
}
.field .hint { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }
.field .error-text { font-size: 12.5px; color: var(--red); margin-top: 6px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=tel], input[type=date], input[type=time], input[type=search],
select, textarea {
    width: 100%;
    padding: 9px 12px;
    font: inherit;
    font-size: 14.5px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    appearance: none;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}

input[type=color] {
    width: 52px; height: 38px; padding: 3px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

input[readonly] { background: var(--surface-2); color: var(--text-muted); }

.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row > * { flex: 1 1 200px; }

.input-prefix {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    overflow: hidden;
}
.input-prefix span {
    display: grid; place-items: center;
    padding: 0 11px;
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 14px;
}
.input-prefix input {
    border: 0; box-shadow: none; border-radius: 0;
}
.input-prefix:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}
.input-prefix input:focus { box-shadow: none; }

/* checkbox / switch */
.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 10px;
}
.check:last-child { margin-bottom: 0; }
.check input[type=checkbox], .check input[type=radio] {
    width: 17px; height: 17px;
    margin: 2px 0 0;
    accent-color: var(--brand);
    flex-shrink: 0;
    cursor: pointer;
}
.check .ct { font-weight: 500; }
.check .cd { font-size: 12.5px; color: var(--text-muted); display: block; font-weight: 400; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
    width: 40px; height: 23px;
    background: var(--border-strong);
    border-radius: 99px;
    position: relative;
    transition: background .15s ease;
    flex-shrink: 0;
}
.switch .track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 19px; height: 19px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease;
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.data th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-subtle);
    font-weight: 600;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}
table.data td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.actions { text-align: right; white-space: nowrap; width: 1%; }
table.data .thumb {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
table.data .thumb-empty {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    display: grid; place-items: center;
    color: var(--text-subtle);
    font-size: 15px;
}

/* ------------------------------------------------------------- badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); border-color: #abefc6; }
.badge-amber { background: var(--amber-bg); color: var(--amber); border-color: #fedf89; }
.badge-red   { background: var(--red-bg);   color: var(--red);   border-color: #fecdca; }
.badge-grey  { background: #f2f4f7;         color: #475467;      border-color: var(--border); }
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-border); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------- flash */

.flash-stack { margin-bottom: 20px; display: grid; gap: 10px; }
.flash {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    border: 1px solid;
}
.flash-success { background: var(--green-bg); border-color: #abefc6; color: #05603a; }
.flash-error   { background: var(--red-bg);   border-color: #fecdca; color: #912018; }
.flash-info    { background: #eff8ff;         border-color: #b2ddff; color: #175cd3; }
.flash svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* ------------------------------------------------------------- notice */

/* Same shape as a flash message, but part of the page rather than
   something that appeared after an action and then goes away. */
.notice {
    display: flex;
    gap: 11px;
    padding: 14px 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-size: 14px;
    line-height: 1.55;
}
.notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.notice strong { display: block; margin-bottom: 2px; }
.notice-amber { background: var(--amber-bg); border-color: #fedf89; color: #93370d; }
.notice-green { background: var(--green-bg); border-color: #abefc6; color: #05603a; }

/* ------------------------------------------------------------- choice */

/* A radio group where each option needs a sentence of explanation - too
   much to sit on one line beside a normal radio button. */
.choice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--border-strong, #98a2b3); }
.choice input { margin-top: 3px; flex-shrink: 0; }
.choice.selected { border-color: var(--brand); background: var(--brand-soft); }
.choice.disabled { opacity: .55; cursor: not-allowed; }
.choice.disabled:hover { border-color: var(--border); }
.choice .small { margin-top: 3px; }

/* -------------------------------------------------------------- empty */

.empty {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
}
.empty .icon {
    width: 46px; height: 46px;
    margin: 0 auto 14px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-subtle);
}
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 380px; margin: 0 auto 18px; font-size: 14px; }

/* -------------------------------------------------------------- login */

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}
.auth-card .logo {
    width: 46px; height: 46px;
    border-radius: 11px;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 19px;
    margin-bottom: 20px;
}
.auth-card h1 { font-size: 21px; margin-bottom: 6px; }
.auth-card .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

/* --------------------------------------------------------- misc bits */

.pill-tabs {
    display: flex;
    gap: 4px;
    background: #eef0f3;
    padding: 4px;
    border-radius: 10px;
    overflow-x: auto;
}
.pill-tabs a {
    padding: 6px 13px;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
}
.pill-tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.pill-tabs a:hover { text-decoration: none; color: var(--text); }

.code-chip {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: .04em;
}

.divider-text {
    display: flex; align-items: center; gap: 12px;
    color: var(--text-subtle); font-size: 12.5px;
    margin: 20px 0;
}
.divider-text::before, .divider-text::after {
    content: ''; flex: 1; border-top: 1px solid var(--border);
}

/* modal */
dialog {
    border: 0;
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: var(--shadow-lg);
    max-width: 560px;
    width: calc(100% - 32px);
    color: var(--text);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog .card-head, dialog .card-body, dialog .card-foot { border-radius: 0; }
dialog .card-foot { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.impersonating {
    background: #fffaeb;
    border-bottom: 1px solid #fedf89;
    color: #93370d;
    font-size: 13px;
    padding: 8px 28px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.impersonating form { margin-left: auto; }

/* ---------------------------------------------------------- responsive */

@media (max-width: 900px) {
    .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.cols-2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex: none;
        height: auto;
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }
    .nav { display: flex; gap: 4px; overflow-x: auto; padding: 8px; }
    .nav a { white-space: nowrap; margin: 0; }
    .nav-group-label { display: none; }
    .nav a .count { margin-left: 6px; }
    .sidebar-foot { display: flex; align-items: center; gap: 10px; }
    .sidebar-foot .spacer { flex: 1; }
    .page { padding: 18px 16px; }
    .topbar { padding: 0 16px; }
    .grid.cols-4, .grid.cols-3 { grid-template-columns: 1fr; }
    .impersonating { padding: 8px 16px; flex-wrap: wrap; }
}

@media print {
    .sidebar, .topbar, .btn, .flash-stack { display: none !important; }
    .page { padding: 0; }
    body { background: #fff; }
}

/* A tablet that has been turned off but is still paired. Dimmed rather than
   hidden, so it is obvious it exists and is deliberately not running. */
.card.is-off { opacity: .62; }
.card.is-off:hover { opacity: 1; }
