/* ==========================================================================
   Barcode Lookup — design system
   Tokens → base → layout → components → pages → responsive
   ========================================================================== */

/* ---------- Tokens: light ---------- */
:root {
    --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

    --bg: #f4f6fa;
    --bg-accent: radial-gradient(1200px 500px at 50% -200px, #e3e8ff 0%, rgba(227, 232, 255, 0) 70%);
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --surface-3: #eef1f6;
    --border: #e2e6ee;
    --border-strong: #cfd5e1;
    --text: #0f172a;
    --text-2: #334155;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    --primary: #3b55e6;
    --primary-hover: #2f47cf;
    --primary-soft: #eef1ff;
    --primary-soft-text: #2c43c4;
    --ring: rgba(59, 85, 230, 0.35);

    --success: #12805c;
    --success-soft: #e7f6ef;
    --warning: #a45f00;
    --warning-soft: #fff5e3;
    --danger: #c9302c;
    --danger-soft: #fdecec;
    --info: #1d64c8;
    --info-soft: #e8f1fd;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.12);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --header-h: 64px;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --skeleton: linear-gradient(90deg, #eef1f6 0%, #f7f8fb 50%, #eef1f6 100%);
    color-scheme: light;
}

/* ---------- Tokens: dark (designed, not inverted) ---------- */
:root[data-theme="dark"] {
    --bg: #0b0f19;
    --bg-accent: radial-gradient(1200px 500px at 50% -200px, rgba(80, 100, 255, 0.16) 0%, rgba(11, 15, 25, 0) 70%);
    --surface: #121827;
    --surface-2: #161d2e;
    --surface-3: #1c2438;
    --border: #232c42;
    --border-strong: #2f3a55;
    --text: #e7eaf3;
    --text-2: #c3c9d8;
    --text-muted: #8a94ab;
    --text-inverse: #0b0f19;

    --primary: #7289ff;
    --primary-hover: #8a9dff;
    --primary-soft: rgba(114, 137, 255, 0.14);
    --primary-soft-text: #aab7ff;
    --ring: rgba(114, 137, 255, 0.45);

    --success: #3ecf95;
    --success-soft: rgba(62, 207, 149, 0.12);
    --warning: #f2b54a;
    --warning-soft: rgba(242, 181, 74, 0.12);
    --danger: #ff7a73;
    --danger-soft: rgba(255, 122, 115, 0.12);
    --info: #6fa8ff;
    --info-soft: rgba(111, 168, 255, 0.12);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --skeleton: linear-gradient(90deg, #1a2234 0%, #222b40 50%, #1a2234 100%);
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-accent), var(--bg);
    background-repeat: no-repeat;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.theme-transition, .theme-transition *, .theme-transition *::before, .theme-transition *::after {
    transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease) !important;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd { font-family: var(--font-mono); font-size: 0.85em; }
kbd {
    padding: 1px 6px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-2);
}

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.text-muted { color: var(--text-muted); }

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 16px; top: -48px; z-index: 100;
    padding: 8px 14px; border-radius: var(--radius-sm);
    background: var(--primary); color: var(--text-inverse);
    transition: top 0.15s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- App layout ---------- */
.app { display: flex; flex-direction: column; }

.app-header {
    position: sticky; top: 0; z-index: 20;
    height: var(--header-h);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.app-header__inner {
    height: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

.app-header__actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); min-width: 0; flex: 0 1 auto; }
.brand:hover { text-decoration: none; }
.brand__mark {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c4dff 100%);
    color: #fff;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 35%, transparent);
}
.brand__mark .icon { width: 20px; height: 20px; }
.brand__mark--md { width: 44px; height: 44px; border-radius: 12px; }
.brand__mark--md .icon { width: 24px; height: 24px; }
.brand__mark--lg { width: 48px; height: 48px; border-radius: 13px; background: rgba(255, 255, 255, 0.16); box-shadow: none; }
.brand__mark--lg .icon { width: 26px; height: 26px; }
.brand__text { display: flex; flex-direction: column; min-width: 0; }
.brand__name { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__company { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    min-width: 0;
}
.avatar {
    display: inline-grid; place-items: center;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary-soft); color: var(--primary-soft-text);
    font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.user-chip__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.user-chip__name { font-size: 13px; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip__meta { font-size: 11.5px; color: var(--text-muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 0; }

.app-main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 36px 24px 48px; outline: none; }
.app-footer { padding: 20px 24px 28px; text-align: center; font-size: 12.5px; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
    --btn-h: 40px;
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: var(--btn-h);
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit; font-size: 14px; font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease),
                box-shadow 0.15s var(--ease), transform 0.1s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { cursor: not-allowed; opacity: 0.7; }
.btn--sm { --btn-h: 34px; padding: 0 12px; font-size: 13px; }
.btn--lg { --btn-h: 48px; padding: 0 22px; font-size: 15px; }
.btn--block { width: 100%; }

.btn--primary {
    background: var(--primary); color: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
:root[data-theme="dark"] .btn--primary { color: #0b0f19; }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn--secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-muted); }

.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn__icon { display: none; }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.icon-btn {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.icon-btn--sm { width: 30px; height: 30px; border-color: transparent; background: transparent; border-radius: var(--radius-sm); }
.icon-btn--sm .icon { width: 16px; height: 16px; }
.icon-btn.is-copied { color: var(--success); }

.theme-toggle__sun { display: none; }
:root[data-theme="dark"] .theme-toggle__sun { display: block; }
:root[data-theme="dark"] .theme-toggle__moon { display: none; }

/* ---------- Badges & alerts ---------- */
.badge {
    display: inline-flex; align-items: center;
    height: 24px; padding: 0 10px;
    border-radius: 999px;
    font-size: 12px; font-weight: 600;
    white-space: nowrap;
}
.badge--warning { background: var(--warning-soft); color: var(--warning); }

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 14px;
    animation: fade-in-up 0.25s var(--ease);
}
.alert .icon { margin-top: 1px; }
.alert--danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert--warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert--info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }

/* ---------- Forms ---------- */
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.field__optional { font-weight: 400; color: var(--text-muted); }
.field__help { font-size: 12.5px; color: var(--text-muted); }
.field__error { font-size: 12.5px; color: var(--danger); min-height: 0; }
.field__error:empty { display: none; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap__icon { position: absolute; left: 13px; color: var(--text-muted); pointer-events: none; transition: color 0.15s var(--ease); }
.input-wrap:focus-within .input-wrap__icon { color: var(--primary); }
.input-wrap__action {
    position: absolute; right: 6px;
    display: grid; place-items: center;
    width: 32px; height: 32px;
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-muted);
    cursor: pointer;
}
.input-wrap__action:hover { background: var(--surface-3); color: var(--text); }
.input-wrap__action:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.input-wrap__action .icon--hide { display: none; }
.input-wrap__action[aria-pressed="true"] .icon--show { display: none; }
.input-wrap__action[aria-pressed="true"] .icon--hide { display: block; }

.input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit; font-size: 15px;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background-color 0.15s var(--ease);
}
.input::placeholder { color: var(--text-muted); opacity: 0.8; }
.input:hover { border-color: var(--text-muted); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 30%, transparent); }
.input--lg { height: 48px; font-size: 16px; }
.input--sm { height: 34px; font-size: 13.5px; padding: 0 10px; }
.input--with-icon { padding-left: 40px; }
.input--sm.input--with-icon { padding-left: 34px; }
.input-wrap--sm .input-wrap__icon { left: 11px; width: 15px; height: 15px; }
.input--with-action { padding-right: 46px; }
.input--mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
input[type="date"].input { padding-right: 10px; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

/* ---------- Lookup page ---------- */
.page { display: flex; flex-direction: column; gap: 24px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-title { font-size: 26px; font-weight: 700; }
.page-subtitle { margin-top: 6px; color: var(--text-muted); font-size: 15px; }

.lookup-card { padding: 24px; }
.lookup-form { display: flex; gap: 16px; }
.lookup-form--inline { align-items: flex-start; }
.lookup-form--inline .lookup-form__fields { flex: 1; min-width: 0; }
.lookup-form--inline .lookup-form__actions { padding-top: 27px; } /* aligns with input under the label */
.lookup-form--grid { flex-direction: column; }
.lookup-form--grid .lookup-form__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 20px; }
.lookup-form--grid .lookup-form__actions { display: flex; justify-content: flex-end; }
.lookup-form__actions .btn { min-width: 132px; }

/* ---------- Result states ---------- */
.results { min-height: 240px; }

.state {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 48px 24px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 60%, transparent);
    animation: fade-in-up 0.3s var(--ease);
}
.state__icon {
    display: grid; place-items: center;
    width: 56px; height: 56px; margin-bottom: 16px;
    border-radius: 16px;
    background: var(--surface-3); color: var(--text-muted);
}
.state__icon .icon { width: 26px; height: 26px; }
.state__title { font-size: 17px; font-weight: 650; }
.state__text { margin-top: 6px; max-width: 460px; color: var(--text-muted); font-size: 14.5px; }
.state__meta { margin-top: 10px; font-family: var(--font-mono); font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.state__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }

.state--idle .state__icon, .state--neutral .state__icon { background: var(--primary-soft); color: var(--primary); }
.state--warning { border-style: solid; border-color: color-mix(in srgb, var(--warning) 30%, var(--border)); }
.state--warning .state__icon { background: var(--warning-soft); color: var(--warning); }
.state--danger { border-style: solid; border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.state--danger .state__icon { background: var(--danger-soft); color: var(--danger); }

/* ---------- Result card ---------- */
.result-card { overflow: hidden; animation: fade-in-up 0.3s var(--ease); }

.result-head {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
}
.result-head__main { min-width: 0; }
.eyebrow { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.mother-code { display: flex; align-items: center; gap: 6px; margin-top: 4px; min-width: 0; }
.mother-code__value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; letter-spacing: 0.01em; overflow-wrap: anywhere; }

.stat {
    display: flex; flex-direction: column; align-items: flex-end;
    padding: 8px 16px;
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary-soft-text);
    flex-shrink: 0;
}
.stat__value { font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__label { font-size: 12px; font-weight: 600; opacity: 0.85; }

.details {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 24px;
    margin: 0; padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}
.details__item { min-width: 0; }
.details dt { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.details dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }

.result-toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 14px 24px;
}
.result-toolbar__title { font-size: 14px; font-weight: 650; color: var(--text-2); }
.result-toolbar__actions { display: flex; align-items: center; gap: 8px; }
.result-toolbar__actions .input-wrap { width: 200px; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    position: sticky; top: 0;
    padding: 10px 24px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}
.data-table td { padding: 11px 24px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.data-table tbody tr { transition: background-color 0.12s var(--ease); animation: fade-in 0.3s var(--ease) both; animation-delay: calc(var(--row-index, 0) * 18ms); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .col-index { width: 56px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.data-table .col-barcode { font-family: var(--font-mono); font-weight: 600; color: var(--text); letter-spacing: 0.01em; }
.data-table .col-actions { width: 56px; text-align: right; padding-top: 6px; padding-bottom: 6px; }
.data-table tbody tr .col-actions .icon-btn { opacity: 0.55; }
.data-table tbody tr:hover .col-actions .icon-btn, .data-table .col-actions .icon-btn:focus-visible { opacity: 1; }
/* Long, comma-separated values (e.g. Description) wrap instead of widening the table. */
.data-table .col-wrap { min-width: 16rem; font-family: var(--font-mono); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.table-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ---------- Skeleton ---------- */
.is-loading .result-head { flex-direction: column; align-items: flex-start; gap: 10px; }
.skeleton { border-radius: 6px; background: var(--skeleton); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; }
.skeleton--label { width: 110px; height: 11px; }
.skeleton--title { width: 260px; max-width: 70%; height: 24px; }
.skeleton-list { display: flex; flex-direction: column; gap: 14px; padding: 22px 24px; }
.skeleton--row { height: 16px; }
.skeleton--row:nth-child(2) { width: 88%; }
.skeleton--row:nth-child(3) { width: 94%; }
.skeleton--row:nth-child(4) { width: 76%; }

/* ---------- Toasts ---------- */
.toast-region {
    position: fixed; top: calc(var(--header-h) + 12px); right: 20px; z-index: 50;
    display: flex; flex-direction: column; gap: 10px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 12px 12px 14px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--info);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    color: var(--text);
    pointer-events: auto;
    animation: toast-in 0.25s var(--ease);
}
.toast.is-leaving { animation: toast-out 0.2s var(--ease) forwards; }
.toast__icon { margin-top: 1px; color: var(--info); }
.toast__text { flex: 1; }
.toast__close { display: grid; place-items: center; width: 24px; height: 24px; margin: -2px -2px 0 0; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); cursor: pointer; }
.toast__close .icon { width: 14px; height: 14px; }
.toast__close:hover { background: var(--surface-3); color: var(--text); }
.toast--success { border-left-color: var(--success); }
.toast--success .toast__icon { color: var(--success); }
.toast--warning { border-left-color: var(--warning); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--error { border-left-color: var(--danger); }
.toast--error .toast__icon { color: var(--danger); }

/* ---------- Auth (login) ---------- */
.auth { background: var(--bg); }
.auth .toast-region { top: 16px; }
.auth-shell { display: grid; grid-template-columns: minmax(380px, 5fr) 7fr; min-height: 100vh; }

.auth-hero {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 44px 48px;
    color: #fff;
    background:
        radial-gradient(900px 500px at 110% 110%, rgba(124, 77, 255, 0.55), transparent 60%),
        radial-gradient(700px 400px at -10% -10%, rgba(80, 160, 255, 0.35), transparent 60%),
        linear-gradient(160deg, #2a3fd1 0%, #1d2b8f 55%, #151d5c 100%);
}
:root[data-theme="dark"] .auth-hero {
    background:
        radial-gradient(900px 500px at 110% 110%, rgba(124, 77, 255, 0.35), transparent 60%),
        radial-gradient(700px 400px at -10% -10%, rgba(80, 160, 255, 0.2), transparent 60%),
        linear-gradient(160deg, #1a2470 0%, #121a4d 55%, #0d1233 100%);
}
.auth-hero__brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth-hero__company { font-weight: 650; font-size: 16px; letter-spacing: 0.01em; }
.auth-hero__copy { position: relative; z-index: 1; max-width: 420px; }
.auth-hero__copy h2 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.auth-hero__copy p { margin-top: 12px; font-size: 15.5px; color: rgba(255, 255, 255, 0.78); }
.auth-hero__list { list-style: none; margin: 28px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-hero__list li { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: rgba(255, 255, 255, 0.9); }
.auth-hero__list .icon { width: 30px; height: 30px; padding: 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.12); }
.auth-hero__bars {
    position: absolute; right: -40px; bottom: 60px;
    width: 360px; height: 180px;
    opacity: 0.1;
    background: repeating-linear-gradient(90deg, #fff 0 6px, transparent 6px 12px, #fff 12px 14px, transparent 14px 22px, #fff 22px 26px, transparent 26px 30px);
    transform: rotate(-8deg);
}

.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; position: relative; }
.auth-topbar { position: absolute; top: 20px; right: 24px; display: flex; align-items: center; gap: 10px; }
.auth-card { width: 100%; max-width: 400px; animation: fade-in-up 0.35s var(--ease); }
.auth-card__header { margin-bottom: 26px; }
.auth-card__header h1 { margin-top: 18px; font-size: 24px; font-weight: 700; }
.auth-card__header p { margin-top: 6px; }
.auth-card .btn--block { margin-top: 6px; }
.auth-footer { position: absolute; bottom: 20px; font-size: 12.5px; color: var(--text-muted); }

/* ---------- Error page ---------- */
.error-page { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 64px 16px; max-width: 520px; margin: 0 auto; }
.error-page__code {
    font-size: 72px; font-weight: 800; line-height: 1; letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--primary), #7c4dff);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.error-page__title { margin-top: 16px; font-size: 22px; }
.error-page__message { margin-top: 8px; color: var(--text-muted); }
.error-page__actions { margin-top: 24px; }
.error-page__ref { margin-top: 24px; font-size: 12.5px; color: var(--text-muted); }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-in-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
}

@media (max-width: 720px) {
    .app-header__inner { padding: 0 16px; }
    .app-main { padding: 24px 16px 40px; }
    .user-chip__text, .brand__company { display: none; }
    .user-chip { padding: 3px; }
    .hide-sm { display: none; }
    .page-title { font-size: 22px; }

    .lookup-card { padding: 18px; }
    .lookup-form--inline { flex-direction: column; align-items: stretch; }
    .lookup-form--inline .lookup-form__actions { padding-top: 0; }
    .lookup-form__actions .btn { width: 100%; }

    .result-head { flex-direction: column; align-items: flex-start; padding: 18px; }
    .stat { flex-direction: row; align-items: baseline; gap: 8px; }
    .details, .result-toolbar { padding-left: 18px; padding-right: 18px; }
    .result-toolbar__actions { width: 100%; }
    .result-toolbar__actions .input-wrap { flex: 1; width: auto; }

    /* Table rows become compact cards on small screens. */
    .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .data-table tbody tr {
        display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 12px;
        padding: 10px 18px;
        border-bottom: 1px solid var(--border);
    }
    .data-table tbody tr:last-child { border-bottom: 0; }
    .data-table td { padding: 2px 0; border: 0; }
    .data-table .col-index { width: auto; grid-column: 1; grid-row: 1; }
    .data-table .col-barcode { grid-column: 2; grid-row: 1; overflow-wrap: anywhere; }
    .data-table .col-actions { width: auto; grid-column: 3; grid-row: 1; padding: 0; }
    .data-table .col-actions .icon-btn { opacity: 1; }
    .data-table td:not(.col-index):not(.col-barcode):not(.col-actions) {
        grid-column: 2 / 4;
        display: flex; justify-content: space-between; gap: 12px;
        font-size: 13px;
    }
    .data-table td:not(.col-index):not(.col-barcode):not(.col-actions)::before {
        content: attr(data-label);
        color: var(--text-muted); font-weight: 500;
    }
    /* Long descriptions: label on its own line above the wrapped value; hidden entirely when empty. */
    .data-table tbody td.col-wrap:not(.col-index):not(.col-barcode):not(.col-actions) { display: block; min-width: 0; }
    .data-table tbody td.col-wrap:not(.col-index):not(.col-barcode):not(.col-actions)::before { display: block; font-family: var(--font-sans); }
    .data-table tbody td.col-wrap:not(.col-index):not(.col-barcode):not(.col-actions):empty { display: none; }

    .toast-region { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; }
}

@media (max-width: 420px) {
    .app-header__actions { gap: 6px; }
    .app-header .badge { padding: 0 8px; font-size: 11px; }
    .auth-topbar { top: 14px; right: 14px; }
    .auth-card__header h1 { font-size: 21px; }
}
