/* App styles. Colours, spacing and radii come from tokens.css only; no one-off values (CLAUDE.md). */

/* ---- base ----------------------------------------------------------------------------- */
h1 { margin: 0 0 var(--space-2); font-size: 28px; line-height: 36px; font-weight: 700; }
h1:focus { outline: none; }
h2 { margin: 0; }
a { color: var(--action); }
p { margin: 0 0 var(--space-3); }
ul, ol { margin: 0; }
.text-secondary { color: var(--text-secondary); }
.hint { color: var(--text-muted); font-weight: 400; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.section-title { font-size: 20px; line-height: 28px; font-weight: 600; margin-bottom: var(--space-3); }

/* ---- shells --------------------------------------------------------------------------- */
.staff-shell { display: flex; min-height: 100vh; }
.staff-sidebar {
    width: var(--sidebar-width);
    flex: none;
    padding: var(--space-6) var(--space-4);
    color: var(--surface);
    background: var(--sidebar);
}
.staff-brand { display: flex; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-8); }
.brand-mark { font-size: 32px; font-weight: 800; color: var(--brand); letter-spacing: -1px; }
.brand-sub { font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.staff-nav { display: flex; flex-direction: column; gap: var(--space-1); }
.nav-item {
    display: flex; align-items: center; gap: var(--space-3);
    min-height: var(--control-height); padding: 0 var(--space-3);
    color: var(--surface); text-decoration: none; border-radius: var(--radius-control);
}
.nav-item:hover { background: var(--sidebar-selected); }
.nav-item.active { background: var(--sidebar-selected); font-weight: 600; }
.staff-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.staff-header {
    height: var(--header-height); flex: none;
    display: flex; align-items: center; justify-content: flex-end; gap: var(--space-6);
    padding: 0 var(--space-8);
    background: var(--surface); border-bottom: 1px solid var(--divider);
}
.staff-identity { display: flex; align-items: center; gap: var(--space-3); }
.staff-identity-text { display: flex; flex-direction: column; text-align: right; line-height: 1.25; font-size: 14px; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 999px;
    color: var(--surface); background: var(--action); font-weight: 600; font-size: 14px;
}
.staff-content { padding: var(--space-8); flex: 1; }

.connectivity { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 14px; color: var(--text-secondary); }
.connectivity-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--success); }
.connectivity.is-offline { color: var(--warning); font-weight: 600; }
.connectivity.is-offline .connectivity-dot { background: var(--warning); }

.customer-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--surface); }
.customer-header {
    display: flex; align-items: center; gap: var(--space-6);
    padding: var(--space-4) var(--space-8); border-bottom: 1px solid var(--divider);
}
.customer-brand { display: flex; align-items: baseline; gap: var(--space-2); }
.customer-brand .brand-sub { color: var(--text); }
.customer-welcome { flex: 1; margin: 0; font-size: 18px; }
.staff-button { min-width: 112px; }
.customer-main { flex: 1; padding: var(--space-6) var(--space-8); }

.page-content { width: 100%; max-width: 1440px; margin-inline: auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-6); margin-bottom: var(--space-6); }
.page-header p { margin: 0; }

.signin-required { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--space-6); }
.signin-required .card { max-width: 480px; text-align: center; }
.signin-required .staff-brand { justify-content: center; }

/* ---- surfaces ------------------------------------------------------------------------- */
.card { margin-bottom: var(--space-6); }
.form-card { max-width: 100%; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); }
.two-col > .card { margin-bottom: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); }
.guidance { margin-bottom: var(--space-4); }

.notice { padding: var(--space-3) var(--space-4); border-radius: var(--radius-control); border: 1px solid var(--divider); margin-bottom: var(--space-4); }
.notice ul { margin: var(--space-2) 0 0; padding-left: var(--space-6); }
.notice-info { color: var(--info); background: var(--info-bg); }
.notice-success { color: var(--success); background: var(--success-bg); }
.notice-warning { color: var(--warning); background: var(--warning-bg); }
.notice-error { color: var(--error); background: var(--error-bg); }

.empty-state { padding: var(--space-12) var(--space-6); text-align: center; background: var(--surface); border: 1px dashed var(--control-border); border-radius: var(--radius-card); }
.skeleton { background: var(--divider); border-radius: var(--radius-card); margin-bottom: var(--space-3); animation: pulse 1.4s ease-in-out infinite; }
.skeleton-card { height: 140px; }
.skeleton-row { height: 64px; }
@keyframes pulse { 50% { opacity: .55; } }

.action-bar {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
    margin-top: var(--space-6); padding-bottom: env(safe-area-inset-bottom);
}
.action-bar-end { display: flex; align-items: center; gap: var(--space-4); }
.form-actions { display: flex; gap: var(--space-3); margin-top: var(--space-4); }

/* ---- buttons -------------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--control-height); padding: 12px 20px;
    font-weight: 600; cursor: pointer; text-decoration: none;
    border: 1px solid transparent; border-radius: var(--radius-control);
}
.btn:disabled { color: var(--text-secondary); background: var(--divider); cursor: not-allowed; }
.btn-primary { color: var(--surface); background: var(--action); }
@media (hover: hover) { .btn-primary:hover:not(:disabled) { background: var(--action-hover); } }
.btn-primary:active:not(:disabled) { background: var(--action-pressed); }
.btn-secondary { color: var(--text); background: var(--surface); border-color: var(--control-border); }
.btn-tertiary { color: var(--action); background: transparent; }
.btn-handover { color: var(--surface); background: var(--handover); }
.btn-sm { min-height: 40px; padding: 8px 14px; }
.btn-lg { min-height: 56px; padding: 14px 28px; font-size: 18px; }

/* ---- forms ---------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-6); border: 0; padding: 0; min-width: 0; }
.field label, .field legend { font-weight: 500; padding: 0; }
.field-inline { flex-direction: row; align-items: center; margin: 0; }
.input {
    width: 100%; min-height: var(--control-height); padding: 12px var(--space-4);
    color: var(--text); background: var(--surface);
    border: 1px solid var(--control-border); border-radius: var(--radius-control);
}
textarea.input { min-height: 112px; resize: vertical; }
.input-lg { min-height: 56px; font-size: 18px; }
.form-error { color: var(--error); font-weight: 500; }
.check-row { display: flex; align-items: flex-start; gap: var(--space-3); min-height: 44px; padding: var(--space-2) 0; cursor: pointer; }
.check-row input { width: 24px; height: 24px; flex: none; margin-top: 2px; accent-color: var(--action); }
.changed-flag { display: flex; align-items: center; gap: var(--space-3); margin: 0; font-size: 14px; }

/* ---- badges, chips, choice cards ------------------------------------------------------ */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; background: var(--divider); color: var(--text-secondary); }
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-error { color: var(--error); background: var(--error-bg); }
.badge-info { color: var(--info); background: var(--info-bg); }
.badge-live { color: var(--surface); background: var(--handover); }

.chip-row, .choice-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.chip {
    min-height: 44px; padding: 8px var(--space-4); border-radius: 999px; font-weight: 500; cursor: pointer;
    color: var(--text); background: var(--surface); border: 1px solid var(--control-border);
}
.chip.is-selected { color: var(--action); background: var(--selected-bg); border-color: var(--action); font-weight: 600; }
.choice-card {
    min-height: 64px; min-width: 112px; padding: var(--space-3) var(--space-6); cursor: pointer; font-weight: 600; font-size: 18px;
    color: var(--text); background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--radius-control);
}
.choice-card.is-selected { color: var(--action); background: var(--selected-bg); border: 2px solid var(--action); }
.choice-card-lg { display: flex; align-items: center; gap: var(--space-3); text-align: left; flex: 1; min-width: 180px; }
.choice-text { display: flex; flex-direction: column; }
.choice-mark { font-size: 22px; }
.choice-row-lg { margin-bottom: var(--space-4); }
fieldset { border: 0; padding: 0; margin: 0 0 var(--space-6); min-width: 0; }
fieldset legend { padding: 0; margin-bottom: var(--space-3); }

/* ---- sessions & lookup ---------------------------------------------------------------- */
.session-card { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-6); align-items: center; }
.session-card.is-quiet { opacity: .9; }
.session-thumb {
    width: 96px; height: 96px; display: flex; align-items: center; justify-content: center;
    font-size: 36px; font-weight: 700; color: var(--action); background: var(--selected-bg); border-radius: var(--radius-card);
}
.session-title-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.session-title { font-size: 20px; line-height: 28px; font-weight: 600; }
.session-meta { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: flex; flex-direction: column; gap: var(--space-1); color: var(--text-secondary); }
.session-side { display: flex; align-items: center; gap: var(--space-6); }
.session-count { display: flex; flex-direction: column; align-items: center; }
.session-count strong { font-size: 24px; }
.session-reason { max-width: 220px; margin: 0; }
.pending-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) 0; border-top: 1px solid var(--divider); }
.pending-row:first-child { border-top: 0; }

.result-list li + li { margin-top: var(--space-3); }
.result-row {
    display: flex; align-items: center; gap: var(--space-4); width: 100%; min-height: 72px; padding: var(--space-3) var(--space-4);
    text-align: left; cursor: pointer; font-size: 16px;
    color: var(--text); background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-card);
}
@media (hover: hover) { .result-row:hover { border-color: var(--action); } }
.result-icon {
    width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center;
    background: var(--selected-bg); border-radius: 999px;
}
.result-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chevron { font-size: 28px; color: var(--text-muted); }
.identity-card { display: flex; align-items: center; gap: var(--space-4); }
.identity-main { display: flex; flex-direction: column; gap: var(--space-1); }

/* ---- consent, products ---------------------------------------------------------------- */
.consent-panel { display: flex; gap: var(--space-6); padding: var(--space-8); background: var(--selected-bg); border: 1px solid var(--divider); border-radius: var(--radius-card); }
.consent-art { font-size: 56px; line-height: 1; }
.consent-body { flex: 1; }
.privacy-note { font-size: 14px; margin-top: var(--space-4); }

.product-grid { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-4); }
.product-tile { padding: var(--space-3); background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-card); }
.product-tile-name { display: block; margin-top: var(--space-2); font-weight: 500; }
.product-image {
    width: 100%; aspect-ratio: 4 / 3; overflow: hidden; display: flex; align-items: center; justify-content: center;
    background: var(--surface-subtle); border-radius: var(--radius-control);
}
.product-image img { width: 100%; height: 100%; object-fit: contain; }
.product-placeholder { font-size: 40px; font-weight: 700; color: var(--text-muted); }

/* ---- customer rating ------------------------------------------------------------------ */
.rate-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-6); max-width: 1280px; margin: 0 auto; }
.rail { padding-right: var(--space-4); border-right: 1px solid var(--divider); }
.rail-title { font-weight: 600; margin-bottom: var(--space-3); }
.rail-item {
    display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 64px; margin-bottom: var(--space-2); padding: var(--space-2);
    text-align: left; cursor: pointer; color: var(--text); background: var(--surface); border: 1px solid transparent; border-radius: var(--radius-control);
}
.rail-item .product-image { width: 56px; flex: none; }
.rail-item .product-placeholder { font-size: 20px; }
.rail-item.is-current { background: var(--selected-bg); border-color: var(--action); }
.rail-text { display: flex; flex-direction: column; min-width: 0; }
.rail-state { font-size: 14px; color: var(--text-secondary); }
.rail-state-rated { color: var(--success); font-weight: 600; }
.rate-panel { min-width: 0; }
.progress { height: 8px; background: var(--divider); border-radius: 999px; overflow: hidden; margin-bottom: var(--space-6); }
.progress-bar { height: 100%; background: var(--action); transition: width .18s ease; }
.rate-product { display: grid; grid-template-columns: 220px 1fr; gap: var(--space-6); align-items: center; margin-bottom: var(--space-6); }
.customer-title { font-size: 32px; line-height: 40px; font-weight: 700; }
.customer-hero { font-size: 40px; line-height: 48px; font-weight: 800; }
.customer-question { font-size: 20px; line-height: 28px; font-weight: 600; margin: 0 0 var(--space-3); }
.skip-row { margin: var(--space-3) 0 var(--space-6); }
.customer-actions { display: flex; justify-content: space-between; gap: var(--space-4); margin-top: var(--space-6); padding-bottom: env(safe-area-inset-bottom); }
.save-status { min-height: 24px; color: var(--text-secondary); margin: 0; }
.char-count { text-align: right; color: var(--text-muted); font-size: 16px; margin: 0; }

.faces { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.face {
    display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
    min-width: 88px; padding: var(--space-2); cursor: pointer; color: var(--text);
    background: transparent; border: 2px solid transparent; border-radius: var(--radius-card);
}
.face:disabled { opacity: .4; cursor: not-allowed; }
.face.is-selected { border-color: var(--text); background: var(--surface-subtle); }
.face-art { width: 72px; height: 72px; }
.face-disc { fill: var(--face-colour); }
.face-shine { fill: var(--surface); opacity: .18; }
.face-feature { fill: var(--face-ink); }
.face-mouth { fill: none; stroke: var(--face-ink); stroke-width: 4; stroke-linecap: round; }
.face-tick { fill: none; stroke: var(--text); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.face-number { font-weight: 700; font-size: 18px; }
.face-label { font-size: 16px; color: var(--text-secondary); }
.faces-status { margin: var(--space-2) 0 0; color: var(--text-secondary); }

.thanks { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.thanks-card { text-align: center; max-width: 520px; }
.thanks-art { font-size: 64px; }

/* ---- PIN gate & dialogs --------------------------------------------------------------- */
.dialog-backdrop {
    position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: var(--space-4);
    background: var(--text); background: color-mix(in srgb, var(--text) 55%, transparent);
}
.dialog {
    width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: var(--space-6);
    background: var(--surface); border-radius: var(--radius-dialog); box-shadow: var(--shadow-dialog);
}
.dialog:focus { outline: none; }
.dialog-title { font-size: 20px; line-height: 28px; font-weight: 600; margin-bottom: var(--space-4); }
.dialog-footer { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-6); }
.pin-card { width: min(380px, 100%); text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: var(--space-3); margin: var(--space-4) 0; }
.pin-dot { width: 16px; height: 16px; border-radius: 999px; border: 2px solid var(--control-border); }
.pin-dot.is-filled { background: var(--text); border-color: var(--text); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-top: var(--space-4); }
.key {
    min-height: 64px; font-size: 24px; font-weight: 600; cursor: pointer;
    color: var(--text); background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--radius-control);
}
.key:disabled { opacity: .45; cursor: not-allowed; }
.key-primary { color: var(--surface); background: var(--action); border-color: transparent; font-size: 18px; }
.key-secondary { background: var(--surface-subtle); }
.pin-cancel { margin-top: var(--space-4); }

/* ---- outcome -------------------------------------------------------------------------- */
.summary-strip { display: flex; gap: var(--space-6); margin: 0; }
.summary-strip div { display: flex; flex-direction: column; align-items: flex-end; }
.summary-strip dt { font-size: 14px; color: var(--text-secondary); }
.summary-strip dd { margin: 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.outcome-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-6); align-items: start; }
.next-panel { position: sticky; top: var(--space-6); background: var(--surface-subtle); }
.next-list li { padding: var(--space-3) 0; border-top: 1px solid var(--divider); display: flex; flex-direction: column; }
.next-list li:first-child { border-top: 0; }
.sample-row { display: flex; align-items: center; gap: var(--space-3); min-height: 64px; padding: var(--space-2) 0; cursor: pointer; border-top: 1px solid var(--divider); }
.sample-list li:first-child .sample-row { border-top: 0; }
.sample-row input { width: 24px; height: 24px; accent-color: var(--action); }
.sample-row .product-image { width: 64px; flex: none; }
.sample-row .product-placeholder { font-size: 22px; }
.sample-name { flex: 1; font-weight: 500; }

/* ---- tasks ---------------------------------------------------------------------------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.kpi { display: flex; flex-direction: column; padding: var(--space-4) var(--space-6); background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-card); }
.kpi-title { color: var(--text-secondary); }
.kpi-value { font-size: 32px; line-height: 40px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-alert .kpi-value { color: var(--error); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap; }
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--divider); }
.tab { min-height: var(--control-height); padding: 0 var(--space-4); cursor: pointer; font-weight: 500; color: var(--text-secondary); background: transparent; border: 0; border-bottom: 3px solid transparent; }
.tab.is-active { color: var(--action); border-bottom-color: var(--action); font-weight: 600; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-card); overflow: hidden; }
.table th { height: 48px; padding: 0 var(--space-4); text-align: left; font-size: 14px; color: var(--text-secondary); background: var(--surface-subtle); }
.table td { padding: var(--space-4); vertical-align: top; border-top: 1px solid var(--divider); }
.table .actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }

/* ---- narrow screens ------------------------------------------------------------------- */
@media (max-width: 1023px) {
    .rate-product { grid-template-columns: 160px 1fr; }
    .outcome-layout { grid-template-columns: 1fr; }
    .next-panel { position: static; }
    .rate-layout { grid-template-columns: 200px minmax(0, 1fr); }
}
@media (max-width: 767px) {
    .staff-sidebar { display: none; }
    .staff-content, .customer-main { padding: var(--space-4); }
    .staff-header, .customer-header { padding-inline: var(--space-4); }
    .two-col, .form-grid { grid-template-columns: 1fr; }
    .session-card { grid-template-columns: 1fr; }
    .session-side { justify-content: space-between; }
    .rate-layout { grid-template-columns: 1fr; }
    .rail { display: none; }
    .rate-product { grid-template-columns: 1fr; }
    .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .consent-panel { flex-direction: column; padding: var(--space-4); }
    .page-header { flex-direction: column; }
    .action-bar { flex-wrap: wrap; }
    .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { padding: var(--space-3) 0; border-top: 1px solid var(--divider); }
    .table td { border: 0; padding: var(--space-1) var(--space-4); }
    .table td[data-label]::before { content: attr(data-label); display: block; font-size: 14px; color: var(--text-secondary); }
    .table td[data-label=""]::before { content: none; }
}

/* ---- loading screen and error bar (Blazor) ------------------------------------------- */
.loading-progress { position: relative; display: block; width: 8rem; height: 8rem; margin: 20vh auto 1rem auto; }
.loading-progress circle { fill: none; stroke: var(--divider); stroke-width: 0.6rem; transform-origin: 50% 50%; transform: rotate(-90deg); }
.loading-progress circle:last-child {
    stroke: var(--action);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text { position: absolute; text-align: center; font-weight: bold; inset: calc(20vh + 3.25rem) 0 auto 0.2rem; }
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Loading"); }

#blazor-error-ui {
    display: none; position: fixed; inset: auto 0 0 0; z-index: 1000; padding: var(--space-3) var(--space-4);
    color: var(--error); background: var(--error-bg); border-top: 1px solid var(--divider);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: var(--space-4); top: var(--space-3); }
