:root {
    --bg-0: #e8f3fb;
    --bg-1: #d9ecf8;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-solid: #ffffff;
    --ink: #0f172a;
    --muted: #5b6f86;
    --line: #c5d8e8;
    --grid: #c5d6e6;
    --brand: #0b3d4a;
    --brand-glow: rgba(56, 146, 196, 0.18);
    --accent: #e67e22;
    --good: #0f766e;
    --good-bg: #d9f5ef;
    --warn: #c2410c;
    --warn-bg: #ffedd5;
    --bad: #b91c1c;
    --bad-bg: #fee2e2;
    --gate: #1d4ed8;
    --gate-bg: #dbeafe;
    --zebra: #f3f8fc;
    --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.05);
    --radius: 12px;
    --font: "Plus Jakarta Sans", sans-serif;
    --mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(900px 420px at 10% -8%, rgba(96, 165, 250, 0.28), transparent 55%),
        radial-gradient(780px 420px at 92% 0%, rgba(125, 211, 252, 0.22), transparent 52%),
        linear-gradient(180deg, #eaf5fc 0%, var(--bg-0) 40%, var(--bg-1) 100%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Top nav: brand | links+party | right meta (full width) ===== */
.top-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    min-height: 46px;
    background: linear-gradient(120deg, rgba(11, 61, 74, 0.97), rgba(18, 85, 102, 0.95) 55%, rgba(15, 55, 68, 0.97));
    color: #f8fafc;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 14px rgba(11, 61, 74, 0.18);
    position: sticky;
    top: 0;
    z-index: 40;
}

.top-brand-block{
    display:inline-flex;
    align-items:center;
    gap:10px;
    flex:0 0 auto;
    position:relative;
    z-index:2;
}
.brand {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    text-decoration: none;
}
.brand-logo {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 7px;
    background: linear-gradient(135deg, rgba(255,255,255,0.18), rgba(255,255,255,0.06));
    border: 1px solid rgba(255,255,255,0.16);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
    color: #fff;
    font-size: .92rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    white-space: nowrap;
    line-height: 1.1;
}

.top-nav-center{
    position:absolute;
    left:50%;
    top:50%;
    transform:translate(-50%,-50%);
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    flex:0 0 auto;
    min-width:0;
    z-index:1;
    pointer-events:none;
}
.top-nav-center > *{pointer-events:auto}
.scope-nav{
    display:inline-flex;
    align-items:center;
    gap:0;
    padding:3px;
    border-radius:999px;
    background:rgba(255,255,255,0.07);
    border:1px solid rgba(255,255,255,0.14);
    box-shadow:inset 0 1px 0 rgba(255,255,255,0.06);
}
.scope-join{
    display:inline-flex;
    align-items:center;
    padding:0 8px;
    font-size:.68rem;
    font-weight:700;
    letter-spacing:.04em;
    text-transform:uppercase;
    color:rgba(248,250,252,.55);
    user-select:none;
}
.top-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 0 0 auto;
    min-width: 0;
    padding: 0;
    border-radius: 999px;
    background: transparent;
    border: 0;
}
.top-links a {
    padding: 6px 13px;
    border-radius: 999px;
    color: rgba(248, 250, 252, 0.84);
    font-weight: 700;
    font-size: .82rem;
    letter-spacing: -0.01em;
    transition: background .18s ease, color .18s ease;
}
.top-links a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.top-links a.active {
    background: #fff;
    color: var(--brand);
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.top-nav-center .party-switch{
    margin:0 6px;
}
.top-links-primary,
.top-links-dashboard{
    flex:0 0 auto;
}

.top-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex: 0 0 auto;
    margin-left: auto;
    padding-left: 28px;
    flex-wrap: nowrap;
    white-space: nowrap;
    min-width: 0;
    position: relative;
    z-index: 2;
}
.top-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}
.btn-master.is-active,
.btn-nav.is-active {
    outline: 2px solid rgba(255,255,255,.55);
    outline-offset: 1px;
}
.clock {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: 7px;
    padding: 4px 9px;
    font-family: var(--mono);
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.clock-date {
    color: rgba(248, 250, 252, 0.78);
    font-size: .68rem;
    font-weight: 500;
}
.clock-sep {
    width: 1px;
    height: 12px;
    background: rgba(255,255,255,0.22);
}
.clock-time {
    color: #fff;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}
.live-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 7px;
    background: rgba(52, 211, 153, 0.14);
    border: 1px solid rgba(52, 211, 153, 0.35);
    color: #bbf7d0;
    font-size: .7rem;
    font-weight: 700;
}
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
    animation: pulse 1.8s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.app-footer {
    margin-top: auto;
    padding: 4px 8px 6px;
    text-align: center;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.app-footer span {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,0.45);
    border: 1px solid var(--line);
}

/* ===== Page shell ===== */
.main {
    padding: 6px 2px 12px;
    width: 100%;
    max-width: 100%;
}
.page-head-compact {
    margin-bottom: 8px;
    padding: 0;
}
.page-head-compact h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #0b1726;
}

.flash {
    padding: 10px 12px;
    border-radius: 10px;
    margin: 0 0 10px;
    font-size: .9rem;
    font-weight: 500;
    border: 1px solid transparent;
}
.flash.success { background: var(--good-bg); color: var(--good); border-color: #99f6e4; }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: #fecaca; }
.flash ul { margin: 0; padding-left: 18px; }

.content { display: grid; gap: 8px; width: 100%; max-width: 100%; }

.filters, .panel, .stat-card, .form-card {
    background: var(--surface);
    border: 1px solid rgba(213, 222, 232, 0.95);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
}
.filters {
    position: relative;
    z-index: 5;
    overflow: visible;
}

/* Compact full-width filter toolbar */
.filters-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: end;
    gap: 8px;
    padding: 8px 10px;
    width: 100%;
}
.filters-bar .field {
    flex: 1 1 0;
    min-width: 0;
}
.filters-bar .field-grow {
    flex: 1.6 1 0;
}
.filters-bar .filter-actions {
    display: flex;
    gap: 6px;
    align-items: end;
    flex: 0 0 auto;
    margin-left: auto;
}
.filters-bar .filter-actions .btn {
    height: 36px;
    white-space: nowrap;
}

.field { display: grid; gap: 4px; }
.field label {
    font-size: .68rem;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.96);
    font-size: .88rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: #7aa7b4;
    box-shadow: 0 0 0 3px var(--brand-glow);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 9px;
    padding: 9px 14px;
    cursor: pointer;
    font-weight: 700;
    font-size: .88rem;
    letter-spacing: -0.01em;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(11, 61, 74, 0.22); }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-accent { background: linear-gradient(135deg, #f59e0b, #e67e22); color: #fff; box-shadow: 0 8px 18px rgba(230, 126, 34, 0.28); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-sm { padding: 4px 8px; font-size: .74rem; border-radius: 6px; font-weight: 600; }
.btn-nav {
    padding: 5px 9px;
    font-size: .72rem;
    border-radius: 7px;
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.28);
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-master {
    background: linear-gradient(135deg, #0f766e, #0d9488);
    color: #fff;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.28);
}
.form-title {
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 800;
}
.btn-insight {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e40af;
    border: 1px solid #93c5fd;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.18);
    min-width: 88px;
}
.btn-insight:hover {
    background: linear-gradient(135deg, #bfdbfe, #93c5fd);
}

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}
.stat-card.premium {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(145deg, rgba(255,255,255,0.95), rgba(248,250,252,0.9));
    border: 1px solid rgba(198, 210, 222, 0.95);
    box-shadow:
        0 8px 22px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255,255,255,0.9);
}
.stat-card.premium::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #94a3b8;
}
.stat-card.premium.gate::before { background: linear-gradient(180deg, #f87171, #ef4444); }
.stat-card.premium.inside::before { background: linear-gradient(180deg, #fbbf24, #eab308); }
.stat-card.premium.dispatched::before { background: linear-gradient(180deg, #34d399, #10b981); }
.stat-card.premium.hold::before { background: linear-gradient(180deg, #38bdf8, #0ea5e9); }
.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
    background:
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.55), transparent 45%),
        linear-gradient(145deg, #e2e8f0, #cbd5e1);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}
.stat-icon.gate { background: linear-gradient(145deg, #fecaca, #fca5a5); }
.stat-icon.inside { background: linear-gradient(145deg, #fde68a, #fcd34d); }
.stat-icon.dispatched { background: linear-gradient(145deg, #a7f3d0, #6ee7b7); }
.stat-icon.hold { background: linear-gradient(145deg, #bae6fd, #7dd3fc); }
.stat-icon.total { background: linear-gradient(145deg, #c7d2fe, #a5b4fc); }
.stat-body { min-width: 0; }
.stat-card.premium span {
    display: block;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.stat-card.premium strong {
    display: block;
    margin-top: 3px;
    font-size: 1.4rem;
    font-family: var(--mono);
    font-weight: 750;
    letter-spacing: -0.03em;
    color: #0f172a;
}
.stat-card.premium.gate strong { color: #b91c1c; }
.stat-card.premium.inside strong { color: #a16207; }
.stat-card.premium.dispatched strong { color: #047857; }
.stat-card.premium.hold strong { color: #0369a1; }

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.dash-boards {
    align-items: stretch;
    position: relative;
    z-index: 1;
}
.dash-boards .board-panel {
    display: flex;
    flex-direction: column;
    min-height: 260px;
    max-height: 320px;
    overflow: hidden;
    background: #fff;
}
.dash-boards .table-wrap {
    flex: 1;
    overflow: auto;
    max-height: none;
}

.panel { padding: 0; overflow: hidden; position: relative; z-index: 1; }
.panel-fill { display: flex; flex-direction: column; }
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #f7fafc, #eef3f8);
}
.panel-head h2 {
    margin: 0;
    font-size: .92rem;
    font-weight: 750;
    letter-spacing: -0.02em;
}
.panel-head span { color: var(--muted); font-size: .74rem; font-weight: 500; }

/* ===== Excel-like grid ===== */
.table-wrap {
    overflow: auto;
    max-height: min(68vh, 760px);
    background: var(--surface-solid);
}
.table-wrap-tall {
    max-height: min(78vh, 900px);
}
.table-wrap-compact {
    max-height: none;
}
.table-wrap > table,
.panel .table-wrap table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
    border: 1px solid #b7c4d2;
}
.table-wrap-compact > table,
.mini-table {
    min-width: 0 !important;
    width: 100%;
    table-layout: fixed;
}
.mini-table th:nth-child(1),
.mini-table td:nth-child(1) { width: 34%; }
.mini-table th:nth-child(2),
.mini-table td:nth-child(2) { width: 14%; }
.mini-table th:nth-child(3),
.mini-table td:nth-child(3) { width: 32%; }
.mini-table th:nth-child(4),
.mini-table td:nth-child(4) { width: 20%; }
.mini-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}
th, td {
    padding: 6px 8px;
    border: 1px solid var(--grid);
    text-align: left;
    font-size: .8rem;
    vertical-align: middle;
    white-space: nowrap;
    line-height: 1.3;
}
.table-wrap-compact th,
.table-wrap-compact td {
    padding: 5px 7px;
    font-size: .78rem;
}
th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(180deg, #e7eef5, #dbe5ef);
    color: #334155;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 800;
    border-bottom: 1px solid #9aabba;
}
.sortable-th { padding: 0; }
.sort-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 6px 8px;
    cursor: pointer;
}
.sort-btn:hover { background: rgba(15, 76, 92, 0.08); }
.sortable-th.is-sorted { background: linear-gradient(180deg, #d9e8f0, #cfe0eb); }
.sort-arrows {
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    line-height: 0;
}
.arrow {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.35;
}
.arrow.up { border-bottom: 5px solid #64748b; }
.arrow.down { border-top: 5px solid #64748b; }
.arrow.active { opacity: 1; }
.arrow.up.active { border-bottom-color: #0b3d4a; }
.arrow.down.active { border-top-color: #0b3d4a; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.insight-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 2px;
}
.insight-tabs {
    display: inline-flex;
    gap: 6px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255,255,255,0.7);
    border: 1px solid var(--line);
}
.insight-tabs a {
    padding: 7px 12px;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--muted);
}
.insight-tabs a.active {
    background: var(--brand);
    color: #fff;
}
.insight-list { padding: 8px 10px; display: grid; gap: 8px; }
.insight-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--line);
}
.timeline-row { align-items: flex-start; }
.timeline-row small { display: block; color: var(--muted); font-size: .75rem; margin-top: 2px; }
.timeline-meta {
    display: grid;
    gap: 2px;
    text-align: right;
    font-family: var(--mono);
    font-size: .75rem;
    color: #334155;
}

body.modal-open { overflow: hidden; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(15, 23, 42, 0.45);
    display: grid;
    place-items: center;
    padding: 10px 6px;
    overflow: auto;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-card {
    width: min(640px, 100%);
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--line);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    overflow: hidden;
    max-height: calc(100vh - 36px);
    display: flex;
    flex-direction: column;
}
.modal-card-lg {
    width: min(1100px, 96vw);
}
.form-grid[hidden] { display: none !important; }
.insight-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(180deg, #f8fafc, #eef4f8);
    border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-sub { margin: 4px 0 0; color: var(--muted); font-size: .82rem; }
.modal-sub .vehicle { margin-right: 8px; color: var(--brand); }
.modal-body {
    padding: 16px 18px 18px;
    overflow: auto;
    flex: 1 1 auto;
    min-height: 0;
}
.modal-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.modal-actions-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.modal-action-btn {
    display: grid;
    gap: 3px;
    width: 100%;
    text-align: left;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #f8fafc;
    color: inherit;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
}
.modal-action-btn:hover {
    background: #e8f4fb;
    border-color: #93c5fd;
}
.modal-action-btn strong { font-size: .92rem; }
.modal-action-btn span { color: var(--muted); font-size: .75rem; }
.modal-head .icon-btn {
    font-size: 1.2rem;
    line-height: 1;
}
tbody tr:nth-child(even) td { background: var(--zebra); }
tbody tr:hover td { background: #eaf4f8; }
.mono { font-family: var(--mono); font-weight: 600; font-size: .76rem; }
.vehicle {
    font-family: var(--mono);
    font-weight: 700;
    color: #0b3d4a;
    font-size: .78rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: .7rem;
    font-weight: 700;
    border: 1px solid transparent;
}
.badge-scheduled { background: #eef2f7; color: #475569; border-color: #cbd5e1; }
.badge-at_gate { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.badge-inside { background: #fef9c3; color: #a16207; border-color: #fde047; }
.badge-dispatched { background: #d1fae5; color: #047857; border-color: #6ee7b7; }

.hold {
    display: inline-block;
    min-width: 72px;
    text-align: center;
    border-radius: 6px;
    padding: 2px 6px;
    font-family: var(--mono);
    font-weight: 600;
    font-size: .74rem;
    border: 1px solid transparent;
    white-space: nowrap;
}
.hold.good { background: var(--good-bg); color: var(--good); border-color: #99f6e4; }
.hold.warn { background: var(--warn-bg); color: var(--warn); border-color: #fdba74; }
.hold.bad { background: var(--bad-bg); color: var(--bad); border-color: #fca5a5; }
.hold.neutral { background: #f1f5f9; color: #64748b; border-color: #cbd5e1; }

.row-actions { display: flex; gap: 4px; flex-wrap: nowrap; align-items: center; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid #b7d0e0;
    background: linear-gradient(180deg, #ffffff, #f3f8fc);
    color: #0f4c5c;
    box-shadow: 0 2px 6px rgba(15, 76, 92, 0.08);
    transition: background .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease;
    cursor: pointer;
    padding: 0;
}
.icon-btn:hover {
    background: linear-gradient(180deg, #e8f6fb, #d9eef8);
    border-color: #7eb6d0;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 76, 92, 0.12);
}
.row-actions{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:6px;
    white-space:nowrap;
}
.icon-btn-edit {
    color: #0b5f73;
}
a.icon-btn-edit{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    text-decoration:none;
}
.icon-btn-view {
    color: #1d4ed8;
}
.icon-btn-view:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}
.empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 500;
}
.empty-compact { padding: 28px 10px; font-size: .84rem; }

.view-card { padding: 16px; }
.view-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.view-grid > div {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
}
.view-grid > div.full { grid-column: 1 / -1; }
.view-grid span {
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 4px;
}
.view-grid strong { font-size: .95rem; font-weight: 700; }

.form-card {
    padding: 16px;
    width: 100%;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 14px;
}
.modal-card-lg .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.pagination {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 8px 12px;
    border-top: 1px solid var(--line);
    background: #f8fafc;
}
.pagination a, .pagination span {
    padding: 6px 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    font-size: .82rem;
    font-weight: 600;
}
.pagination .active span {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

@media (max-width: 1100px) {
    .stats, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr 1fr; }
    .filters-bar { flex-wrap: wrap; }
    .filters-bar .field { flex: 1 1 160px; }
    .top-nav { gap: 6px; }
    .clock-date { display: none; }
    .clock-sep { display: none; }
    .insight-toolbar { flex-wrap: wrap; }
}
@media (max-width: 980px) {
    .top-nav {
        flex-wrap: wrap;
        justify-content: space-between;
        row-gap: 8px;
    }
    .top-nav-center{
        position:static;left:auto;top:auto;transform:none;
        order:3;width:100%;justify-content:center;gap:8px;flex-wrap:wrap;
        pointer-events:auto;
    }
    .top-links{justify-content:center}
    .party-switch{margin-left:0}
    .top-meta {
        margin-left: auto;
        flex:0 0 auto;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }
    .modal-card-lg .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .main { padding: 6px 2px 10px; }
    .stats, .grid-3, .grid-2, .form-grid { grid-template-columns: 1fr; }
    .filters-bar .field { flex: 1 1 100%; }
    .filters-bar .filter-actions { margin-left: 0; width: 100%; }
    .modal-actions-3 { grid-template-columns: 1fr; }
}


/* ---------- Party mode + sheet tables ---------- */
.party-switch{
    display:inline-flex;align-items:center;gap:0;flex:0 0 auto;
    margin:0;
    border:1px solid rgba(255,255,255,0.28);border-radius:999px;overflow:hidden;
    background:rgba(0,0,0,0.28);white-space:nowrap;
    vertical-align:middle;
}
.scope-nav .party-switch{
    margin:0 2px;
    box-shadow:0 0 0 1px rgba(255,255,255,0.06);
}
.party-tab{
    padding:5px 11px;font-size:.72rem;font-weight:800;color:rgba(248,250,252,.78);
    text-decoration:none;letter-spacing:.01em;white-space:nowrap;
    border-radius:0;box-shadow:none;
}
.top-links .party-tab{
    padding:5px 11px;border-radius:0;font-size:.72rem;font-weight:800;
}
.party-tab:hover{color:#fff;background:rgba(255,255,255,.08)}
.party-tab.active{color:#0f172a;background:#fff}
.party-tab-supplier.active,.top-links .party-tab-supplier.active{background:#dbeafe;color:#0f172a}
.party-tab-customer.active,.top-links .party-tab-customer.active{background:#fef3c7;color:#0f172a}
.party-tab-plant.active,.top-links .party-tab-plant.active{background:#dcfce7;color:#0f172a}
.live-chip{flex-shrink:0;white-space:nowrap}
.top-brand-block .live-chip{
    padding:5px 10px;
    border-radius:999px;
}
.th-span{
    text-align:center !important;
    text-transform:none !important;
    letter-spacing:0 !important;
    font-size:.92rem !important;
    background:#fff !important;
    color:#0f172a !important;
    position:sticky;top:0;z-index:3;
}
.sheet-table{min-width:1280px;width:100%}
.sheet-table-plant{min-width:1180px}
.sheet-table th{text-align:center;white-space:normal;line-height:1.25;max-width:160px}
.sheet-table th.th-hold{
    background:#fff7ed !important;
    color:#9a3412 !important;
    font-size:.72rem !important;
    max-width:140px;
}
.sheet-table th.th-hold small{
    display:block;font-weight:600;opacity:.85;margin-top:2px;text-transform:none;letter-spacing:0;
}
.sheet-table td.th-gate-report,
.sheet-table-plant td.th-gate-report{
    background:#fef9c3;
    font-weight:700;
}
.sheet-table-plant td:nth-child(10),
.sheet-table-plant td:nth-child(11),
.sheet-table-plant td:nth-child(12),
.sheet-table:not(.sheet-table-plant) td:nth-child(16),
.sheet-table:not(.sheet-table-plant) td:nth-child(17),
.sheet-table:not(.sheet-table-plant) td:nth-child(18){white-space:nowrap;text-align:center}

.sheet-table-plant td.plant-vehicle-hover{
    cursor:pointer;
    position:relative;
}
.sheet-table-plant td.plant-vehicle-hover:hover{
    background:#d9eef8!important;
    text-decoration:underline;
}
.outward-hover-modal{
    position:fixed;
    inset:0;
    z-index:85;
    display:grid;
    place-items:center;
    padding:16px;
    pointer-events:none;
    background:rgba(15,23,42,.28);
}
.outward-hover-modal[hidden]{display:none!important}
.outward-hover-card{
    pointer-events:auto;
    width:min(520px,96vw);
    max-height:min(78vh,640px);
    overflow:auto;
    background:#fff;
    border-radius:14px;
    border:1px solid var(--line);
    box-shadow:0 22px 50px rgba(15,23,42,.28);
}
.outward-hover-head{
    padding:14px 16px;
    background:linear-gradient(180deg,#f8fafc,#eef4f8);
    border-bottom:1px solid var(--line);
}
.outward-hover-head h2{margin:0;font-size:1.02rem}
.outward-hover-body{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px 14px;
    padding:14px 16px 16px;
}
.outward-hover-row{
    display:grid;
    gap:2px;
}
.outward-hover-row span{
    font-size:.68rem;
    text-transform:uppercase;
    letter-spacing:.04em;
    color:var(--muted);
}
.outward-hover-row strong{
    font-size:.86rem;
    font-weight:650;
    color:#0f172a;
    word-break:break-word;
}
.outward-hover-empty{
    padding:22px 16px;
    text-align:center;
    color:var(--muted);
    font-size:.9rem;
}
.sheet-table td{text-align:center}
.table-wrap{width:100%}
.panel-fill{width:100%}
.entry-table-title{
    margin:0 0 12px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;
    text-align:center;font-weight:800;font-size:1rem;background:#fff;
}
.linkish{
    appearance:none;border:0;background:transparent;color:var(--brand);font:inherit;font-weight:750;
    cursor:pointer;padding:0;text-decoration:underline;text-underline-offset:2px;
}
.field label{
    display:block;font-size:.72rem;font-weight:700;color:#475569;margin-bottom:4px;
}
.field input,.field select,.field textarea{
    width:100%;padding:8px 10px;border:1px solid #d0dbe8;border-radius:8px;background:#fff;
}
.field input:focus,.field select:focus,.field textarea:focus{
    outline:none;border-color:#93c5fd;box-shadow:0 0 0 3px rgba(59,130,246,.15);
}
.modal-card-lg .form-actions{
    position:sticky;bottom:0;background:#fff;padding-top:12px;margin-top:16px;
    border-top:1px solid var(--line);
}

.panel-head-inline{justify-content:flex-start;gap:10px}
.panel-head-inline h2{display:inline-flex;align-items:baseline;gap:10px;flex-wrap:wrap}
.panel-count{font-size:.78rem;font-weight:650;color:var(--muted);letter-spacing:0}
