:root {
    color-scheme: light;
    --ink: #17202a;
    --muted: #6b7280;
    --line: #dfe4ea;
    --surface: #ffffff;
    --page: #f4f6f8;
    --brand: #075aa5;
    --brand-strong: #033f78;
    --court: #c69113;
    --court-strong: #9d6b07;
    --danger: #b91c1c;
    --shadow: 0 16px 48px rgba(23, 32, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--page);
    color: var(--ink);
}

button,
a {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 16px;
    background: #121820;
    color: #eef3f8;
}

.brand {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 52px;
    margin-bottom: 28px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 1px solid rgba(198, 145, 19, 0.24);
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(7, 90, 165, 0.16);
}

.brand-mark img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    display: block;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: #a8b3c2;
    font-size: 13px;
}

.nav-list {
    display: grid;
    gap: 6px;
}

.nav-list a {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    color: #cbd5e1;
}

.nav-list a:hover,
.nav-list a.is-active {
    background: #243142;
    color: #ffffff;
}

.main-area {
    min-width: 0;
}

.topbar {
    min-height: 88px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
}

.topbar h1,
.section-heading h2,
.panel h3 {
    margin: 0;
    letter-spacing: 0;
}

.topbar h1 {
    font-size: 24px;
    line-height: 1.2;
}

.eyebrow {
    margin: 0 0 3px;
    color: var(--brand-strong);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    margin-left: auto;
    padding: 0 12px;
    border: 1px solid #b7d8d3;
    border-radius: 999px;
    color: var(--brand-strong);
    background: #edf7ff;
    font-size: 14px;
    font-weight: 700;
}

.status-pill:hover {
    border-color: #7fb8d8;
    color: var(--brand);
}

.status-pill span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--brand);
}

.logout-form {
    margin: 0;
}

.text-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.text-button:hover {
    border-color: #b8d4ef;
    color: var(--brand-strong);
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: var(--brand);
    color: #ffffff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.primary-button:hover {
    background: var(--brand-strong);
}

.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fef2f2;
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
}

.danger-button:hover {
    border-color: #fca5a5;
    background: #fee2e2;
}

.icon-button {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
}

.menu-button span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 4px auto;
    background: currentColor;
}

.page-content {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 32px;
}

.overview {
    display: grid;
    gap: 24px;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
}

.section-heading h2 {
    font-size: 28px;
    line-height: 1.2;
}

.section-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.segmented-control {
    display: inline-grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    min-height: 40px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #edf1f5;
}

.segmented-control button {
    min-width: 84px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-weight: 700;
}

.segmented-control button.is-active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 2px 10px rgba(23, 32, 42, 0.08);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.metric-card,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.metric-card {
    min-height: 142px;
    padding: 18px;
    display: grid;
    align-content: space-between;
}

.metric-card span,
.metric-card small {
    color: var(--muted);
}

.metric-card strong {
    display: block;
    font-size: 26px;
    line-height: 1.2;
}

.workbench {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
    gap: 16px;
}

.panel {
    padding: 22px;
}

.panel h3 {
    margin-bottom: 16px;
    font-size: 20px;
}

.accent-panel {
    border-color: #efd899;
    background: #fff9e8;
}

.accent-panel p {
    margin: 0;
    color: #5f4309;
}

.check-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.check-list li {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    color: #334155;
}

.check-list span {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--brand);
    position: relative;
}

.check-list span::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 3px;
    width: 5px;
    height: 9px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Overview dashboard */
.dashboard { display: grid; gap: 24px; }
.dashboard-heading { align-items: center; }
.section-description { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.dashboard-filter { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--brand-strong); }
.dashboard-filter select { border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.dashboard-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.summary-card { display: flex; gap: 14px; align-items: flex-start; min-height: 132px; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.summary-card__icon { display: grid; flex: 0 0 auto; place-items: center; width: 40px; height: 40px; border-radius: 10px; font-size: 20px; font-weight: 800; }
.summary-card--blue .summary-card__icon { background: #e8f3fc; color: var(--brand); }.summary-card--gold .summary-card__icon { background: #fff5dc; color: var(--court-strong); }.summary-card--green .summary-card__icon { background: #e8f7ee; color: #18794e; }
.summary-card__label { display: block; color: var(--muted); font-size: 13px; font-weight: 700; }.summary-card strong { display: block; margin: 3px 0; font-size: 28px; line-height: 1.2; }.summary-card small { color: var(--muted); font-size: 12px; }.summary-card small b { color: #18794e; }
.dashboard-charts { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(330px, .9fr); gap: 16px; }.dashboard-panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }.panel-heading { display: flex; justify-content: space-between; gap: 16px; }.panel-heading h3, .invoice-section__heading h3 { margin: 0; font-size: 18px; }.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }.panel-total { color: var(--brand-strong); font-size: 20px; white-space: nowrap; }.panel-total small { color: var(--muted); font-size: 12px; font-weight: 600; }
.bar-chart { position: relative; height: 244px; margin-top: 22px; padding-left: 30px; }.bar-chart__grid { position: absolute; inset: 0 0 28px; display: flex; flex-direction: column; justify-content: space-between; border-bottom: 1px solid #dbe3eb; background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(20% - 1px), #edf1f5 calc(20% - 1px), #edf1f5 20%); }.bar-chart__grid span { position: relative; left: -12px; top: -9px; color: #94a3b8; font-size: 11px; }.bar-chart__bars { position: absolute; inset: 0 0 0 30px; display: flex; align-items: end; justify-content: space-around; }.bar-chart__item { display: grid; grid-template-rows: 24px 1fr 24px; align-items: end; justify-items: center; width: 42px; height: 100%; }.bar-chart__value { color: var(--brand-strong); font-size: 11px; font-weight: 800; opacity: 0; transition: opacity .15s; }.bar-chart__bar { display: block; width: 28px; max-height: calc(100% - 24px); border-radius: 6px 6px 2px 2px; align-self: end; background: #78add8; transition: background .15s, transform .15s; }.bar-chart__item:hover .bar-chart__bar { background: var(--brand); transform: translateY(-2px); }.bar-chart__item:hover .bar-chart__value { opacity: 1; }.bar-chart__day { align-self: end; color: var(--muted); font-size: 12px; }
.type-chart-content { display: grid; justify-items: center; gap: 24px; padding-top: 24px; }.donut-chart { display: grid; place-items: center; width: 162px; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(var(--brand) 0 62%, var(--court) 62% 100%); }.donut-chart > div { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; width: 112px; aspect-ratio: 1; border-radius: 50%; background: var(--surface); text-align: center; }.donut-chart strong { font-size: 24px; line-height: 1; }.donut-chart span { color: var(--muted); font-size: 12px; line-height: 1; }.chart-legend { width: 100%; display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }.chart-legend li { display: grid; grid-template-columns: 10px 1fr auto; gap: 9px; align-items: center; color: #334155; font-size: 14px; }.chart-legend li small { display: block; color: var(--muted); font-size: 11px; }.legend-dot { width: 10px; height: 10px; border-radius: 50%; }.legend-dot--blue { background: var(--brand); }.legend-dot--gold { background: var(--court); }
.invoice-section { display: grid; gap: 14px; }.invoice-section__heading { display: flex; align-items: end; justify-content: space-between; }.invoice-section__heading .eyebrow { margin-bottom: 2px; }.invoice-section__heading a { color: var(--brand); font-size: 13px; font-weight: 800; }.invoice-section__heading a span { margin-left: 4px; }.invoice-status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }.invoice-status-card { min-height: 138px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }.invoice-status-card > div { display: flex; align-items: center; gap: 8px; color: #475569; font-size: 13px; font-weight: 700; }.invoice-status-card__icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 7px; font-weight: 800; }.invoice-status-card strong { display: block; margin: 13px 0 2px; font-size: 26px; line-height: 1; }.invoice-status-card small { color: var(--muted); font-size: 12px; }.invoice-status-card--pending { border-top: 3px solid #d79c1c; }.invoice-status-card--pending .invoice-status-card__icon { background: #fff5dc; color: #a36d00; }.invoice-status-card--sent { border-top: 3px solid #4d91c7; }.invoice-status-card--sent .invoice-status-card__icon { background: #e8f3fc; color: var(--brand); }.invoice-status-card--paid { border-top: 3px solid #3ca66a; }.invoice-status-card--paid .invoice-status-card__icon { background: #e8f7ee; color: #18794e; }

.auth-body {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(7, 90, 165, 0.12), rgba(198, 145, 19, 0.10)),
        var(--page);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-heading {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    margin-bottom: 24px;
}

.auth-heading h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.2;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-form label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 700;
}

.auth-form input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    color: var(--ink);
    font: inherit;
}

.auth-form input:focus {
    outline: 3px solid #b8d4ef;
    border-color: var(--brand);
    background: var(--surface);
}

.auth-form button {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    background: var(--brand);
    color: #ffffff;
    cursor: pointer;
    font-weight: 800;
}

.auth-form button:hover {
    background: var(--brand-strong);
}

.turnstile-widget {
    min-height: 65px;
}

.alert {
    margin-bottom: 18px;
    padding: 12px;
    border-radius: 8px;
    font-weight: 700;
}

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

.alert-success {
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.profile-page {
    display: grid;
    gap: 24px;
}

.profile-panel {
    max-width: 640px;
}

.profile-form {
    display: grid;
    gap: 16px;
}

.shipment-form-section {
    display: grid;
    gap: 16px;
    margin: 0;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.shipment-wizard-progress {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.shipment-wizard-progress--four {
    grid-template-columns: repeat(4, 1fr);
}

.shipment-wizard-progress li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.shipment-wizard-progress li span {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface);
}

.shipment-wizard-progress li.is-active,
.shipment-wizard-progress li.is-complete {
    color: var(--brand-strong);
}

.shipment-wizard-progress li.is-active span,
.shipment-wizard-progress li.is-complete span {
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
}

.shipment-customer-summary {
    display: grid;
    gap: 3px;
    padding: 14px 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
}

.shipment-customer-summary__label {
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

.shipment-customer-summary strong {
    color: #1e3a5f;
}

.shipment-customer-summary > span:last-child {
    color: #475569;
    font-size: 13px;
}

.shipment-detail-tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.shipment-detail-tabs button { padding: 10px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.shipment-detail-tabs button.is-active { border-color: var(--brand); color: var(--brand-strong); }
.shipment-status-modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; }
.shipment-status-modal__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.shipment-status-modal__content { position: relative; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; }
[x-cloak] { display: none !important; }

.primary-button:disabled { cursor: wait; opacity: .7; }
.status-attachments { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }.status-attachments img { width:72px; height:72px; object-fit:cover; border-radius:7px; border:1px solid var(--line); }

.profile-form label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 700;
}

.profile-form input,
.profile-form select,
.profile-form textarea,
.filter-form input,
.filter-form select {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    color: var(--ink);
    font: inherit;
}

.profile-form input[type="file"] {
    height: auto;
    min-height: 54px;
    padding: 6px 10px;
    line-height: 1.2;
}

.profile-form input[type="file"]::file-selector-button {
    margin: 0 12px 0 0;
    padding: 8px 12px;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.profile-form textarea {
    min-height: 92px;
    padding: 10px 12px;
    resize: vertical;
}

.profile-form input,
.profile-form select,
.filter-form input,
.filter-form select {
    height: 44px;
    align-self: start;
}

.form-grid label {
    align-content: start;
}

.profile-form input:disabled {
    color: var(--muted);
    background: #edf1f5;
}

.profile-form input:read-only,
.profile-form textarea:read-only {
    color: var(--muted);
    background: #edf1f5;
}

.profile-form input:focus,
.profile-form select:focus,
.profile-form textarea:focus,
.filter-form input:focus,
.filter-form select:focus {
    outline: 3px solid #b8d4ef;
    border-color: var(--brand);
    background: var(--surface);
}

.form-divider {
    height: 1px;
    background: var(--line);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

.users-page {
    display: grid;
    gap: 24px;
}

.users-page .section-heading {
    align-items: center;
}

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

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

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

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

.data-table th {
    color: var(--muted);
    background: #f8fafc;
    font-size: 13px;
    font-weight: 800;
}

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

.actions-column {
    width: auto;
    text-align: right !important;
    white-space: nowrap;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.row-actions > * {
    flex: 0 0 auto;
}

.row-actions form {
    margin: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
}

.status-badge.is-active {
    background: #f0fdf4;
    color: #166534;
}

.status-badge.is-disabled {
    background: #f1f5f9;
    color: #64748b;
}

.quotation-status-draft { background: #fff7ed; color: #b45309; }
.quotation-status-sent { background: #e8f3fc; color: #075aa5; }
.quotation-status-accepted { background: #e8f7ee; color: #18794e; }
.quotation-status-rejected { background: #fef2f2; color: #b91c1c; }
.quotation-status-expired { background: #f1f5f9; color: #64748b; }
.quotation-status-cancelled { background: #f3f4f6; color: #4b5563; }

.filter-form,
.form-grid {
    display: grid;
    gap: 16px;
}

.filter-form {
    grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, 1fr)) auto;
    align-items: end;
}

.filter-form label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 700;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.user-filter-form {
    grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(150px, 1fr)) auto;
}

.user-filter-form .filter-actions {
    justify-content: flex-end;
}

/* Roles & Permissions page */
.roles-layout {
    display: grid;
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.roles-sidebar {
    display: grid;
    gap: 16px;
    position: sticky;
    top: 24px;
}

.roles-panel h3,
.create-role-panel h3 {
    margin: 0;
    font-size: 17px;
}

.roles-panel__heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.roles-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: #edf1f5;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.role-list {
    display: grid;
    gap: 6px;
}

.role-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
}

.role-item:hover {
    background: #f8fafc;
}

.role-item:focus-visible {
    outline: 3px solid #b8d4ef;
    outline-offset: 1px;
}

.role-item.is-active {
    border-color: #b8d4ef;
    background: #eef6fd;
}

.role-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #e3eefb;
    color: var(--brand-strong);
    font-size: 15px;
    font-weight: 800;
}

.role-item.is-active .role-avatar {
    background: var(--brand);
    color: #ffffff;
}

.role-avatar--large {
    width: 46px;
    height: 46px;
    font-size: 18px;
}

.role-item__text {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.role-item__text strong {
    font-size: 15px;
}

.role-item__text small {
    color: var(--muted);
    font-size: 12px;
}

.role-item__chevron {
    width: 9px;
    height: 9px;
    margin-left: auto;
    border-top: 2px solid #cbd5e1;
    border-right: 2px solid #cbd5e1;
    border-radius: 1px;
    transform: rotate(45deg);
}

.role-item.is-active .role-item__chevron {
    border-color: var(--brand);
}

.create-role-form {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.create-role-form label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 700;
}

.create-role-form input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    color: var(--ink);
    font: inherit;
}

.create-role-form input:focus {
    outline: 3px solid #b8d4ef;
    border-color: var(--brand);
    background: var(--surface);
}

.create-role-form .field-hint {
    color: var(--muted);
    font-size: 12px;
}

.create-role-form .primary-button {
    width: 100%;
    min-height: 44px;
}

.roles-editor {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.roles-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.roles-editor-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.roles-editor-title h3 {
    margin: 0;
    font-size: 20px;
}

.roles-editor-title p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.roles-editor-tools {
    display: flex;
    align-items: center;
    gap: 10px;
}

.permission-search {
    display: block;
}

.permission-search input {
    width: 230px;
    min-height: 40px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='9' cy='9' r='6' fill='none' stroke='%2394a3b8' stroke-width='2'/%3E%3Cpath d='M13.5 13.5 17 17' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 12px center / 16px 16px;
    color: var(--ink);
    font: inherit;
}

.permission-search input:focus {
    outline: 3px solid #b8d4ef;
    border-color: var(--brand);
    background-color: var(--surface);
}

.permission-counter {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: #e8f1fb;
    color: #1d4f7a;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.roles-note {
    margin: 0;
    padding: 12px 16px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a5f;
    font-size: 14px;
    font-weight: 600;
}

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

.permission-card {
    padding: 0;
    overflow: hidden;
}

.permission-card__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}

.permission-card__header h3 {
    margin: 0;
    font-size: 16px;
}

.permission-card__count {
    padding: 2px 9px;
    border-radius: 999px;
    background: #edf1f5;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.permission-card__toggle {
    margin-left: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--brand);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.permission-card__toggle:hover {
    color: var(--brand-strong);
    text-decoration: underline;
}

.permission-card__body {
    display: grid;
    gap: 2px;
    padding: 10px;
}

.permission-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.permission-option:hover {
    border-color: var(--line);
    background: #f8fafc;
}

.permission-option:has(input:checked) {
    border-color: #b8d4ef;
    background: #eef6fd;
}

.permission-option input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    display: grid;
    place-content: center;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
}

.permission-option input[type="checkbox"]:checked {
    border-color: var(--brand);
    background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / 12px 12px;
}

.permission-option input[type="checkbox"]:focus-visible {
    outline: 3px solid #b8d4ef;
    outline-offset: 1px;
}

.permission-option input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.permission-option:has(input:disabled) {
    cursor: default;
}

.permission-option__text {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.permission-option__label {
    font-size: 14px;
    font-weight: 600;
}

.permission-option__text code {
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
}

.permission-flag {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #fff5dc;
    color: #a36d00;
    font-size: 11px;
    font-weight: 800;
    vertical-align: middle;
}

.roles-empty {
    color: var(--muted);
    text-align: center;
}

.roles-savebar {
    position: sticky;
    bottom: 16px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow);
}

.roles-savebar__status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
}

.roles-savebar__status.is-dirty {
    color: var(--court-strong);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
}

.status-dot--ok {
    background: #22a06b;
}

.status-dot--warn {
    background: #d79c1c;
}

.roles-savebar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.quotation-filter-form {
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px) auto;
}

.quotation-filter-form .filter-actions {
    justify-content: flex-end;
}

.customer-filter-form {
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px) auto;
}

.shipment-filter-form {
    grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(160px, 220px)) auto;
}

.region-filter-form {
    padding: 20px;
    grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(140px, 180px)) auto;
}

.master-grid > .pagination {
    grid-column: 2;
}

.customer-selector {
    width: 100%;
}

.customer-selector .ts-control {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    cursor: text;
}

.customer-selector .ts-control > input {
    flex: 1 1 160px !important;
    width: 160px !important;
    min-width: 160px !important;
    min-height: 0;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink) !important;
    -webkit-text-fill-color: var(--ink);
    caret-color: var(--brand-strong) !important;
    opacity: 1 !important;
    align-self: center;
    line-height: normal;
}

.customer-selector .ts-control:focus-within {
    outline: 3px solid #b8d4ef;
    border-color: var(--brand);
    background: var(--surface);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-link,
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    border-radius: 8px;
    font-weight: 700;
}

.pagination-link {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
}

.pagination-link:hover {
    border-color: #b8d4ef;
    color: var(--brand-strong);
}

.pagination-link.is-current {
    border: 1px solid var(--brand);
    background: var(--brand);
    color: #ffffff;
}

.member-id {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e8f1fb;
    color: #1d4f7a;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    vertical-align: middle;
}

.region-parent-badge {
    display: table;
    margin: 6px 0 0;
}

.text-button.is-disabled {
    color: #94a3b8;
    cursor: not-allowed;
}

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

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

.span-two {
    grid-column: 1 / -1;
}

.three-columns .subject-field {
    grid-column: span 2;
}

.invoice-form-panel {
    max-width: 980px;
}

.invoice-tabs {
    display: inline-grid;
    grid-template-columns: repeat(4, minmax(110px, 1fr));
    gap: 3px;
    width: min(620px, 100%);
    min-height: 44px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #edf1f5;
}

.invoice-tabs button,
.invoice-tabs span {
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-weight: 800;
}

.invoice-tabs button { cursor: pointer; }

.invoice-tabs button.is-active,
.invoice-tabs span.is-active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 2px 10px rgba(23, 32, 42, 0.08);
}

.invoice-tab-panel {
    display: grid;
    gap: 18px;
}

.invoice-item {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

.item-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.item-heading h3 {
    margin: 0;
}

.item-heading.compact {
    min-height: 40px;
}

.invoice-summary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.7fr);
    gap: 16px;
}

.master-grid {
    display: grid;
    grid-template-columns: minmax(320px, 0.45fr) minmax(0, 1fr);
    gap: 16px;
}

/* Master tables must fit their panel without a horizontal scrollbar. */
.master-page .data-table {
    min-width: 0;
    table-layout: fixed;
}

.master-page .data-table th,
.master-page .data-table td {
    overflow-wrap: anywhere;
}

.master-service-table .master-service-name-column {
    width: 20%;
}

.master-service-table .master-service-status-column {
    width: 14%;
}

.master-service-table .actions-column {
    width: 180px;
}

.master-page .master-stage-table {
    table-layout: auto;
}

.master-stage-table .master-stage-content-column,
.master-stage-table .master-stage-status-column,
.master-stage-table .actions-column {
    width: 1%;
    overflow-wrap: normal;
    white-space: nowrap;
}

.master-region-table .master-region-number-column {
    width: 64px;
}

.master-region-table .master-region-level-column {
    width: 15%;
}

.master-region-table .master-region-status-column {
    width: 14%;
}

.master-region-table .actions-column {
    width: 110px;
}

.detail-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.detail-list div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

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

.detail-list dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
    text-align: right;
}

.muted-text {
    display: block;
    color: var(--muted);
}

.resi-preview {
    display: grid;
    gap: 4px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid #b8d4ef;
    border-radius: 8px;
    background: #eff6ff;
}

.resi-preview span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.resi-preview strong {
    color: var(--brand-strong);
    font-size: 22px;
}

.timeline-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline-list li {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 12px;
    padding: 0 0 18px;
    position: relative;
}

.timeline-list li::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 18px;
    bottom: 0;
    width: 2px;
    background: var(--line);
}

.timeline-list li:last-child {
    padding-bottom: 0;
}

.timeline-list li:last-child::before {
    display: none;
}

.timeline-list li > span {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--brand);
    margin-top: 2px;
    position: relative;
    z-index: 1;
}

.timeline-list strong,
.timeline-list small,
.timeline-list em {
    display: block;
}

.timeline-list small,
.timeline-list em {
    color: var(--muted);
}

.timeline-list p {
    margin: 8px 0 0;
}

.empty-cell {
    color: var(--muted);
    text-align: center !important;
}

.left-actions {
    justify-content: flex-start;
}

.invoice-status-draft {
    background: #eff6ff;
    color: #1d4ed8;
}

.invoice-status-issued {
    background: #fef9c3;
    color: #854d0e;
}

.invoice-status-paid {
    background: #f0fdf4;
    color: #166534;
}

.invoice-status-cancelled {
    background: #f1f5f9;
    color: #64748b;
}

[x-cloak] {
    display: none !important;
}

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

    .sidebar {
        position: fixed;
        z-index: 20;
        inset: 0 auto 0 0;
        width: 264px;
        transform: translateX(-100%);
        transition: transform 180ms ease;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .icon-button {
        display: block;
        flex: 0 0 auto;
    }

    .metric-grid,
    .workbench,
    .master-grid,
    .filter-form,
    .invoice-summary-grid,
    .dashboard-summary,
    .invoice-status-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-charts,
    .roles-layout {
        grid-template-columns: 1fr;
    }

    .roles-sidebar {
        position: static;
    }

    .role-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 700px) {
    .topbar {
        padding: 14px 18px;
    }

    .status-pill {
        display: none;
    }

    .page-content {
        padding: 22px 18px;
    }

    .section-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .section-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .segmented-control {
        width: 100%;
    }

    .segmented-control button,
    .invoice-tabs button,
    .invoice-tabs span {
        min-width: 0;
    }

    .invoice-tabs {
        width: 100%;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-grid,
    .workbench,
    .master-grid,
    .filter-form,
    .permission-card-grid,
    .role-list,
    .two-columns,
    .three-columns,
    .invoice-summary-grid,
    .dashboard-summary,
    .invoice-status-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-filter {
        width: 100%;
    }

    .dashboard-filter select {
        width: 100%;
    }

    .filter-actions,
    .item-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .roles-editor-header,
    .roles-editor-tools,
    .roles-savebar {
        align-items: stretch;
        flex-direction: column;
    }

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

    .roles-savebar__actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .pagination-controls {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

}
