:root {
    --navy: #17324d;
    --navy-soft: #24476a;
    --teal: #0f766e;
    --teal-soft: #e7f4f1;
    --text: #1f2937;
    --muted: #5b6675;
    --border: #d8e0e8;
    --bg: #f3f6f9;
    --surface: #ffffff;
    --danger: #b42318;
    --warning: #8a5a00;
    --radius: 14px;
    --shadow: 0 12px 30px rgba(23, 50, 77, 0.07);
    /* The content area uses the whole window on ordinary desktop widths and
       only stops growing on very large monitors. */
    --shell-max: 2140px;
    --gutter: clamp(12px, 1.4vw, 28px);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

h1,
h2,
h3,
p,
ul,
dl {
    margin-top: 0;
}

h1 {
    margin-bottom: 6px;
    color: var(--navy);
    font-size: clamp(1.6rem, 2.1vw, 2.05rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

h2 {
    margin-bottom: 10px;
    color: var(--navy);
    font-size: 1.1rem;
    line-height: 1.3;
}

p {
    margin-bottom: 14px;
}

a {
    color: var(--teal);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    color: #0b5f59;
}

code {
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #f6f8fa;
    color: #1b2430;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.88em;
}

.mono {
    font-family: Consolas, "Courier New", monospace;
}

.muted {
    color: var(--muted);
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--teal);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.lede {
    max-width: 90ch;
    color: var(--muted);
    font-size: 1rem;
}

.hint {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

.topbar {
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
}

.topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: 9px var(--gutter);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--navy);
    text-decoration: none;
}

.brand:hover {
    color: var(--navy);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--teal);
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.brand-text strong {
    font-size: 1rem;
}

.brand-text small {
    color: var(--muted);
    font-size: 0.76rem;
}

.nav {
    display: flex;
    gap: 18px;
    margin-left: auto;
}

.nav a {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
}

.nav a:hover {
    color: var(--teal);
}

.userbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 18px;
    border-left: 1px solid var(--border);
}

.userbox form {
    margin: 0;
}

.user-name {
    color: var(--navy);
    font-size: 0.9rem;
    font-weight: 600;
}

.shell {
    flex: 1;
    width: 100%;
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: 16px var(--gutter) 26px;
}

.page-head {
    max-width: none;
    margin-bottom: 14px;
}

.page-head h1 {
    margin-bottom: 4px;
}

.grid {
    display: grid;
    gap: 12px;
}

.grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 12px;
}

.card {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.card:last-child {
    margin-bottom: 0;
}

.card > h2:first-child {
    margin-top: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--teal-soft);
    color: var(--teal);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-teal {
    background: var(--teal-soft);
    color: var(--teal);
}

.badge-muted {
    background: #eef2f6;
    color: var(--muted);
}

.kv {
    display: grid;
    grid-template-columns: minmax(110px, 0.65fr) minmax(0, 1.35fr);
    gap: 10px 16px;
    margin: 0;
}

.kv dt {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
}

.kv dd {
    margin: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-done {
    background: #e8f5ee;
    color: #177245;
}

.status-pending {
    background: #fff6e0;
    color: var(--warning);
}

.status-blocked {
    background: #fdeceb;
    color: var(--danger);
}

.checklist {
    margin: 0;
    padding: 0;
    list-style: none;
}

.checklist li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid #edf1f5;
}

.checklist li:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.checklist li:first-child {
    padding-top: 0;
}

.checklist .status {
    flex: 0 0 auto;
    margin-top: 2px;
}

.checklist-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.checklist-text strong {
    color: var(--navy);
    font-size: 0.95rem;
}

.checklist-text small {
    color: var(--muted);
    font-size: 0.83rem;
}

.plain-list {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
}

.plain-list li {
    margin-bottom: 8px;
}

.plain-list li:last-child {
    margin-bottom: 0;
}

.alert {
    margin-bottom: 12px;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.9rem;
}

.alert-error {
    border-color: #f3c1bd;
    background: #fdf1f0;
    color: #8f1d14;
}

.alert-success {
    border-color: #b9dfc8;
    background: #eef8f1;
    color: #166534;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
    background: var(--teal);
    color: #ffffff;
}

.btn-primary:hover {
    background: #0b5f59;
    color: #ffffff;
}

.btn-ghost {
    border-color: var(--border);
    background: transparent;
    color: var(--muted);
}

.btn-ghost:hover {
    border-color: var(--navy);
    color: var(--navy);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    width: min(1040px, 100%);
    margin: 26px auto;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 22px 60px rgba(23, 50, 77, 0.12);
}

.auth-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 52px 48px;
    background:
        radial-gradient(circle at 15% 10%, rgba(15, 118, 110, 0.35), transparent 45%),
        linear-gradient(150deg, #17324d 0%, #1c3b5a 55%, #0f2a40 100%);
    color: #ffffff;
}

.auth-side .eyebrow {
    color: #8fd3ca;
}

.auth-side h1 {
    margin-bottom: 18px;
    color: #ffffff;
    font-size: clamp(1.9rem, 3.2vw, 2.55rem);
}

.auth-side .lede {
    margin-bottom: 24px;
    color: #cdd9e4;
    font-size: 0.98rem;
}

.auth-points {
    margin: 0 0 28px;
    padding: 0;
    list-style: none;
}

.auth-points li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
    color: #e4ecf3;
    font-size: 0.92rem;
}

.auth-points .dot {
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    margin-top: 7px;
    border-radius: 50%;
    background: #6ac7bb;
}

.phase-note {
    margin: 0;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    color: #9fb3c6;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-panel {
    display: flex;
    align-items: center;
    padding: 48px 44px;
}

.auth-panel-inner {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
}

.auth-panel h2 {
    margin-bottom: 6px;
    font-size: 1.65rem;
}

.auth-form {
    margin-top: 22px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    color: var(--navy);
    font-size: 0.86rem;
    font-weight: 600;
}

.field input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fbfcfd;
    color: var(--text);
    font: inherit;
    font-size: 0.96rem;
}

.field input:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
    background: #ffffff;
}

.auth-form .btn {
    margin-top: 6px;
}

.error-card {
    max-width: 640px;
    margin: 40px auto;
    text-align: left;
}

.footer {
    border-top: 1px solid var(--border);
    background: #ffffff;
}

.footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: 10px var(--gutter);
    color: var(--muted);
    font-size: 0.76rem;
}

@media (max-width: 900px) {
    .grid-two {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
        margin: 10px auto;
    }

    .auth-side {
        padding: 36px 30px;
    }

    .auth-side h1 {
        font-size: 1.9rem;
    }

    .auth-panel {
        padding: 36px 30px;
    }
}

@media (max-width: 640px) {
    .topbar-inner {
        gap: 12px;
        padding: 12px 16px;
    }

    .brand-text small {
        display: none;
    }

    .nav {
        order: 3;
        width: 100%;
        margin-left: 0;
        padding-top: 8px;
        border-top: 1px solid var(--border);
    }

    .userbox {
        margin-left: auto;
        padding-left: 0;
        border-left: 0;
    }

    .user-name {
        display: none;
    }

    .shell {
        padding: 12px var(--gutter) 20px;
    }

    .card {
        padding: 12px 13px;
    }

    .kv {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
    }

    .kv dd {
        margin-bottom: 8px;
    }

    .checklist li {
        gap: 10px;
    }
}

/* ---------- Phase 1 application chrome ---------- */

.appnav {
    border-top: 1px solid var(--border);
    background: #ffffff;
}

.appnav-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    width: 100%;
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: 4px var(--gutter);
}

.appnav-link {
    padding: 5px 9px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
}

.appnav-link:hover {
    background: #f1f5f8;
    color: var(--navy);
}

.appnav-link.is-active {
    background: var(--teal-soft);
    color: var(--teal);
}

.nav-group {
    position: relative;
}

.nav-trigger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 9px;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}

.nav-trigger:hover,
.nav-group.is-open > .nav-trigger {
    background: #f1f5f8;
    color: var(--navy);
}

.nav-group.has-active > .nav-trigger,
.nav-group.has-active > .nav-trigger:hover {
    background: var(--teal-soft);
    color: var(--teal);
}

.nav-trigger:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
}

.nav-caret {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.65;
    transition: transform 0.15s ease;
}

.nav-group.is-open .nav-caret {
    transform: rotate(180deg);
}

.nav-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 80;
    min-width: 232px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 16px 34px rgba(23, 50, 77, 0.16);
}

.nav-group.is-open > .nav-menu {
    display: block;
}

.nav-menu-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.nav-menu-link:hover {
    background: #f1f5f8;
    color: var(--navy);
}

.nav-menu-link.is-active {
    background: var(--teal-soft);
    color: var(--teal);
}

.user-name {
    text-decoration: none;
}

.alert-warning {
    border-color: #f2d49b;
    background: #fff8e6;
    color: #7a4d00;
}

.alert-info {
    border-color: #c4d8ea;
    background: #eef5fb;
    color: #23476b;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.stat-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stat-value {
    color: var(--navy);
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-warn {
    color: var(--warning);
}

.stat-danger {
    color: var(--danger);
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.action-row form {
    margin: 0;
}

.inline-form {
    display: inline;
    margin: 0;
}

.link-small {
    color: var(--teal);
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
}

.link-small:hover {
    text-decoration: underline;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--teal);
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}

.link-button:hover {
    text-decoration: underline;
}

.link-danger {
    color: var(--danger);
}

.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.card-head h2 {
    margin-bottom: 0;
}

.subhead {
    margin: 22px 0 10px;
    color: var(--navy);
    font-size: 1rem;
}

.empty {
    margin: 0;
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.table th,
.table td {
    padding: 6px 9px;
    border-bottom: 1px solid #edf1f5;
    text-align: left;
    vertical-align: top;
}

.table th {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table th.num,
.table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.row-muted {
    color: var(--muted);
    background: #fafbfc;
}

.row-highlight {
    background: var(--teal-soft);
}

.table .flags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.table .actions {
    white-space: nowrap;
    text-align: right;
}

.table .actions > * + * {
    margin-left: 8px;
}

.table .actions.actions-stack {
    white-space: normal;
}

.table .actions.actions-stack > * + * {
    margin-left: 0;
    margin-top: 4px;
}

.table .actions.actions-stack div > * + * {
    margin-left: 8px;
}

.table small {
    display: block;
    font-size: 0.73rem;
    line-height: 1.35;
}

.bulk-table {
    min-width: 1700px;
}

.bulk-table td {
    vertical-align: middle;
}

.bulk-table input[type="text"],
.bulk-table input[type="number"],
.bulk-table select {
    width: 100%;
    min-width: 70px;
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fbfcfd;
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
}

.bulk-table input[type="number"] {
    min-width: 64px;
}

.bulk-table input[type="text"]:focus,
.bulk-table input[type="number"]:focus,
.bulk-table select:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
    background: #ffffff;
}

.bulk-table input[readonly] {
    background: #f1f4f7;
    color: var(--muted);
}

.bulk-table th:nth-child(2) {
    min-width: 140px;
}

.bulk-table th:nth-child(3) {
    min-width: 130px;
}

.bulk-table th:nth-child(11),
.bulk-table th:nth-child(12) {
    min-width: 150px;
}

.bulk-index {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    text-align: right;
    width: 28px;
}

.bulk-flags {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bulk-flags .check {
    gap: 5px;
    font-size: 0.78rem;
    white-space: nowrap;
}

.bulk-flags .check input {
    width: 14px;
    height: 14px;
}

.bulk-remove {
    white-space: nowrap;
}

.bulk-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
}

.badge-ok {
    background: #e8f5ee;
    color: #177245;
}

.badge-warn {
    background: #fff6e0;
    color: var(--warning);
}

.badge-danger {
    background: #fdeceb;
    color: var(--danger);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.filters .field {
    margin-bottom: 0;
}

.field-grow {
    flex: 1 1 240px;
}

.field select,
.field textarea,
.field input[type="file"] {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fbfcfd;
    color: var(--text);
    font: inherit;
    font-size: 0.96rem;
}

.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
    background: #ffffff;
}

.field input[readonly],
.field input:disabled,
.field select:disabled {
    background: #f1f4f7;
    color: var(--muted);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
}

.form-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin: 6px 0 16px;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 0.9rem;
}

.check input {
    width: 16px;
    height: 16px;
    accent-color: var(--teal);
}

.perm-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    min-width: 260px;
}

.perm-checks .check {
    white-space: nowrap;
}

.approver-picker {
    max-height: 180px;
    overflow-y: auto;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
}

.email-recipients {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 0 0 14px;
    padding: 10px 14px;
}

.email-recipients legend {
    font-weight: 600;
    padding: 0 6px;
}

.email-recipient {
    align-items: flex-start;
    display: flex;
    gap: 10px;
    padding: 6px 0;
}

.email-recipient input {
    accent-color: var(--teal);
    height: 16px;
    margin-top: 3px;
    width: 16px;
}

.email-recipient span {
    display: flex;
    flex-direction: column;
}

.email-recipient.is-unavailable {
    opacity: 0.6;
}

.req {
    color: var(--danger);
}

.text-warn {
    color: var(--warning);
    font-weight: 700;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 18px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 7px 12px;
    border-radius: 8px 8px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
}

.tab:hover {
    background: #f1f5f8;
    color: var(--navy);
}

.tab.is-active {
    background: var(--teal-soft);
    color: var(--teal);
}

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 16px;
}

.pager-current {
    padding: 6px 12px;
    border-radius: 9px;
    background: var(--navy);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 700;
}

.bucket-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bucket-list li {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfcfd;
}

.bucket-label {
    display: block;
    color: var(--navy);
    font-weight: 700;
    font-size: 0.9rem;
}

.bucket-value {
    color: var(--muted);
    font-size: 0.82rem;
}

.details summary {
    color: var(--teal);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.json {
    max-width: 420px;
    margin: 6px 0 0;
    padding: 10px;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f7f9fb;
    color: #26313d;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.76rem;
    white-space: pre-wrap;
    word-break: break-word;
}

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

@media (max-width: 900px) {
    .appnav-inner {
        position: relative;
        flex-wrap: wrap;
        padding: 4px 8px;
    }

    .appnav-link,
    .nav-trigger {
        white-space: nowrap;
    }

    .nav-group {
        position: static;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 8px;
        right: 8px;
        min-width: 0;
        z-index: 90;
    }
}

@media (max-width: 640px) {

    .form-grid,
    .form-grid-4 {
        grid-template-columns: minmax(0, 1fr);
    }

    .filters {
        align-items: stretch;
    }

    .table .actions {
        white-space: normal;
    }
}

/* ---------- Phase 2 point of sale ---------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.split-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.split-grid > .card {
    margin: 0;
}

.card-highlight {
    border-color: #b9e3d9;
    background: #f4fbf8;
}

.card-danger {
    border-color: #f3c9c5;
    background: #fffafa;
}

.summary-list {
    margin: 0;
    padding: 0;
}

.summary-list > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed #e5ebf0;
}

.summary-list > div:last-child {
    border-bottom: 0;
}

.summary-list dt {
    color: var(--muted);
    font-size: 0.86rem;
}

.summary-list dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.summary-list .summary-total {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 2px solid var(--navy);
    border-bottom: 0;
}

.summary-list .summary-total dt,
.summary-list .summary-total dd {
    color: var(--navy);
    font-size: 1.05rem;
    font-weight: 800;
}

.summary-inline > div {
    display: inline-flex;
    flex-direction: column;
    border: 0;
    padding: 0 22px 0 0;
}

.summary-inline {
    display: flex;
    flex-wrap: wrap;
}

.table tr.row-sub td {
    padding-top: 4px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #eef2f6;
    color: var(--muted);
    font-size: 0.84rem;
}

.rx-image {
    display: block;
    max-width: 100%;
    max-height: 420px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.pos-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.pos-head h1 {
    margin-bottom: 4px;
}

.pos-shift {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.pos-app {
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr);
    gap: 12px;
    align-items: start;
}

.pos-main,
.pos-side {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.pos-search-card {
    position: relative;
    padding-bottom: 8px;
}

.pos-search {
    position: relative;
}

.pos-search input[type="search"] {
    width: 100%;
    padding: 14px 54px 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: #fbfcfd;
    color: var(--text);
    font: inherit;
    font-size: 1.05rem;
}

.pos-search input[type="search"]:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
    background: #fff;
}

.pos-search-hint {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f1f5f8;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.pos-results {
    max-height: 380px;
    margin-top: 8px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.pos-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #edf1f5;
    background: #fff;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.pos-result:last-child {
    border-bottom: 0;
}

.pos-result:hover,
.pos-result.is-selected {
    background: var(--teal-soft);
}

.pos-result-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pos-result-main small {
    color: var(--muted);
    font-size: 0.78rem;
}

.pos-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.pos-result-price {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pos-result-stock {
    color: #177245;
    font-size: 0.78rem;
    font-weight: 600;
}

.pos-result-stock.is-out {
    color: var(--danger);
}

.pos-shelf {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #eef4fb;
    color: #23476b;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.pos-result-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    margin-top: 2px;
    color: #31465a;
    font-size: 0.76rem;
}

.pos-fact-label {
    color: var(--muted);
    font-weight: 600;
}

.pos-on-order {
    margin-top: 2px;
    color: #8a5a00;
    font-size: 0.78rem;
    font-weight: 600;
}

.pos-alt-open {
    margin-top: 4px;
}

body.pos-modal-open {
    overflow: hidden;
}

.pos-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pos-modal[hidden] {
    display: none;
}

.pos-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 32, 48, 0.55);
}

.pos-modal-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(720px, 100%);
    max-height: min(86vh, 760px);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(16, 32, 48, 0.3);
    overflow: hidden;
}

.pos-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.pos-modal-head .eyebrow {
    margin: 0;
}

.pos-modal-head h2 {
    margin: 2px 0 4px;
}

.pos-modal-head p {
    margin: 0;
}

.pos-alt-modal-body {
    display: grid;
    gap: 10px;
    flex: 1 1 auto;
    padding: 14px 18px;
    overflow-y: auto;
}

.pos-alt-modal-body .empty {
    margin: 0;
}

.pos-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: #f8fafc;
}

.pos-alt-card {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.pos-alt-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.pos-alt-card p {
    margin: 0;
}

.pos-alt-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    color: #31465a;
    font-size: 0.82rem;
}

.pos-alt-card .btn {
    justify-self: start;
    margin-top: 4px;
}

.pos-loose {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #e6f6ec;
    color: #146c43;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
}

.pos-table .pos-mode-fixed {
    color: var(--muted);
    font-size: 0.85rem;
    cursor: help;
}

.pos-messages {
    min-height: 0;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.88rem;
}

.pos-messages.is-error {
    color: var(--danger);
    font-weight: 600;
}

.pos-messages.is-success {
    color: #177245;
    font-weight: 600;
}

.pos-cart-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.84rem;
}

.pos-table td {
    vertical-align: middle;
}

.pos-table .pos-qty,
.pos-table .pos-discount {
    width: 78px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    text-align: right;
}

.pos-table .pos-mode {
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
}

.pos-held-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pos-held-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfd;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.pos-held-item:hover {
    border-color: var(--teal);
    background: var(--teal-soft);
}

.pos-held-item small {
    color: var(--muted);
}

.pos-totals {
    background: #fbfcfd;
}

.pos-total-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    font-variant-numeric: tabular-nums;
}

.pos-total-row strong {
    font-weight: 700;
}

.pos-grand {
    margin: 6px 0 10px;
    padding-top: 8px;
    border-top: 2px solid var(--navy);
    color: var(--navy);
    font-size: 1.15rem;
    font-weight: 800;
}

.pos-customer-results {
    max-height: 220px;
    margin-top: 6px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.pos-customer-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid #b9e3d9;
    border-radius: 8px;
    background: #f4fbf8;
}

.pos-details {
    margin-top: 8px;
}

.pos-details summary {
    color: var(--teal);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}

.pos-payments {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.pos-tender-ref {
    margin-top: 6px;
    padding: 6px 8px;
    font-size: 0.85rem;
}

.pos-actions {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 10px;
}

.btn-block {
    width: 100%;
}

.pos-toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 50;
    padding: 12px 16px;
    border: 1px solid var(--navy);
    border-radius: 9px;
    background: var(--navy);
    color: #fff;
    box-shadow: 0 10px 30px rgba(15, 40, 70, 0.28);
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}

.pos-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.pos-toast.is-error {
    border-color: var(--danger);
    background: var(--danger);
}

/* ---------- Phase 2 Z report ---------- */

.z-report {
    background: #fff;
}

.z-head {
    padding-bottom: 10px;
    border-bottom: 2px solid var(--navy);
    text-align: center;
}

.z-head h2 {
    margin-bottom: 2px;
}

.z-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 6px 22px;
    margin: 0 0 18px;
}

.z-grid > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #e5ebf0;
}

.z-grid dt {
    color: var(--muted);
    font-size: 0.84rem;
}

.z-grid dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.z-report h3 {
    margin: 18px 0 8px;
    color: var(--navy);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.z-cash {
    max-width: 460px;
}

.z-warning {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #f2d49b;
    border-radius: 8px;
    background: #fff8e6;
    color: #7a4d00;
    font-size: 0.9rem;
}

.z-sign {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 20px;
    margin-top: 34px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.86rem;
}

@media (max-width: 980px) {
    .pos-app {
        grid-template-columns: minmax(0, 1fr);
    }

    .split-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .pos-payments {
        grid-template-columns: minmax(0, 1fr);
    }

    .pos-modal {
        padding: 10px;
    }

    .pos-modal-dialog {
        max-height: 94vh;
    }

    .pos-modal-head {
        flex-direction: column;
    }

    .page-actions {
        width: 100%;
    }
}

@media print {
    .topbar,
    .footer,
    .no-print,
    .action-row,
    .alert {
        display: none !important;
    }

    .shell {
        width: auto;
        margin: 0;
        padding: 0;
    }

    .card {
        border: 0;
        box-shadow: none;
        padding: 0;
    }

    .z-report {
        font-size: 11px;
    }
}

/* Purchasing (Phase 3) */
.field-wide {
    grid-column: 1 / -1;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
}

.product-search {
    position: relative;
    margin-bottom: 12px;
}

.product-search label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted, #5b6770);
    margin-bottom: 6px;
}

.product-search input {
    width: 100%;
}

.product-results {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    margin-top: 4px;
    max-height: 320px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line, #d7dee3);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(15, 31, 42, .16);
}

.product-results button {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-bottom: 1px solid var(--line, #edf1f3);
    background: transparent;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.product-results button:hover,
.product-results button:focus {
    background: #eef6f3;
    outline: none;
}

.product-results small {
    display: block;
    color: var(--muted, #5b6770);
}

.product-results .empty {
    padding: 10px 12px;
}

.purchase-lines td,
.purchase-lines th {
    vertical-align: middle;
}

.purchase-lines input {
    width: 100%;
    min-width: 70px;
    padding: 6px 7px;
    font-size: 13px;
}

.purchase-lines .line-product {
    min-width: 200px;
}

.purchase-lines .line-product strong {
    display: block;
}

.purchase-lines .line-product small {
    display: block;
    color: var(--muted, #5b6770);
    font-size: 12px;
}

.purchase-lines tr.is-invalid {
    background: #fff6f5;
}

.purchase-totals {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.purchase-totals .summary-list {
    width: min(420px, 100%);
}

.purchase-form .form-actions {
    margin-top: 18px;
}

@media (max-width: 900px) {
    .two-col {
        grid-template-columns: minmax(0, 1fr);
    }
}

.btn-danger {
    background: #a12622;
    border-color: #a12622;
    color: #fff;
}

.btn-danger:hover {
    background: #8b1f1b;
    border-color: #8b1f1b;
}

.return-block + .return-block {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line, #e6ecef);
}

.return-block h3 {
    margin: 0 0 4px;
    font-size: 16px;
}

/* Reports and controls (Phase 4) */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.report-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: inherit;
    text-decoration: none;
}

.report-card:hover {
    border-color: var(--teal, #2f8f83);
}

.report-card strong {
    color: var(--navy);
}

.report-card span {
    color: var(--muted);
    font-size: 0.88rem;
}

a.stat-value {
    text-decoration: none;
}

a.stat-value:hover {
    text-decoration: underline;
}

.report-table tfoot td {
    border-top: 2px solid var(--border);
    background: var(--surface-alt, #f6f8f9);
}

.print-body {
    background: #fff;
    margin: 0;
}

.print-sheet {
    max-width: 900px;
    margin: 18px auto;
    padding: 0 24px;
}

.print-head h1 {
    margin: 0;
    font-size: 1.4rem;
    color: var(--navy);
}

.print-head p {
    margin: 4px 0 16px;
    color: var(--muted);
}

.print-summary {
    margin-bottom: 16px;
}

.print-section {
    margin: 18px 0 8px;
    font-size: 1rem;
    color: var(--navy);
}

.print-table {
    font-size: 12px;
}

.print-table th,
.print-table td {
    padding: 4px 6px;
    vertical-align: top;
}

.print-note {
    font-size: 11px;
    color: var(--muted);
}

.print-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--muted);
}

@media print {
    .print-sheet {
        max-width: none;
        margin: 0;
        padding: 0;
    }
}

.count-input {
    width: 96px;
    padding: 6px 8px;
    text-align: right;
}

/* Purchase orders */
.po-secondary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.po-secondary-actions .inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.po-secondary-actions input[type="text"] {
    min-width: 240px;
}

.purchase-lines input.line-batch,
.purchase-lines input.line-expiry {
    min-width: 110px;
}

.purchase-lines tr.is-skipped {
    opacity: .55;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Expiry-risk bands: five return-deadline colours, red (passed) to green (safe). */
.risk-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 0 0 1rem;
}

.risk-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .6rem;
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: 999px;
    background: var(--surface);
    font-size: .82rem;
}

.risk-chip strong {
    font-variant-numeric: tabular-nums;
}

.expiry-risk-table td:first-child {
    border-left: 4px solid transparent;
}

/* This report carries about twenty columns; trim its cells so it still fits a
   laptop screen before the internal scroller is needed. */
.expiry-risk-table th,
.expiry-risk-table td {
    padding: 4px 5px;
}

.expiry-risk-table {
    font-size: 0.8rem;
}

.risk-band-1 {
    --risk-colour: #b42318;
    --risk-tint: #fef3f2;
}

.risk-band-2 {
    --risk-colour: #b54708;
    --risk-tint: #fff6ed;
}

.risk-band-3 {
    --risk-colour: #8a5a00;
    --risk-tint: #fffaeb;
}

.risk-band-4 {
    --risk-colour: #a16207;
    --risk-tint: #fefce8;
}

.risk-band-5 {
    --risk-colour: #0f766e;
    --risk-tint: #ecfdf3;
}

.risk-chip.risk-band-1,
.risk-chip.risk-band-2,
.risk-chip.risk-band-3,
.risk-chip.risk-band-4,
.risk-chip.risk-band-5 {
    border-left-color: var(--risk-colour);
    background: var(--risk-tint);
}

.expiry-risk-table tr.risk-band-1 td,
.expiry-risk-table tr.risk-band-2 td,
.expiry-risk-table tr.risk-band-3 td,
.expiry-risk-table tr.risk-band-4 td,
.expiry-risk-table tr.risk-band-5 td {
    background: var(--risk-tint);
}

.expiry-risk-table tr.risk-band-1 td:first-child,
.expiry-risk-table tr.risk-band-2 td:first-child,
.expiry-risk-table tr.risk-band-3 td:first-child,
.expiry-risk-table tr.risk-band-4 td:first-child,
.expiry-risk-table tr.risk-band-5 td:first-child {
    border-left-color: var(--risk-colour);
}

/* Keep the wide expiry-risk table usable: a mirrored scrollbar above the table
   and a pinned item column so each row stays identifiable while scrolling. */
.expiry-risk-table-wrap {
    overflow-x: auto;
}

.hscroll-mirror {
    overflow-x: auto;
    overflow-y: hidden;
    height: 18px;
    margin: 0 0 .35rem;
}

.hscroll-mirror[hidden] {
    display: none;
}

.hscroll-mirror-inner {
    height: 1px;
}

.expiry-risk-table th:first-child,
.expiry-risk-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: 1px 0 0 var(--border);
}

.expiry-risk-table th:first-child {
    z-index: 2;
    background: var(--surface);
}

.expiry-risk-table td:first-child {
    background: var(--risk-tint, var(--surface));
}

/* Sale-projection drafting */
.projection-table .check-cell {
    width: 2.25rem;
    text-align: center;
}

.projection-table .check-cell input {
    width: 1.05rem;
    height: 1.05rem;
}

.projection-table tr.projection-covered td {
    color: var(--muted);
}

.projection-actions {
    justify-content: flex-end;
    margin: 0.9rem 0 0;
}

/* Catalogue maintenance tools */
.tool-table {
    min-width: 980px;
}

.tool-table .check-cell,
.check-cell {
    width: 2.25rem;
    text-align: center;
}

.tool-table .check-cell input,
.check-cell input {
    width: 1.05rem;
    height: 1.05rem;
}

.quality-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 8px;
}

.quality-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfcfd;
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
}

.quality-chip strong {
    font-variant-numeric: tabular-nums;
    color: var(--navy);
}

.quality-chip:hover,
.quality-chip.is-active {
    border-color: var(--teal);
    background: var(--teal-soft);
}

.quality-chip.is-active strong {
    color: var(--teal);
}

.missing-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.dup-group {
    margin-bottom: 16px;
}

.dup-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.dup-head h2 {
    margin-bottom: 4px;
}

.dup-head p {
    margin-bottom: 0;
}

.dup-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.sticky-actions {
    margin: 0 0 16px;
}

/* Inter-user chat */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}

.nav-badge[hidden],
.chat-unread[hidden] {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.chat-shell {
    display: grid;
    grid-template-columns: minmax(270px, 350px) minmax(0, 1fr);
    gap: 14px;
    height: calc(100vh - 250px);
    min-height: 480px;
    margin-bottom: 16px;
}

.chat-contacts,
.chat-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}

.chat-contacts-head,
.chat-panel-head {
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.chat-contacts-head h2 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-search {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.chat-search input {
    flex: 1;
    min-width: 0;
}

.chat-contact-list {
    flex: 1;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-y: auto;
}

.chat-contact {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.chat-contact:hover {
    background: #f7fafc;
    color: var(--text);
}

.chat-contact.is-active {
    background: var(--teal-soft);
    box-shadow: inset 3px 0 0 var(--teal);
}

.chat-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--navy);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chat-contact-main {
    flex: 1;
    min-width: 0;
}

.chat-contact-top {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.chat-contact-top strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.88rem;
}

.chat-role {
    flex: 0 0 auto;
    padding: 1px 6px;
    border-radius: 999px;
    background: #eef2f6;
    color: var(--muted);
    font-size: 0.68rem;
}

.chat-preview {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex: 0 0 auto;
}

.chat-time {
    color: var(--muted);
    font-size: 0.66rem;
    white-space: nowrap;
}

.chat-unread {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
}

.chat-partner {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-partner h2 {
    margin: 0;
    font-size: 1rem;
}

.chat-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.chat-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    overflow-y: auto;
    background: #fbfcfd;
}

.chat-message {
    display: flex;
    justify-content: flex-start;
}

.chat-message.is-mine {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: min(74%, 720px);
    padding: 8px 12px;
    border: 1px solid #e1e8ef;
    border-radius: 12px;
    background: #eef3f8;
    box-shadow: 0 1px 2px rgba(23, 50, 77, 0.05);
}

.chat-message.is-mine .chat-bubble {
    border-color: #cbe6e1;
    background: var(--teal-soft);
}

.chat-who {
    display: block;
    margin-bottom: 2px;
    color: var(--navy);
    font-size: 0.72rem;
    font-weight: 600;
}

.chat-bubble p {
    margin: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font-size: 0.88rem;
}

.chat-stamp {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.66rem;
}

.chat-new {
    padding: 0 6px;
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.chat-compose {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.chat-compose textarea {
    flex: 1;
    min-width: 0;
    min-height: 42px;
    max-height: 160px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    font-size: 0.88rem;
    resize: vertical;
}

.chat-compose textarea:focus {
    outline: 2px solid var(--teal);
    outline-offset: 1px;
}

.chat-error {
    margin: 0;
    padding: 0 16px 10px;
    color: var(--danger);
    font-size: 0.8rem;
}

.chat-empty,
.chat-placeholder {
    padding: 18px 16px;
}

.chat-placeholder {
    padding: 48px 24px;
    text-align: center;
}

.chat-readonly {
    margin: 0;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

@media (max-width: 900px) {
    .chat-shell {
        grid-template-columns: 1fr;
        height: auto;
    }

    .chat-contacts {
        max-height: 320px;
    }

    .chat-panel {
        min-height: 60vh;
    }

    .chat-bubble {
        max-width: 88%;
    }
}

/* Public pickup finder */
.is-public {
    background: #f4f7f9;
}

.public-actions {
    margin-left: auto;
}

.public-hero {
    margin-bottom: 16px;
}

.public-hero h1 {
    margin-bottom: 6px;
}

.public-search {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.public-errors {
    margin: 8px 0 0;
    padding-left: 20px;
}

.honeypot {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.qty-input {
    width: 72px;
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fbfcfd;
    font: inherit;
    text-align: right;
}

.public-notices {
    margin: 0 0 16px;
    padding: 0;
    border: 0;
}

.public-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.public-notice:last-child {
    border-bottom: 0;
}

.public-notice input {
    width: 16px;
    height: 16px;
    margin-top: 3px;
    accent-color: var(--teal);
}

.public-notice span {
    line-height: 1.5;
}

.public-notice strong {
    color: var(--navy);
}

.public-steps {
    margin: 0 0 10px;
    padding-left: 20px;
    line-height: 1.6;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Public payment and QR */
.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
    margin: 10px 0 0;
}

.account-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fbfcfd;
    color: var(--text);
    text-decoration: none;
}

.account-card:hover,
.account-card:focus-visible {
    border-color: var(--teal);
    background: var(--teal-soft);
}

.account-card strong {
    color: var(--navy);
}

.qr-panel {
    display: grid;
    grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
    gap: 18px;
    margin-top: 14px;
}

.qr-figure {
    text-align: center;
}

.qr-image {
    display: block;
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
}

.qr-details .kv {
    margin-bottom: 12px;
}

.qr-claim {
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.qr-settings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 12px;
}

.qr-admin-card {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fbfcfd;
}

.qr-admin-card h3 {
    margin: 0 0 6px;
    font-size: 1rem;
    color: var(--navy);
}

.qr-preview {
    display: block;
    width: 100%;
    max-width: 160px;
    margin: 8px 0;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.qr-admin-card form {
    margin-top: 8px;
}

@media (max-width: 760px) {
    .qr-panel {
        grid-template-columns: 1fr;
    }
}

/* ------------------------------------------------------------------ */
/* Installation wizard                                                 */
/* ------------------------------------------------------------------ */

.installer-page {
    background:
        radial-gradient(circle at 12% 0%, rgba(15, 118, 110, 0.10), transparent 34%),
        var(--bg);
}

.install-top {
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
}

.install-top-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(1020px, 100%);
    margin: 0 auto;
    padding: 13px var(--gutter);
}

.install-main {
    flex: 1;
    width: min(1020px, 100%);
    margin: 0 auto;
    padding: 26px var(--gutter) 42px;
}

.install-card {
    padding: 30px 34px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 18px 50px rgba(23, 50, 77, 0.10);
}

.install-head {
    margin-bottom: 20px;
}

.install-head h1 {
    margin-bottom: 8px;
}

.install-head .lede {
    max-width: 74ch;
    margin-bottom: 0;
}

.install-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
}

.install-grid > .field-wide,
.install-grid > .check {
    grid-column: 1 / -1;
}

.install-section {
    margin: 0 0 18px;
    padding: 18px 20px 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fdfefe;
}

.install-section legend {
    padding: 0 8px;
    color: var(--navy);
    font-size: 1rem;
    font-weight: 700;
}

.install-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--teal-soft);
    color: var(--teal);
    font-size: 0.78rem;
    font-weight: 700;
}

.install-note {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.88rem;
}

.installer-page .field select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fbfcfd;
    color: var(--text);
    font: inherit;
    font-size: 0.96rem;
}

.installer-page .field select:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
    background: #ffffff;
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 4px 0 14px;
    color: var(--navy);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.check input {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-top: 3px;
    accent-color: var(--teal);
}

.install-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.install-actions .btn {
    padding: 11px 20px;
}

.alert-list {
    margin: 6px 0 0;
    padding-left: 18px;
}

.req-list {
    display: grid;
    gap: 8px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
}

.req-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fdfefe;
}

.req-state {
    flex: 0 0 auto;
    min-width: 64px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-align: center;
    text-transform: uppercase;
}

.req-state.is-ok {
    background: #eef8f1;
    color: #166534;
}

.req-state.is-fail {
    background: #fdf1f0;
    color: #8f1d14;
}

.req-body {
    display: flex;
    flex-direction: column;
}

.req-body small {
    color: var(--muted);
}

.install-summary {
    margin: 4px 0 22px;
}

.install-next-title {
    margin-top: 4px;
}

.install-next {
    margin: 0 0 18px;
    padding-left: 22px;
    font-size: 0.94rem;
}

.install-next li {
    margin-bottom: 6px;
}

@media (max-width: 720px) {
    .install-card {
        padding: 22px 18px;
    }

    .install-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .install-grid > .field-wide {
        grid-column: auto;
    }
}

/* Quick stock adjustment grid */
.quick-table td {
    vertical-align: middle;
}

.quick-table input[type="text"] {
    width: 100%;
    min-width: 96px;
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fbfcfd;
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
}

.quick-table input[type="text"]:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
    background: #ffffff;
}

.quick-table tr.is-invalid td {
    background: #fff6f5;
}

.quick-table .row-warning {
    display: block;
    margin-top: 4px;
    color: #b42318;
}

.quick-table .row-warning[hidden] {
    display: none;
}

.quick-table th a {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.quick-table th a:hover {
    text-decoration: underline;
}

/* Owner notifications */
.topbar-inbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--navy);
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
}

.topbar-inbox:hover {
    border-color: var(--teal);
    color: var(--teal);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: none;
}

.chip:hover {
    border-color: var(--teal);
    color: var(--teal);
}

.chip.is-active {
    border-color: var(--teal);
    background: var(--teal);
    color: #ffffff;
}

.chip.is-active .badge {
    background: rgba(255, 255, 255, 0.24);
    color: #ffffff;
}

.notification-list {
    padding: 0;
}

.notification-item {
    padding: 16px var(--gutter);
    border-bottom: 1px solid var(--border);
}

.notification-item:last-child {
    border-bottom: 0;
}

.notification-item.is-unread {
    background: rgba(15, 118, 110, 0.05);
    box-shadow: inset 3px 0 0 var(--teal);
}

.notification-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.notification-head h2 {
    margin: 5px 0 0;
    font-size: 1.02rem;
    color: var(--navy);
}

.notification-body {
    color: var(--text);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.notification-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.notification-foot form {
    margin: 0;
}
