/* Cargo Management — design system (no external dependencies, works offline). */
:root {
    --primary: #0052B5;
    --primary-600: #00449a;
    --primary-50: #EAF2FF;
    --accent: #FCC220;
    --accent-600: #e0a800;
    --accent-50: #fff8dd;
    --bg: #F5F7FB;
    --surface: #ffffff;
    --surface-2: #EEF2F8;
    --border: #E8EDF4;
    --field-border: #d3dbe8;
    --active-bg: #EAF2FF;
    --control-h: 44px;          /* buttons, inputs and selects share one height */
    --control-h-sm: 36px;
    --nav-item-h: 42px;
    --text: #14213d;
    --muted: #64708a;
    --success: #14804a;
    --success-50: #e6f6ee;
    --danger: #c62828;
    --danger-50: #fdeaea;
    --warn: #b26a00;
    --warn-50: #fff3df;
    --info: #1565c0;
    --info-50: #e6f1fd;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
    --sidebar-w: 250px;
    --topbar-h: 64px;
    /* Inter when the device has it (nothing is downloaded), otherwise the closest system face. */
    --font: Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
    color: var(--text); background: var(--bg);
    -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
    padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { line-height: 1.25; letter-spacing: -.012em; margin: 0; }
p { margin: 0; }
a { color: var(--primary); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: absolute; inset-inline-start: -999px; top: 8px; background: var(--accent); color: #000; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { inset-inline-start: 8px; }

/* ---------- Buttons ---------- */
/* One fixed height per size, one line of text, never squeezed by a flex parent: a longer translation makes a button
   wider (down to a shared minimum width), never taller. Rows of buttons wrap as whole buttons. */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex-shrink: 0;
    height: var(--control-h); min-width: 116px; max-width: 100%; padding: 0 18px; border: 1px solid transparent; border-radius: var(--radius-sm);
    font: inherit; font-weight: 600; line-height: 20px; white-space: nowrap; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
}
.btn > .icon { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(0, 82, 181, .28); }
.btn-primary:hover { background: var(--primary-600); }
.btn-accent { background: var(--accent); color: #1b1500; }
.btn-accent:hover { background: var(--accent-600); }
.btn-outline { background: var(--surface); border-color: var(--field-border); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { height: var(--control-h-sm); min-width: 96px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; flex-shrink: 0; place-items: center; width: 44px; height: 44px;border: 0; background: transparent; border-radius: var(--radius-sm); color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.input {
    width: 100%; min-width: 0; padding: 10px 14px; font: inherit; line-height: 22px; color: var(--text);
    background: var(--surface); border: 1px solid var(--field-border); border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
input.input, select.input { height: var(--control-h); padding-block: 0; }
select.input { padding-inline: 10px; text-overflow: ellipsis; }
.input:hover:not(:disabled) { border-color: #b4c1d8; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0, 82, 181, .18); }
.has-error .input { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.input-group { position: relative; }
.input-group .input { padding-inline-end: 48px; }
.input-addon { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 8px; }
.input-addon:hover { color: var(--primary); }

/* ---------- Cards / alerts / badges ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card-title { font-size: 15.5px; font-weight: 700; margin-bottom: 16px; }
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; font-size: 14px; }
.alert-success { background: var(--success-50); color: var(--success); border-color: #b9e3cd; }
.alert-error { background: var(--danger-50); color: var(--danger); border-color: #f4c2c2; }
.alert-info { background: var(--info-50); color: var(--info); border-color: #bcd9f6; }
.alert-warn { background: var(--warn-50); color: var(--warn); border-color: #f2d49b; }
.pill { display: inline-flex; flex-shrink: 0; align-items: center; gap: 6px; padding: 6px 12px; white-space: nowrap;background: var(--primary-50); color: var(--primary); border-radius: 999px; font-size: 13px; font-weight: 600; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge-draft { background: #eceff4; color: #4b5870; }
.badge-in_transit { background: var(--info-50); color: var(--info); }
.badge-arrived { background: #e3f4f6; color: #0b7285; }
.badge-verification_pending { background: var(--accent-50); color: #8a6500; }
.badge-verification_submitted { background: #efe9fb; color: #5b3aa8; }
.badge-under_review { background: var(--primary-50); color: var(--primary); }
.badge-discrepancy { background: var(--danger-50); color: var(--danger); }
.badge-completed { background: var(--success-50); color: var(--success); }
.badge-cancelled { background: #f1f1f1; color: #777; text-decoration: line-through; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 11px 10px; border-bottom: 1px solid var(--border); background: #F8FAFD; }
.table thead th:first-child { border-start-start-radius: var(--radius-sm); }
.table thead th:last-child { border-start-end-radius: var(--radius-sm); }
.table td { padding: 13px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
.table tbody tr { transition: background-color .12s ease; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #F7FAFF; }
.table td a { text-decoration: none; }
.table td a:hover { text-decoration: underline; }
.table td a.btn:hover { text-decoration: none; }
/* Row buttons are wide enough for the Somali "Edit", so they keep one size when the language changes. */
.table .row-actions .btn-sm { min-width: 120px; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
/* ---- Sidebar: white, 250px, one blue accent. Every entry is one line and the same height in every language. ---- */
.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: #fff; color: var(--text); border-inline-end: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh;
    transition: width .22s ease, flex-basis .22s ease;
}
.sidebar-head { flex: none; height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block-start: 8px; padding-inline: 24px 10px; border-bottom: 1px solid var(--border); }
.sidebar-close { display: none; width: 36px; height: 36px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap; }
.brand img { border-radius: 8px; flex: none; }
/* The scrollbar is hidden so it never takes width away from the labels; wheel, touch and keyboard scrolling still work. */
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding-block: 22px 14px; padding-inline: 18px 6px; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-link, .nav-sublink {
    position: relative; display: flex; align-items: center; flex: none; height: var(--nav-item-h); padding: 0 8px; border-radius: var(--radius-sm);
    color: #4b5870; text-decoration: none; font-family: inherit; font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap;
    transition: background-color .15s ease, color .15s ease;
}
.nav-link { gap: 8px; width: 100%; background: none; border: 0; cursor: pointer; text-align: start; }
.nav-link > .icon { width: 18px; height: 18px; color: #7b869b; transition: color .15s ease; }
/* The few translations too long for one line at the normal size are set a little smaller, never wrapped or cut off. */
.nav-label.is-long { font-size: 12px; letter-spacing: -.015em; }
.nav-link:hover, .nav-sublink:hover { background: #F5F7FB; color: var(--text); }
.nav-link:hover > .icon { color: var(--text); }
.nav-link:focus-visible, .nav-sublink:focus-visible, .logout-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
/* Active page: light blue pill, blue text and icon. */
.nav-link.is-active, .nav-sublink.is-active { background: var(--active-bg); color: var(--primary); font-weight: 600; }
.nav-link.is-active > .icon { color: var(--primary); }
/* Menus that open and close (native <details>: works with no JavaScript, keyboard accessible).
   The menu holding the current page is tinted, and so is the page inside it. */
.nav-group { flex: none; }
.nav-group > summary { list-style: none; user-select: none; }
.nav-group[open] > summary { color: var(--text); font-weight: 600; }
.nav-group[open] > summary.is-active { color: var(--primary); }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-link > .nav-chevron { width: 14px; height: 14px; margin-inline-start: auto; opacity: .7; transition: transform .18s ease; }
.nav-group[open] > summary .nav-chevron { transform: rotate(90deg); }
[dir="rtl"] .nav-chevron { transform: scaleX(-1); }
[dir="rtl"] .nav-group[open] > summary .nav-chevron { transform: scaleX(-1) rotate(90deg); }
.nav-sub { display: flex; flex-direction: column; gap: 2px; padding-block: 4px 2px; }
/* Only when the user opens it: a menu that is already open when the page loads does not fade in. */
.nav-group.is-animated[open] > .nav-sub { animation: nav-open .18s ease; }
@keyframes nav-open { from { opacity: 0; transform: translateY(-6px); } }
/* Each page inside a menu: a dot under the menu's icon, text in line with the menu's name. */
.nav-sublink { height: 38px; padding-inline: 14px 6px; gap: 9px; font-size: 13.5px; }
.nav-sublink::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: #cbd3e1; transition: background-color .15s ease; }
.nav-sublink:hover::before { background: #8a94a8; }
.nav-sublink.is-active::before { background: var(--primary); }
/* The count of a closed menu shows on its header; once open it shows on the page itself. */
.nav-group[open] > summary .nav-badge-group { display: none; }
.nav-group:not([open]) > summary > .nav-badge ~ .nav-chevron { margin-inline-start: 8px; }
.nav-badge { margin-inline-start: auto; }

.sidebar-foot { flex: none; display: flex; align-items: center; gap: 8px; padding-block: 10px calc(10px + env(safe-area-inset-bottom)); padding-inline: 24px 10px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.sidebar-user .user-meta { min-width: 0; }
.sidebar-user .user-meta strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .user-meta small { overflow-wrap: break-word; }
.logout-form { margin: 0; flex: none; }
.logout-btn { width: 40px; height: 40px; color: #7b869b; border-radius: var(--radius-sm); }
.logout-btn .icon { width: 18px; height: 18px; }
.logout-btn:hover { background: var(--danger-50); color: var(--danger); }

.nav-link.is-active::before { content: ""; position: absolute; inset-inline-start: -8px; top: 9px; bottom: 9px; width: 3px; background: var(--primary); border-start-end-radius: 3px; border-end-end-radius: 3px; }
.nav-group[open] > summary.is-active::before { display: none; }
.collapse-btn { margin-inline-start: -10px; color: var(--muted); }
.collapse-btn .icon-expand, .nav-collapsed .collapse-btn .icon-collapse { display: none; }
.nav-collapsed .collapse-btn .icon-expand { display: block; }
[dir="rtl"] .collapse-btn .icon { transform: scaleX(-1); }
.nav-tip { position: fixed; z-index: 70; transform: translateY(-50%); max-width: 260px; padding: 7px 11px; border-radius: 8px; background: #14213d; color: #fff; font-size: 12.5px; font-weight: 600; line-height: 1.3; box-shadow: var(--shadow-lg); pointer-events: none; }

/* 72px icon rail (desktop only; below 1025px the sidebar is a drawer and always shows its labels). */
@media (min-width: 1025px) {
    .nav-collapsed { --sidebar-w: 72px; }
    .nav-collapsed .sidebar { overflow: hidden; }
    .nav-collapsed .sidebar-head { justify-content: center; padding-inline: 0; }
    .nav-collapsed .brand span, .nav-collapsed .nav-label, .nav-collapsed .sidebar-user .user-meta { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .nav-collapsed .nav { padding-inline: 12px; }
    .nav-collapsed .nav-link { justify-content: center; padding: 0; gap: 0; }
    .nav-collapsed .nav-link > .icon { width: 20px; height: 20px; }
    .nav-collapsed .nav-link > .nav-chevron, .nav-collapsed .nav-sub { display: none; }
    .nav-collapsed .nav-link.is-active::before { inset-inline-start: -12px; }
    .nav-collapsed .nav-group[open] > summary.is-active::before { display: block; }
    .nav-collapsed .nav-group[open] > summary .nav-badge-group { display: block; }
    .nav-collapsed .nav-link > .nav-badge { position: absolute; top: 2px; inset-inline-end: 0; min-width: 18px; height: 18px; padding: 0 4px; font-size: 10.5px; line-height: 18px; text-align: center; }
    .nav-collapsed .sidebar-foot { flex-direction: column; gap: 6px; padding-inline: 0; }
    .nav-collapsed .sidebar-user { flex: none; justify-content: center; }
}

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
    padding: 0 24px; background: #fff; border-bottom: 1px solid var(--border);
}
/* A long page title takes a second line inside the fixed-height bar; it is never cut off. */
.topbar-title { font-size: 17px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.menu-btn { display: none; margin-inline-start: -10px; }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; background: #EAF2FF; color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-meta small { color: var(--muted); font-size: 12px; }

/* Profile menu (native <details>; app.js closes it on outside click / Escape) */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; transition: background-color .15s ease; }
.user-chip:hover, .user-menu[open] > .user-chip { background: var(--surface-2); }
.user-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.user-caret { width: 14px; height: 14px; color: var(--muted); }
.user-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 220px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(20, 33, 61, .08); padding: 6px; z-index: 40; }
.user-panel-id { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; overflow-wrap: anywhere; }
.user-panel-id small { color: var(--muted); font-size: 12px; }
.user-panel-id .role-tag { color: var(--primary); font-weight: 600; }
.user-panel form { margin: 0; }
.user-panel-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 12px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: 14px; color: var(--text); cursor: pointer; text-align: start; }
.user-panel-item .icon { width: 16px; height: 16px; color: var(--muted); }
.user-panel-item:hover { background: var(--danger-50); color: var(--danger); }
.user-panel-item:hover .icon { color: var(--danger); }
.content { padding: 28px; max-width: 1280px; width: 100%; margin: 0 auto; }
.content:focus { outline: none; }
.scrim { position: fixed; inset: 0; background: rgba(20, 33, 61, .4); z-index: 29; }
body.nav-open { overflow: hidden; }

.lang-switch { display: inline-flex; flex-shrink: 0; margin: 0; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.lang-btn { width: 44px; height: 32px; border: 0; background: transparent; padding: 0; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.lang-btn.is-active { background: #fff; color: var(--primary); box-shadow: 0 0 0 1px var(--border); }

.sync { font-size: 13px; line-height: 1.25; font-weight: 600; padding: 4px 10px;border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.sync.is-pending { background: var(--accent-50); color: #8a6500; }
.sync.is-synced { background: var(--success-50); color: var(--success); }
.sync.is-failed { background: var(--danger-50); color: var(--danger); }

.banner { position: fixed; z-index: 60; inset-inline: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: 520px; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; }
.banner-warn { background: #3a2a00; color: #ffe08a; }
.banner-info { background: var(--primary); color: #fff; bottom: calc(76px + env(safe-area-inset-bottom)); }
#net-banner { top: 12px; bottom: auto; }

/* ---------- Dashboard ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; overflow-wrap: break-word; }
/* The heading block takes the free space, so a long description wraps instead of pushing the buttons around. */
.page-head > div:first-child:not(.head-actions) { flex: 1 1 280px; min-width: 0; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid > * { min-width: 0; }
.grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-stats.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; }
/* KPI card: label over a large figure, tinted icon at the far side, a thin tone line at the start edge. */
.stat { position: relative; display: flex; flex-direction: row-reverse; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 20px; overflow: hidden; --tone: var(--primary); }
.stat::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--tone); }
.stat > div { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 8px; min-width: 0; }
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex: none; }
.stat-icon .icon { width: 21px; height: 21px; }
.stat-accent { --tone: var(--accent); }
.stat-info { --tone: #2f80d8; }
.stat-danger { --tone: var(--danger); }
.stat-accent .stat-icon { background: var(--accent-50); color: #8a6500; }
.stat-info .stat-icon { background: var(--info-50); color: var(--info); }
.stat-danger .stat-icon { background: var(--danger-50); color: var(--danger); }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.025em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-label { color: var(--muted); font-size: 13px; line-height: 1.35; font-weight: 600; overflow-wrap: break-word; }

/* Secondary figures: smaller tiles that sit under the four main ones. */
.grid-mini { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.grid-mini .stat { padding: 14px 16px; gap: 10px; }
.grid-mini .stat::before { display: none; }
.grid-mini .stat-value { font-size: 21px; }
.grid-mini .stat-label { font-size: 12.5px; }
.grid-mini .stat-icon { width: 32px; height: 32px; border-radius: 9px; }
.grid-mini .stat-icon .icon { width: 17px; height: 17px; }

.dash-hero { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 16px; padding: 22px 26px; border-radius: var(--radius); background: linear-gradient(120deg, var(--primary) 0%, #003d89 100%); color: #fff; box-shadow: var(--shadow); overflow: hidden; }
.dash-hero::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 3px; background: var(--accent); }
.dash-hero > div { flex: 1 1 260px; min-width: 0; }
.dash-hero h2 { font-size: 23px; overflow-wrap: break-word; }
.dash-hero p { margin-top: 4px; color: rgba(255, 255, 255, .82); }
.dash-hero .pill { background: rgba(255, 255, 255, .16); color: #fff; }

.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 16px; }
.card-head .card-title { margin: 0; }
.card-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.card-link:hover { text-decoration: underline; }
.card-link .icon { width: 14px; height: 14px; }

.status-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.status-list li { display: grid; grid-template-columns: minmax(0, 180px) minmax(40px, 1fr) 36px; align-items: center; gap: 12px; min-height: 32px; }
.status-list li.is-zero .badge, .status-list li.is-zero .count { opacity: .55; }
.status-list .badge { justify-self: start; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--tone, var(--primary)); border-radius: 99px; transition: width .5s ease; }
/* One strip showing every status's share of all shipments. */
.bar.dist { display: flex; gap: 2px; height: 12px; margin-bottom: 16px; }
.dist span { border-radius: 0; min-width: 0; }
.s-draft { --tone: #9aa5b8; }
.s-in_transit { --tone: #2f80d8; }
.s-arrived { --tone: #149db3; }
.s-verification_pending { --tone: #FCC220; }
.s-verification_submitted { --tone: #7c5cc9; }
.s-under_review { --tone: #0052B5; }
.s-discrepancy { --tone: #d64545; }
.s-completed { --tone: #1f9d63; }
.s-cancelled { --tone: #c3c9d4; }
.count { text-align: end; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 0; color: var(--muted); }
.empty .icon { width: 32px; height: 32px; opacity: .6; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.activity li:last-child { border: 0; }
.activity li > div { flex: 1; display: flex; gap: 6px; flex-wrap: wrap; }
.activity time { font-size: 12.5px; white-space: nowrap; }
.activity .avatar { width: 30px; height: 30px; font-size: 12px; }
@media (max-width: 600px) { .activity li { flex-wrap: wrap; } .activity time { width: 100%; padding-inline-start: 42px; } }

/* ---------- Auth ---------- */
body.guest { background: var(--surface-2); }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: linear-gradient(145deg, var(--primary) 0%, #003a82 100%); color: #fff; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 64px; }
.auth-hero img { border-radius: 16px; }
.auth-hero h2 { font-size: 36px; }
.auth-hero p { font-size: 18px; max-width: 420px; color: rgba(255, 255, 255, .85); }
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--bg); position: relative; }
.auth-lang { position: absolute; top: 16px; inset-inline-end: 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 28px; margin-bottom: 6px; }
.auth-card .muted { margin-bottom: 24px; }
.auth-brand-mobile { display: none; align-items: center; gap: 12px; margin-bottom: 24px; font-size: 18px; }
.auth-brand-mobile img { border-radius: 12px; }

.error-page { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; }
.error-code { font-size: 72px; font-weight: 800; color: var(--primary); line-height: 1; }
.debug { text-align: start; background: #111; color: #9f9; padding: 12px; border-radius: 8px; max-width: 100%; overflow: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
    .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 30; width: min(280px, 86vw); flex-basis: auto;transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; box-shadow: 0 8px 32px rgba(20, 33, 61, .18); }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.is-open { transform: none; visibility: visible; transition: transform .2s ease; }
    .sidebar-close { display: inline-grid; }
    .menu-btn { display: inline-grid; }
    .collapse-btn { display: none; }
}
@media (max-width: 900px) {
    .topbar { padding: 0 16px; gap: 8px; }
    .topbar-title { font-size: 15px; }
    .topbar-actions { gap: 6px; }
    .content { padding: 16px; }
    .topbar .user-meta, .user-caret { display: none; }
    .user-chip { padding: 2px; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-brand-mobile { display: flex; }
}
@media (max-width: 600px) {
    .grid-stats, .grid-stats.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat { flex-direction: column; justify-content: flex-start; gap: 10px; padding: 14px; }
    .stat-value { font-size: 24px; }
    .grid-mini { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-hero { padding: 18px; }
    .dash-hero h2 { font-size: 19px; }
    .page-head h2 { font-size: 20px; }
    .status-list li { grid-template-columns: 1fr 36px; }
    .status-list .bar { grid-column: 1 / -1; grid-row: 2; }
    #install-btn { width: var(--control-h-sm); min-width: 0; padding: 0; }
    #install-btn span { display: none; }
    .lang-btn { width: 38px; }
    .stat-label { overflow-wrap: break-word; }
}
/* Phones and portrait tablets: table rows become cards, so wide tables never scroll sideways. */
@media (max-width: 820px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 6px 0; }
    .table td { border: 0; padding: 6px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; text-align: end; overflow-wrap: anywhere; }
    .table td > * { min-width: 0; max-width: 100%; }
    .table td::before { content: attr(data-label); flex: none; margin-inline-end: auto; color: var(--muted); font-size: 12px; text-transform: uppercase; text-align: start; }
    .table td.row-actions { justify-content: flex-end; white-space: normal; }
    .table td.row-actions:empty { display: none; }
    .card-flush .table tr { margin: 10px 12px; width: auto; }
    .card-flush .table td:first-child, .card-flush .table td:last-child { padding-inline: 12px; }
    .roles-table td { height: auto; }
    .role-desc { max-width: none; }
}
/* Small laptops and landscape tablets: tighter cells and wrapping action buttons keep most tables from scrolling. */
@media (min-width: 821px) and (max-width: 1439px) {
    .table th, .table td { padding-inline: 6px; }
    .table .row-actions { white-space: normal; }
    .table .row-actions .btn { margin-block: 2px; }
}
@media (min-width: 601px) and (max-width: 820px) {
    .table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
    .table td { align-content: center; }
    .table td.row-actions, .table td.note-cell { grid-column: 1 / -1; }
}
/* ---------- Phase 2: forms, filters, lists, detail ---------- */
select.input { appearance: auto; }
textarea.input { resize: vertical; min-height: 88px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.form-card { max-width: 640px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 0 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.shipment-form .card { margin-bottom: 16px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.inline { display: inline; margin: 0; }
.row-actions { white-space: nowrap; text-align: end; }
.row-actions .btn { margin-inline-start: 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; max-width: 100%; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a11f1f; }
.btn-danger-outline { color: var(--danger); border-color: #f0b9b9; }
.btn-danger-outline:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-50); }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(165px, 100%), 1fr)); gap: 0 14px; align-items: end; margin-bottom: 16px; padding-bottom: 6px; }
.filters .field { margin-bottom: 14px; min-width: 0; }
/* The buttons always have their own row, so their place does not depend on how long the words are. */
.filter-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 14px; }

.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 16px; }
.page-link { min-width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 600; }
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-gap { color: var(--muted); }
.page-total { margin-inline-start: auto; color: var(--muted); font-size: 13px; }

.item-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px dashed var(--border); }
.item-grid { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) minmax(0, 1.2fr); gap: 0 12px; }
/* Labels of one row may differ in length; inputs still line up because each field fills its cell from the bottom. */
.item-grid .field { display: flex; flex-direction: column; margin-bottom: 8px; min-width: 0; }
.item-grid .field > label { flex: 1 0 auto; }
.item-grid .item-notes { grid-column: 1 / -1; }
.item-row label { font-size: 13px; }
.item-remove { margin-top: 26px; }
#add-item { margin-top: 14px; }

.kv { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 10px 20px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.action-title { margin-top: 22px; }
.status-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.cancel-box { width: 100%; }
.cancel-box summary { list-style: none; cursor: pointer; display: inline-flex; }
.cancel-box summary::-webkit-details-marker { display: none; }
.cancel-box form { margin-top: 12px; padding: 14px; background: var(--danger-50); border-radius: var(--radius-sm); }

.timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 18px 18px; }
[dir="rtl"] .timeline li { padding: 0 18px 18px 0; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.timeline .note { margin-top: 6px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 14px; }

@media (max-width: 900px) {
    .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .item-grid .field:first-child { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    .item-row { flex-direction: column; gap: 0; }
    .item-remove { margin-top: 0; align-self: flex-end; }
    .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .kv dd { margin-bottom: 10px; }
    .form-actions .btn { flex: 1 0 auto; } /* share the row; a button that does not fit moves to its own row */
}
/* ---------- Phase 3: receiving (mobile-first) ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.badge-v-submitted { background: var(--accent-50); color: #8a6500; }
.badge-v-approved { background: var(--success-50); color: var(--success); }
.badge-v-rejected { background: var(--danger-50); color: var(--danger); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; -webkit-overflow-scrolling: touch; }
.tab { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-h); min-width: 96px; white-space: nowrap; padding: 0 16px;border-radius: 999px; background: var(--surface-2); color: var(--muted); text-decoration: none; font-weight: 700; }
.tab.is-active { background: var(--primary); color: #fff; }
.tab-count { background: rgba(0, 0, 0, .12); border-radius: 999px; padding: 0 8px; font-size: 12px; line-height: 20px; }
.tab.is-active .tab-count { background: rgba(255, 255, 255, .25); }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.ship-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .05s; }
.ship-card:hover { box-shadow: 0 2px 4px rgba(20, 33, 61, .08), 0 8px 24px rgba(20, 33, 61, .1); }
.ship-card.is-ready { border-color: var(--accent); border-width: 2px; }
.ship-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 17px; }
.ship-card-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; }
.ship-card-meta span { display: inline-flex; align-items: center; gap: 6px; }
.ship-card-alert { margin: 0; }
.cta-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; border-color: var(--accent); background: var(--accent-50); }

.verify-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 10; padding: 12px; margin-bottom: 14px; }
.verify-summary strong { display: block; font-size: 20px; }
.sum-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.item-card { margin-bottom: 14px; border-inline-start: 5px solid var(--border); }
.item-card.has-missing { border-inline-start-color: var(--danger); }
.item-card.has-damage { border-inline-start-color: var(--accent); }
.item-card.has-over { border-inline-start-color: var(--info); }
.item-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.expected-chip { text-align: end; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; white-space: nowrap; }
.expected-chip strong { display: block; font-size: 17px; color: var(--text); text-transform: none; }
.item-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input.input-lg { height: 56px; font-size: 22px; font-weight: 700; text-align: center; }
.calc-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-2); }
.chip-missing b { color: var(--danger); } .chip-good b { color: var(--success); } .chip-over b { color: var(--info); }
.item-note summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 14px; padding: 6px 0; }
.item-note .input { margin-top: 6px; }

.photo-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.photo-actions .btn { flex: 1 0 auto; min-width: 150px; height: 52px; cursor: pointer; }
.field label.btn { display: inline-flex; margin: 0; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.photo-thumb { position: relative; margin: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: block; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove { position: absolute; top: 4px; inset-inline-end: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.draft-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.sticky-bar { position: sticky; bottom: 0; z-index: 15; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; margin: 0 -16px; background: rgba(247, 249, 252, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--border); }
.sticky-bar .btn { height: 52px; min-width: 200px; margin-inline-start: auto; font-size: 16px; }
.draft-status { font-size: 13px; }

.totals-grid { grid-template-columns: repeat(6, 1fr); }
.total { padding: 14px; text-align: center; }
.total .stat-value { font-size: 24px; }
.total-danger .stat-value { color: var(--danger); } .total-success .stat-value { color: var(--success); } .total-info .stat-value { color: var(--info); } .total-accent .stat-value { color: #8a6500; }
.row-flag { background: #fffbea; }

.bottom-nav { display: none; }
@media (max-width: 900px) {
    .bottom-nav { position: fixed; z-index: 25; inset-inline: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
    .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; min-height: 58px; justify-content: center; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 700; }
    .bottom-nav a.is-active { color: var(--primary); }
    body[data-role="receiving_officer"] .content { padding-bottom: 90px; }
    body[data-role="receiving_officer"] .sticky-bar { bottom: calc(58px + env(safe-area-inset-bottom)); }
    body[data-role="receiving_officer"] .banner-info { bottom: calc(130px + env(safe-area-inset-bottom)); }
    .totals-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
    .verify-summary { top: calc(var(--topbar-h) + 4px); }
    .sticky-bar { margin: 0 -16px; }
    .sticky-bar .btn { flex: 1 0 auto; min-width: 0; }
    .draft-status { display: none; }
    .totals-grid { grid-template-columns: repeat(2, 1fr); }
    .cards { grid-template-columns: 1fr; }
}
/* ---------- Phase 4: review ---------- */
.nav-badge { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: #1b1500; font-size: 12px; font-weight: 800; display: inline-grid; place-items: center; }
.alert-link { display: block; text-decoration: none; color: inherit; }
.alert-link:hover { filter: brightness(.97); }
.review-panel { border-color: var(--primary); border-width: 2px; margin-bottom: 16px; }
.review-actions { margin: 10px 0 4px; }
.review-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.review-form { padding: 14px; border-radius: var(--radius-sm); background: var(--success-50); }
.review-form-reject { background: var(--danger-50); }
.review-form .btn { margin-top: 4px; }
.resolve-box form { background: var(--success-50); }
@media (max-width: 700px) { .review-forms { grid-template-columns: 1fr; } }
/* ---------- Phase 5: reports ---------- */
.report-cards { margin-bottom: 16px; }
.report-totals { grid-template-columns: repeat(2, minmax(0, 220px)); }
.report-count { margin: -4px 0 12px; }
.filter-check { align-self: center; margin-bottom: 14px; }
.note-cell { max-width: 280px; }
.head-actions .btn span { white-space: nowrap; }
@media (max-width: 600px) { .report-totals { grid-template-columns: 1fr 1fr; } }
@media (max-width: 820px) {
    /* Notes are long text: give them the whole row instead of a narrow right-aligned column. */
    .table td.note-cell { display: block; text-align: start; max-width: none; }
    .table td.note-cell::before { display: block; margin-bottom: 4px; }
}
.mono-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

/* ---------- Phase 6: system, offline app ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; word-break: break-all; }
.backup-create { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 12px 0 8px; }
.backup-create .check { margin: 0; }
.restore-card { border-color: #f0b9b9; }
.restore-form .check { margin-bottom: 8px; }
.health-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.health-list li { display: flex; align-items: flex-start; gap: 10px; }
.health-list li > div { display: flex; flex-direction: column; min-width: 0; }
.health-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--success); }
.health-warn .health-dot { background: var(--accent); }
.health-fail .health-dot { background: var(--danger); }
.pill-warn { background: var(--warn-50); color: var(--warn); }
.queue-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.queue-item { margin-bottom: 12px; }
.queue-item.is-failed { border-color: #f0b9b9; }
.queue-meta { font-size: 13px; margin: 6px 0 10px; }
.pack-age { font-size: 13px; margin-bottom: 12px; }
.queued-card { text-align: center; padding: 28px 20px; }
.queued-card .form-actions { justify-content: center; }
.offline-app .topbar { position: sticky; }
.sync { text-decoration: none; }
@media (max-width: 900px) { .offline-app .content { padding-bottom: 24px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- Modal dialog (create / edit forms) ---- */
body.modal-open { overflow: hidden; }
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(20, 33, 61, .5); display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; }
/* Every dialog has the same width in both languages; only its height follows the content. */
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: 0 12px 48px rgba(20, 33, 61, .3); width: min(760px, 100%); flex: none; outline: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 20px; min-width: 0; overflow-wrap: break-word; }
.modal-x { font-size: 28px; line-height: 1; background: none; border: 0; cursor: pointer; color: var(--muted); padding: 0 6px; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-body .form-card { max-width: none; border: 0; box-shadow: none; padding: 0; }
.modal-body .shipment-form .card { box-shadow: none; }
.modal-loading { color: var(--muted); text-align: center; padding: 24px 0; }
@media (max-width: 600px) {
    .modal-overlay { padding: 0; }
    .modal { border-radius: 0; min-height: 100%; }
}

/* ---- Customers ---- */
.grid-stats.grid-3 { grid-template-columns: repeat(3, 1fr); }
.static-value { margin: 0; padding: 10px 0; font-weight: 600; }
.form-note { margin: 0 0 14px; }
.card-more { margin: 12px 0 0; font-size: 14px; }

/* Customer picker (shipment form) */
.picker-search { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.picker-box { position: relative; flex: 1 1 260px; min-width: 0; }
.picker-search .btn { min-width: 232px; } /* same width in both languages, so the search box does not change size */
.picker-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.picker-list li { display: flex; flex-direction: column; gap: 2px; padding: 9px 12px; border-radius: 6px; cursor: pointer; }
.picker-list li:hover, .picker-list li.is-active { background: var(--primary-50); }
.picker-list .picker-empty { cursor: default; color: var(--muted); font-size: 14px; }
.picker-list .picker-empty:hover { background: none; }
.picker-selected { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: var(--primary-50); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.picker-selected[hidden], .picker-search[hidden] { display: none; }
.picker-chip { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) {
    .grid-stats.grid-3 { grid-template-columns: 1fr; }
    .picker-search .btn { width: 100%; justify-content: center; }
}

/* Sub-menu entries that open a modal show a small plus. */
.nav-sublink .sub-icon { width: 14px; height: 14px; margin-inline-end: 8px; color: var(--primary); }

/* ---- Expenses ---- */
.num { text-align: end; white-space: nowrap; }
.money-input { position: relative; }
.money-input > span { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.money-input .input { padding-inline-start: 28px; }
.expenses-card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head .card-title { margin: 0; }
tfoot td { border-top: 2px solid var(--border); padding-top: 12px; }

/* ---- Accounting statements ---- */
.statement { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.statement th { text-align: start; padding: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.statement td { padding: 9px 0; border-bottom: 1px solid #eef1f6; }
.statement .st-indent { padding-inline-start: 16px; color: #4b5870; }
.statement .st-section td { padding-top: 18px; font-weight: 700; border-bottom: 0; }
.statement .st-total td { font-weight: 700; border-top: 1px solid var(--border); }
.statement .st-grand td { padding: 14px 0 4px; font-size: 16px; font-weight: 800; border-top: 2px solid var(--text); border-bottom: 0; }
.statement .st-grand.is-neg td { color: var(--danger); }
.statement .num { font-variant-numeric: tabular-nums; }
.bs-grid { align-items: start; }
.finance-card { margin-top: 16px; }
@media print {
    .sidebar, .topbar, .scrim, .no-print, .bottom-nav, .modal-overlay, .head-actions, #net-banner, .skip-link { display: none !important; }
    .shell, .main-col { display: block; }
    .content { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
    .grid-stats { display: none; }
}
/* ---- Roles & permissions ---- */
.card-flush { padding: 0; }
.card-flush .table th:first-child, .card-flush .table td:first-child { padding-inline-start: 20px; }
.card-flush .table th:last-child, .card-flush .table td:last-child { padding-inline-end: 20px; }
.card-flush .table tbody tr:last-child td { border-bottom: 0; }
.table th.num { text-align: end; }

/* ---- Chart of accounts: one table per account type, with columns that line up from card to card ---- */
.account-group { margin-bottom: 16px; }
.acct-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.acct-name small { font-size: 12.5px; font-weight: 400; }
@media (min-width: 821px) {
    .accounts-table { table-layout: fixed; }
    .accounts-table .acct-code { width: 90px; }
    .accounts-table .acct-state { width: 120px; }
    .accounts-table .acct-balance { width: 150px; }
    .accounts-table .acct-actions { width: 390px; }
}
@media (min-width: 821px) and (max-width: 1439px) { .accounts-table .acct-actions { width: 270px; } }

/* Roles listing */
.roles-table td { height: 64px; }
.role-name { display: flex; align-items: center; gap: 12px; text-align: start; }
.role-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); }
.role-icon.is-system { background: var(--active-bg); color: var(--primary); }
.role-icon .icon { width: 18px; height: 18px; }
.role-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.role-title a { text-decoration: none; overflow-wrap: anywhere; }
.role-title a:hover { text-decoration: underline; }
.role-desc { color: var(--muted); max-width: 320px; overflow-wrap: anywhere; }
.perm-count { white-space: nowrap; }
.roles-table .row-actions { white-space: normal; }
.roles-table .row-actions .btn { margin-block: 2px; }
@media (min-width: 1200px) { .roles-table .row-actions { white-space: nowrap; width: 1%; } }

/* Permission editors */
.perm-editor > .card { margin-bottom: 16px; }
.role-details .field { margin-bottom: 10px; }
.perm-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; padding: 16px 20px 0; }
.perm-head .card-title { margin: 0; }
.perm-note { padding-inline: 20px; }
.perm-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.perm-search { position: relative; flex: 0 1 340px; max-width: 100%; } /* the buttons wrap before the search box changes size */
.perm-search > .icon { position: absolute; inset-inline-start: 12px; top: 13px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.perm-search .input { padding-inline-start: 40px; }
.perm-bulk { display: flex; flex-wrap: wrap; gap: 8px; }
.perm-bulk .btn { height: var(--control-h); }
.perm-wrap { container-type: inline-size; }
.perm-empty { padding: 36px 20px; }
.perm-critical { display: inline-block; font-size: 10px; line-height: 1.2; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--warn); }

/* Role matrix: modules down, actions across */
.perm-matrix { width: 100%; border-collapse: collapse; table-layout: fixed; }
.perm-matrix th, .perm-matrix td { padding: 6px 4px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: middle; }
.perm-matrix thead th { padding-block: 10px; font-size: 12px; line-height: 1.3; font-weight: 700; color: var(--muted); background: #FAFBFD; vertical-align: bottom; overflow-wrap: break-word; }
.perm-matrix th:first-child { width: 23%; text-align: start; padding-inline-start: 20px; }
.perm-matrix th:last-child, .perm-matrix td:last-child { padding-inline-end: 12px; }
.perm-matrix tbody tr:last-child > * { border-bottom: 0; }
.perm-matrix tbody tr:hover { background: #FAFCFF; }
.perm-matrix input[type=checkbox] { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--primary); cursor: pointer; }
.perm-matrix input[type=checkbox]:disabled { cursor: not-allowed; }
.perm-module-name { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.perm-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px; border-radius: var(--radius-sm); cursor: pointer; transition: background-color .15s ease; }
.perm-cell:hover { background: var(--surface-2); }
.perm-cell:has(input:checked) { background: var(--active-bg); }
.perm-cell.is-locked { cursor: not-allowed; }
.perm-cell-label { display: none; }
.perm-none { color: #b8c0d0; }
@container (max-width: 760px) {
    .perm-matrix, .perm-matrix tbody { display: block; }
    .perm-matrix thead { display: none; }
    .perm-matrix tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 8px; padding: 10px 14px 14px; border-bottom: 1px solid var(--border); }
    .perm-matrix tr:last-child { border-bottom: 0; }
    .perm-matrix th, .perm-matrix td, .perm-matrix th:first-child, .perm-matrix td:last-child { width: auto; padding: 0; border: 0; }
    .perm-matrix th:first-child { grid-column: 1 / -1; }
    .perm-matrix .perm-none { display: none; }
    .perm-cell { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 6px 10px; border: 1px solid var(--border); text-align: start; }
    .perm-cell-label { display: inline; font-size: 13.5px; line-height: 1.3; }
    .perm-cell .perm-critical { margin-inline-start: auto; }
}

/* Personal overrides: one row per permission */
.perm-list { width: 100%; border-collapse: collapse; }
.perm-list th, .perm-list td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: middle; }
.perm-list thead th { font-size: 12px; font-weight: 700; color: var(--muted); background: #FAFBFD; }
.perm-list th:first-child { padding-inline-start: 20px; }
.perm-list .perm-group th { background: var(--surface-2); font-size: 13.5px; font-weight: 700; }
.perm-name { font-weight: 500; }
.perm-flag { display: inline-flex; justify-content: center; min-width: 56px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.perm-flag.is-yes { background: var(--success-50); color: var(--success); }
.perm-choice { display: inline-grid; grid-template-columns: repeat(3, minmax(108px, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.perm-opt { display: flex; align-items: center; justify-content: center; gap: 6px; height: var(--control-h-sm); padding: 0 10px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.perm-opt + .perm-opt { border-inline-start: 1px solid var(--border); }
.perm-opt input { margin: 0; accent-color: var(--primary); }
.perm-opt:has(input:checked) { background: var(--active-bg); color: var(--primary); font-weight: 600; }
.perm-opt.perm-deny:has(input:checked) { background: var(--danger-50); color: #b42318; }
.perm-opt:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.perm-opt:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: -2px; }
@container (max-width: 700px) {
    .perm-list, .perm-list tbody, .perm-list .perm-group, .perm-list .perm-group th { display: block; }
    .perm-list thead { display: none; }
    .perm-list tr[data-perm-row] { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
    .perm-list tr[data-perm-row] > * { padding: 0; border: 0; }
    .perm-list tr[data-perm-row] > th { grid-column: 1 / -1; font-weight: 600; }
    .perm-list td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
    .perm-list .perm-override { grid-column: 1 / -1; grid-row: 2; }
    .perm-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
    .perm-opt { height: auto; min-height: 44px; padding: 4px 6px; white-space: normal; text-align: center; line-height: 1.2; }
}

.save-bar { position: sticky; bottom: 0; z-index: 15; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: rgba(247, 249, 252, .96); border-top: 1px solid var(--border); }
.save-bar .btn { min-width: 140px; }
@media (max-width: 600px) { .save-bar .btn, .perm-bulk .btn { flex: 1 0 auto; } .perm-bulk { width: 100%; } .perm-search { flex-basis: 100%; } }

/* Role detail page */
.user-list { list-style: none; margin: 0; padding: 0; }
.user-list li { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.user-list li:last-child { border-bottom: 0; }
.user-list-id { display: flex; flex-direction: column; flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.perm-summary { margin: 0; }
.perm-summary dt { font-size: 13px; font-weight: 700; }
.perm-summary dd { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 14px; }
.perm-chip { padding: 2px 10px; border-radius: 999px; background: var(--active-bg); color: var(--primary); font-size: 12.5px; font-weight: 600; }
/* New customer form opened inside the shipment form, under the picker. */
.inline-new { margin-top: 12px; padding: 14px 16px 16px; border: 1px solid var(--border); border-inline-start: 3px solid var(--primary); border-radius: var(--radius-sm); background: var(--surface-2); }
.inline-new-title { margin: 0 0 10px; font-size: 15px; }
.inline-new .form-actions { margin-bottom: 0; }
