:root {
    --brand-blue: #01659A;
    --brand-blue-dark: #014f78;
    --brand-blue-soft: #e6f2f7;
    --brand-yellow: #FFD000;
    --brand-yellow-dark: #e6bb00;
    --surface: #ffffff;
    --surface-muted: #f5f7f9;
    --text: #1a2330;
    --text-muted: #5b6775;
    --border: #d7dee5;
    --danger: #b42318;
    --danger-soft: #fef3f2;
    --success: #067647;
    --success-soft: #ecfdf3;
    --warning: #b54708;
    --warning-soft: #fffaeb;
    --neutral: #475467;
    --neutral-soft: #f2f4f7;
    --info: #01659A;
    --info-soft: #e6f2f7;
    --accent: #0f766e;
    --accent-soft: #f0fdfa;
    --shadow: 0 10px 30px rgba(1, 101, 154, 0.08);
    --radius: 12px;
    --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

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

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface-muted);
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

.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;
}

/* Logo */
.brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-logo img {
    display: block;
    height: 48px;
    width: auto;
    object-fit: contain;
}

.brand-logo--header {
    display: block;
    width: 100%;
}

.brand-logo--header img {
    display: block;
    width: 100%;
    max-width: 175px;
    height: auto;
    margin-inline: auto;
    object-fit: contain;
    object-position: center;
}

.brand-logo-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    height: 48px;
    padding: 0 1rem;
    border: 2px dashed var(--brand-blue);
    border-radius: 8px;
    background: var(--brand-blue-soft);
    color: var(--brand-blue);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.brand-logo--header .brand-logo-placeholder {
    display: flex;
    width: 100%;
    min-width: 0;
    height: 64px;
    max-width: 175px;
    margin-inline: auto;
    padding: 0 0.5rem;
    font-size: 0.8rem;
    background: transparent;
    border-color: rgba(255, 208, 0, 0.65);
    color: #fff;
}

.brand-logo--guest {
    display: block;
    margin: 0;
    line-height: 0;
}

.brand-logo--guest img {
    display: block;
    width: min(210px, 100%);
    max-width: 100%;
    height: auto;
    object-fit: contain;
    object-position: left center;
}

.brand-logo--guest .brand-logo-placeholder {
    min-width: 160px;
    height: 52px;
    background: transparent;
    border-color: rgba(255, 208, 0, 0.65);
    color: #fff;
}

.brand-logo--login {
    justify-content: center;
    margin: 0 auto 0.35rem;
}

.brand-logo--login img {
    display: block;
    height: auto;
    width: auto;
    max-width: min(220px, 72vw);
    max-height: 88px;
    margin-inline: auto;
    object-fit: contain;
}

.brand-logo--login .brand-logo-placeholder {
    min-width: 180px;
    height: 72px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.65rem 1.25rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:focus-visible {
    outline: 3px solid var(--brand-yellow);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--brand-blue);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-blue-dark);
    text-decoration: none;
}

.btn-secondary {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-muted);
    text-decoration: none;
}

.btn-accent {
    background: var(--brand-yellow);
    color: var(--text);
}

.btn-accent:hover {
    background: var(--brand-yellow-dark);
    text-decoration: none;
}

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

.btn-danger:hover {
    background: #b42318;
    border-color: #b42318;
    color: #fff;
    text-decoration: none;
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--text);
}

.form-control {
    width: 100%;
    min-height: 44px;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(1, 101, 154, 0.18);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-error {
    margin-top: 0.4rem;
    color: var(--danger);
    font-size: 0.9rem;
}

.form-hint {
    margin-top: 0.35rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 3.25rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--brand-blue);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.4rem 0.55rem;
    border-radius: 6px;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    background: var(--brand-blue-soft);
    outline: none;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0.75rem 0 1.25rem;
}

.form-check input {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--brand-blue);
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #fecdca;
}

.alert-success {
    background: #ecfdf3;
    color: var(--success);
    border: 1px solid #abeec2;
}

/* Guest / login layout */
.guest-body {
    min-height: 100vh;
    margin: 0;
    background: var(--surface-muted);
}

.guest-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.guest-brand {
    position: relative;
    display: none;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    padding: clamp(2rem, 5vw, 4rem);
    color: #fff;
    background:
        radial-gradient(ellipse 80% 60% at 10% 15%, rgba(255, 208, 0, 0.18), transparent 55%),
        linear-gradient(155deg, #0173b0 0%, var(--brand-blue) 42%, var(--brand-blue-dark) 78%, #01324c 100%);
}

.guest-brand__motif {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.guest-brand__shape {
    position: absolute;
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
}

.guest-brand__shape--a {
    width: 112px;
    height: 78px;
    top: 12%;
    right: 14%;
    transform: rotate(-8deg);
}

.guest-brand__shape--b {
    width: 88px;
    height: 62px;
    top: 26%;
    right: 28%;
    transform: rotate(6deg);
    border-color: rgba(255, 208, 0, 0.35);
    background: rgba(255, 208, 0, 0.08);
}

.guest-brand__shape--c {
    width: 64px;
    height: 46px;
    bottom: 18%;
    right: 18%;
    transform: rotate(-4deg);
}

.guest-brand__route {
    position: absolute;
    left: 8%;
    right: 36%;
    bottom: 22%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 208, 0, 0.75), rgba(255, 255, 255, 0.35));
    border-radius: 999px;
}

.guest-brand__route::before,
.guest-brand__route::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand-yellow);
    transform: translateY(-50%);
    box-shadow: 0 0 0 4px rgba(255, 208, 0, 0.2);
}

.guest-brand__route::before {
    left: 18%;
}

.guest-brand__route::after {
    right: 8%;
}

.guest-brand__logo {
    position: absolute;
    top: clamp(1.5rem, 4vw, 2.75rem);
    left: clamp(1.5rem, 4vw, 2.75rem);
    z-index: 2;
    max-width: min(240px, 70%);
}

.guest-brand__content {
    position: relative;
    z-index: 1;
    max-width: 28rem;
}

.guest-brand__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 1.15rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.92);
}

.guest-brand__eyebrow::before {
    content: "";
    width: 2rem;
    height: 4px;
    border-radius: 999px;
    background: var(--brand-yellow);
}

.guest-brand__title {
    margin: 0 0 1rem;
    font-size: clamp(1.65rem, 2.4vw, 2.15rem);
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.guest-brand__lead {
    margin: 0 0 1.5rem;
    font-size: 1.05rem;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.9);
}

.guest-brand__points {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 0.65rem;
}

.guest-brand__points li {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.92);
}

.guest-brand__points li::before {
    content: "";
    flex: 0 0 auto;
    width: 0.55rem;
    height: 0.55rem;
    margin-top: 0.45rem;
    border-radius: 50%;
    background: var(--brand-yellow);
    box-shadow: 0 0 0 3px rgba(255, 208, 0, 0.2);
}

.guest-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.25rem, 4vw, 2.5rem);
    background:
        linear-gradient(180deg, #f7fafc 0%, var(--surface-muted) 100%);
}

.login-panel {
    width: 100%;
    max-width: 420px;
}

.login-card {
    width: 100%;
    background: var(--surface);
    border: 1px solid rgba(215, 222, 229, 0.95);
    border-radius: 16px;
    box-shadow:
        0 1px 2px rgba(26, 35, 48, 0.04),
        0 18px 40px rgba(1, 101, 154, 0.08);
    padding: clamp(1.5rem, 3vw, 2.25rem);
}

.login-card__header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-card__header h1 {
    margin: 0.85rem 0 0.4rem;
    font-size: 1.4rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--brand-blue);
}

.login-card__header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-form .form-group {
    margin-bottom: 1.05rem;
}

.login-form .form-label {
    font-weight: 600;
    color: var(--text);
}

.login-form .form-control {
    min-height: 46px;
    border-radius: 10px;
    border-color: #cfd8e1;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-form .form-control:hover {
    border-color: #b7c4d0;
}

.login-form .form-control:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(1, 101, 154, 0.16);
    outline: none;
}

.login-form .form-check {
    margin: 0.35rem 0 1.35rem;
}

.login-submit {
    min-height: 48px;
    border-radius: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 8px 18px rgba(1, 101, 154, 0.22);
}

.login-submit:hover {
    box-shadow: 0 10px 22px rgba(1, 79, 120, 0.28);
}

.login-submit:focus-visible {
    outline: 3px solid var(--brand-yellow);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .login-form .form-control,
    .login-submit {
        transition: none;
    }
}

/* App shell */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px 1fr;
}

.app-sidebar {
    background: var(--brand-blue);
    color: #fff;
    padding: 1.15rem 0.9rem 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.app-sidebar__brand {
    padding: 0.2rem 0.45rem 0.55rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.app-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    color: #fff;
    text-decoration: none;
    text-align: center;
}

.app-brand:hover {
    text-decoration: none;
    color: #fff;
}

.app-brand__logo {
    display: block;
    width: 65%;
    max-width: 175px;
    margin-inline: auto;
    line-height: 0;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}

.app-brand__name {
    display: block;
    margin: 0;
    font-size: 0.98rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.1;
    color: #fff;
}

.app-brand__tagline {
    display: block;
    margin: 0;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.78);
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0 0.15rem;
}

.app-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.72rem 0.9rem;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
}

.app-nav a:hover,
.app-nav a.is-active {
    background: rgba(255, 255, 255, 0.14);
    text-decoration: none;
}

.app-nav a.is-active {
    box-shadow: inset 3px 0 0 var(--brand-yellow);
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface-muted);
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 68px;
    padding: 0.85rem 1.5rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-topbar__title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.app-topbar h1 {
    margin: 0;
    font-size: 1.3rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--brand-blue);
}

.app-user-menu {
    position: relative;
    flex-shrink: 0;
}

.app-user-menu__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: min(220px, 42vw);
    min-height: 40px;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.app-user-menu__toggle:hover,
.app-user-menu.is-open .app-user-menu__toggle {
    border-color: rgba(1, 101, 154, 0.35);
    color: var(--brand-blue);
}

.app-user-menu__toggle:focus-visible {
    outline: 2px solid rgba(1, 101, 154, 0.45);
    outline-offset: 2px;
}

.app-user-menu__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-user-menu__chevron {
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    flex-shrink: 0;
    opacity: 0.7;
}

.app-user-menu.is-open .app-user-menu__chevron {
    transform: rotate(-135deg) translateY(-1px);
}

.app-user-menu__panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 50;
    min-width: 210px;
    padding: 0.45rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.app-user-menu__meta {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.55rem 0.65rem 0.7rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.35rem;
}

.app-user-menu__meta-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    word-break: break-word;
}

.app-user-menu__item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 40px;
    padding: 0.55rem 0.7rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.app-user-menu__item:hover,
.app-user-menu__item.is-active {
    background: var(--brand-blue-soft);
    color: var(--brand-blue);
    text-decoration: none;
}

.app-user-menu__item--danger:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.app-user-menu__logout {
    margin: 0;
}

.app-content {
    padding: 1.5rem 1.6rem 2rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.panel h2 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    color: var(--brand-blue);
}

.panel p {
    margin: 0;
    color: var(--text-muted);
}

.panel--welcome {
    max-width: 52rem;
    padding: 1.5rem 1.6rem;
}

.panel__eyebrow {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand-blue);
}

.panel--welcome h2 {
    margin-bottom: 0.65rem;
    font-size: 1.35rem;
    letter-spacing: -0.01em;
}

.panel__lead {
    max-width: 42rem;
    line-height: 1.55;
}

.panel__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 1.1rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--brand-blue-soft);
    color: var(--brand-blue);
}

.badge::before {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--brand-yellow);
}

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

.badge--success::before {
    background: var(--success);
}

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

.badge--warning::before {
    background: var(--warning);
}

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

.badge--danger::before {
    background: var(--danger);
}

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

.badge--neutral::before {
    background: var(--neutral);
}

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

.badge--info::before {
    background: var(--info);
}

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

.badge--accent::before {
    background: var(--accent);
}

.mobile-nav-toggle {
    display: none;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    min-height: 40px;
    padding: 0 0.85rem;
    font: inherit;
    font-weight: 600;
    color: var(--brand-blue);
    cursor: pointer;
}

@media (min-width: 900px) {
    .guest-shell {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    }

    .guest-brand {
        display: flex;
    }

    .guest-main {
        padding-inline: clamp(2rem, 5vw, 4rem);
    }
}

@media (min-width: 1100px) {
    .guest-shell {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

@media (max-width: 899px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        display: none;
    }

    .app-sidebar.is-open {
        display: flex;
        position: fixed;
        inset: 0 auto 0 0;
        width: min(270px, 88vw);
        z-index: 40;
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.2);
    }

    .mobile-nav-toggle {
        display: inline-flex;
        align-items: center;
    }

    .app-topbar {
        padding: 0.85rem 1rem;
        min-height: 60px;
    }

    .app-topbar h1 {
        font-size: 1.15rem;
    }

    .app-content {
        padding: 1.1rem 1rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 1.35rem 1.1rem 1.5rem;
        border-radius: 14px;
    }

    .login-card__header h1 {
        font-size: 1.25rem;
    }

    .brand-logo--login img {
        height: 60px;
    }

    .app-brand__name {
        font-size: 1rem;
    }

    .app-user-menu__toggle {
        max-width: min(170px, 46vw);
        min-height: 38px;
        padding-inline: 0.65rem;
    }
}

/* Compact brand strip on smaller tablets before the two-column split */
@media (max-width: 899px) {
    .guest-brand {
        display: flex;
        min-height: auto;
        padding: 1.35rem 1.25rem 1.5rem;
    }

    .guest-brand__logo {
        position: static;
        max-width: min(200px, 72%);
        margin-bottom: 0.85rem;
    }

    .guest-brand__motif,
    .guest-brand__points {
        display: none;
    }

    .guest-brand__title {
        font-size: 1.25rem;
        margin-bottom: 0.45rem;
    }

    .guest-brand__lead {
        margin: 0;
        font-size: 0.92rem;
    }

    .guest-main {
        align-items: flex-start;
        padding-top: 1.5rem;
        padding-bottom: 2rem;
    }
}

/* Page toolbar and tables */
.search-with-scan {
    position: relative;
    display: flex;
    align-items: stretch;
}

.search-with-scan__input {
    padding-right: 2.85rem;
}

.search-with-scan__btn {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--brand-blue);
    cursor: pointer;
    padding: 0;
}

.search-with-scan__btn:hover {
    background: var(--brand-blue-soft);
}

.barcode-scan-reader {
    width: 100%;
    min-height: 240px;
    overflow: hidden;
    border-radius: 8px;
    background: #0f172a;
}

.barcode-scan-reader video {
    width: 100% !important;
    border-radius: 8px;
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.page-toolbar__text {
    margin: 0;
    color: var(--text-muted);
}

.panel--flush {
    padding: 0;
    overflow: hidden;
}

.table-results {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    flex-wrap: wrap;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fbfd;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.table-results__meta {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.table-results__trailing {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.45rem;
    margin-left: auto;
    font-weight: 500;
    text-align: right;
}

.table-results__quick-label {
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 0.15rem;
}

.table-results__quick-sep {
    color: var(--text-muted);
    font-weight: 400;
}

.table-results__trailing a {
    font-weight: 600;
}

.dashboard-panel > .table-results {
    margin: 0 -1.25rem 0.75rem;
    border-top: 1px solid var(--border);
}

.panel:not(.panel--flush) > .table-results {
    margin: 0.5rem 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.table-results__range {
    font-weight: 500;
    color: var(--text-muted);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table th {
    background: var(--brand-blue-soft);
    color: var(--brand-blue);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.pagination-wrap {
    margin-top: 1rem;
    padding: 0 0.25rem 0.25rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.pagination__summary {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.pagination__list {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--brand-blue);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.2;
}

a.pagination__link:hover {
    background: var(--brand-blue-soft);
    border-color: rgba(1, 101, 154, 0.35);
}

.pagination__item.is-active .pagination__link {
    background: var(--brand-blue);
    border-color: var(--brand-blue);
    color: #fff;
}

.pagination__item.is-disabled .pagination__link {
    color: #94a3b8;
    background: #f8fafc;
    cursor: default;
}

/* Safety: never let leftover pagination SVGs blow up the layout */
.pagination-wrap svg,
.pagination svg {
    width: 1rem;
    height: 1rem;
    max-width: 1rem;
    max-height: 1rem;
}

@media (max-width: 640px) {
    .data-table thead {
        display: none;
    }

    .data-table tr {
        display: block;
        padding: 0.85rem 1rem;
        border-bottom: 1px solid var(--border);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        border: 0;
        padding: 0.35rem 0;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
    }
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.config-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    color: inherit;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.config-card:hover {
    border-color: var(--brand-blue);
    text-decoration: none;
    box-shadow: inset 0 -3px 0 var(--brand-yellow);
}

.config-card h3 {
    margin: 0 0 0.35rem;
    color: var(--brand-blue);
    font-size: 1.05rem;
}

.config-card p {
    margin: 0;
    color: var(--text-muted);
}

.link-button {
    border: 0;
    background: transparent;
    color: var(--brand-blue);
    font: inherit;
    cursor: pointer;
    padding: 0;
    margin-left: 0.75rem;
}

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

.leg-card {
    border-left: 4px solid var(--brand-yellow);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
}

.filter-panel__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.85rem 1rem;
}

.filter-panel__search {
    flex: 1 1 240px;
    min-width: min(100%, 240px);
}

.filter-panel__bar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.filter-panel__advanced {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.detail-list {
    margin: 0;
}

.detail-list > div {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
}

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

.detail-list dt {
    margin: 0;
    color: var(--text-muted);
    font-weight: 600;
}

.detail-list dd {
    margin: 0;
}

.history-timeline__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 0.85rem;
}

.history-timeline__header h2 {
    margin: 0;
}

.history-timeline__convention {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.history-item {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
}

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

.history-item__meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.55rem;
}

.history-item p {
    margin: 0;
}

.history-item__details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.45rem 1rem;
    margin: 0;
}

.history-item__details > div {
    min-width: 0;
}

.history-item__details dt {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.history-item__details dd {
    margin: 0.15rem 0 0;
    color: var(--text);
    font-size: 0.92rem;
}

.history-item__notes {
    grid-column: 1 / -1;
}

.history-item__payload {
    margin-top: 0.65rem;
    font-size: 0.88rem;
}

.history-item__payload ul,
.audit-payload {
    margin: 0.4rem 0 0;
    padding-left: 1.1rem;
}

.audit-payload {
    font-size: 0.85rem;
}

.decision-actions {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.decision-actions .btn {
    min-height: 34px;
    padding: 0.35rem 0.7rem;
    font-size: 0.82rem;
    white-space: nowrap;
    flex: 0 0 auto;
}

.modal[hidden] {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(26, 35, 48, 0.45);
}

.modal__dialog {
    position: relative;
    z-index: 1;
    width: min(480px, 100%);
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.35rem;
}

.modal__dialog h2 {
    margin: 0 0 0.5rem;
    color: var(--brand-blue);
    font-size: 1.15rem;
}

.modal__dialog p {
    margin: 0 0 1rem;
    color: var(--text);
}

.route-previews {
    display: grid;
    gap: 0.5rem;
    margin: 0.75rem 0 1rem;
}

.route-preview {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    background: var(--surface-muted);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.route-preview summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--brand-blue);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.route-preview__selected-tag {
    display: none;
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--success);
    background: #dcfae6;
    border: 1px solid #abefc6;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
}

.route-preview.is-selected {
    border-color: #079455;
    background: #ecfdf3;
    box-shadow: inset 0 0 0 1px rgba(7, 148, 85, 0.25);
}

.route-preview.is-selected summary {
    color: var(--success);
}

.route-preview.is-selected .route-preview__selected-tag {
    display: inline-flex;
}

.route-preview ol {
    margin: 0.55rem 0 0;
    padding-left: 1.25rem;
}

.route-selected-banner {
    margin-bottom: 0.85rem;
}

/* Dashboard */
.dashboard {
    display: grid;
    gap: 1.15rem;
}

.dashboard__welcome {
    max-width: none;
}

.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: 0.85rem;
}

.dashboard-kpi {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.05rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    min-height: 108px;
}

.dashboard-kpi:hover {
    border-color: rgba(1, 101, 154, 0.35);
    text-decoration: none;
}

.dashboard-kpi--danger {
    border-color: #fecdca;
    background: var(--danger-soft);
}

.dashboard-kpi--danger:hover {
    border-color: var(--danger);
}

.dashboard-kpi__label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1.3;
}

.dashboard-kpi__value {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--brand-blue);
    line-height: 1.1;
}

.dashboard-kpi--danger .dashboard-kpi__value {
    color: var(--danger);
}

.dashboard-kpi__hint {
    margin-top: auto;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(1, 101, 154, 0.85);
}

.report-pct {
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

.dashboard-kpi--danger .dashboard-kpi__hint {
    color: var(--danger);
}

.form-hint--danger {
    color: var(--danger);
    font-weight: 600;
}

.data-table tbody tr.is-alert > td {
    background: var(--danger-soft);
}

.data-table tbody tr.is-alert:hover > td {
    background: #fee4e2;
}

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

.dashboard-panel__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.dashboard-panel__header h2 {
    margin: 0;
}

.dashboard-panel__header a {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.dashboard-empty {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.status-bars {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.55rem;
}

.status-bars__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.2rem;
    font-size: 0.86rem;
}

.status-bars__meta a {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.status-bars__meta a:hover {
    color: var(--brand-blue);
    text-decoration: underline;
}

.status-bars__count {
    font-weight: 700;
    color: var(--brand-blue);
}

.status-bars__track {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    overflow: hidden;
}

.status-bars__fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand-blue), #0284c7);
    min-width: 0;
}

.data-table--compact th,
.data-table--compact td {
    padding: 0.55rem 0.45rem;
    font-size: 0.9rem;
}

.table-actions {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.table-actions form {
    margin: 0;
    flex: 0 0 auto;
}

.btn-table {
    min-height: 34px;
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    white-space: nowrap;
    flex: 0 0 auto;
}

.data-table th:last-child,
.data-table td[data-label="Actions"] {
    white-space: nowrap;
    width: 1%;
}

@media (max-width: 899px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .dashboard-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-kpi {
        min-height: 96px;
        padding: 0.85rem 0.8rem;
    }

    .dashboard-kpi__value {
        font-size: 1.4rem;
    }
}

.profile-panel {
    max-width: none;
    width: 100%;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 2rem;
    align-items: start;
}

.profile-grid__section {
    min-width: 0;
    padding: 1.1rem 1.15rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafbfc;
}

.profile-grid__heading {
    margin: 0 0 1rem;
    font-size: 1rem;
    color: var(--brand-blue);
}

.profile-panel__actions {
    margin-top: 1.35rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

@media (max-width: 899px) {
    .profile-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}
