/* Superkul TMS — base stylesheet (no external fonts/CDNs; CSP: style-src 'self'). */

:root {
    --ink: #0f1d2b;
    --ink-2: #33475b;
    --muted: #64748b;
    --line: #dde3ea;
    --line-strong: #c7d0db;
    --bg: #f3f6f9;
    --surface: #ffffff;
    --sidebar: #0d2133;
    --sidebar-ink: #c9d6e3;
    --sidebar-active: #15354f;
    --accent: #0b7285;
    --accent-ink: #ffffff;
    --accent-soft: #e3f4f6;
    --ok: #1f7a46;
    --ok-soft: #e5f4ea;
    --warn: #8a5a00;
    --warn-soft: #fff4d6;
    --err: #b42318;
    --err-soft: #fdecea;
    --info: #1d4f91;
    --info-soft: #e8f0fb;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(15, 29, 43, .06), 0 1px 1px rgba(15, 29, 43, .04);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
code, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
:focus-visible { outline: 3px solid #5ab8c9; outline-offset: 2px; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Shell */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 12px; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #12a3b8, #0b5f73); color: #fff; font-weight: 700; letter-spacing: .5px; font-size: 13px; }
.brand-mark-lg { width: 44px; height: 44px; font-size: 16px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text small { font-size: 11px; letter-spacing: .3px; color: #8fa6bb; }
.nav-section { margin: 14px 0; }
.nav-heading { margin: 0 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7d93a8; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.nav-link { display: block; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--sidebar-ink); text-decoration: none; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.is-active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #2bb3c8; }

.main-col { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 24px; position: sticky; top: 0; z-index: 10; }
.topbar-title { font-weight: 600; color: var(--ink-2); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; }
.user-roles { font-size: 12px; color: var(--muted); }
.nav-toggle { display: none; }
.content { padding: 24px; max-width: 1280px; width: 100%; }
.content:focus { outline: none; }
.footer { margin-top: auto; padding: 14px 24px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); }

/* ---------- Typography helpers */
.h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; }
.h2 { font-size: 19px; margin: 0 0 6px; }
.h3 { font-size: 16px; margin: 0 0 10px; }
.h4 { font-size: 14px; margin: 0 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xsmall { font-size: 11px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
p { margin: 0 0 10px; }

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

/* ---------- Cards & layout grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.narrow { max-width: 560px; }
.table-card { padding: 0; overflow-x: auto; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.role-card { margin-bottom: 0; }
.grid-4 + .card { margin-top: 16px; }
.link-list { margin: 0; padding-left: 18px; }

/* ---------- Forms */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; margin: 0; min-width: 0; }
fieldset.field { border: 0; padding: 0; }
legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
label { font-weight: 600; font-size: 13px; color: var(--ink-2); }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=submit]), select {
    width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: #fff; font: inherit; color: var(--ink);
}
input:focus, select:focus { border-color: var(--accent); outline: 2px solid rgba(11, 114, 133, .2); outline-offset: 0; }
.has-error input, .has-error select { border-color: var(--err); }
.field-error { color: var(--err); font-size: 12.5px; margin: 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 6px; cursor: pointer; }
.check:hover { border-color: var(--line-strong); }
.check input { margin-top: 3px; }
.check span { display: flex; flex-direction: column; }
.check small { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 8px; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; }
.field-actions { display: flex; gap: 8px; align-items: end; }
.inline { display: inline; margin: 0; }

/* ---------- Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #095e6e; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #eef2f6; }
.btn-danger { background: var(--surface); color: var(--err); border-color: #f1b8b2; }
.btn-danger:hover { background: var(--err-soft); }

/* ---------- Alerts, badges, chips */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cb; }
.alert-info { background: var(--info-soft); color: var(--info); border-color: #c7d9f3; }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: #f2dc9b; }
.alert-error { background: var(--err-soft); color: var(--err); border-color: #f5c2bc; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; margin-right: 4px; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-off { background: #edf0f3; color: var(--muted); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--accent-soft); color: #075563; font-size: 12px; margin: 1px 4px 1px 0; }

/* ---------- Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); position: sticky; top: 0; }
.table tbody tr:hover { background: #fafcfd; }
.table td.right, .table th.right { text-align: right; }
.table td.center, .table th.center { text-align: center; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
.matrix .tick { color: var(--ok); font-weight: 700; }
.matrix .dash { color: #b5c0cc; }
.audit pre { margin: 4px 0 0; padding: 8px; background: #f6f8fa; border: 1px solid var(--line); border-radius: 4px; max-height: 240px; overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.audit details summary { cursor: pointer; color: var(--accent); }
.diff { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; min-width: 200px; max-width: 520px; }
.reason { margin: 0 0 4px; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; }
.pager { display: flex; align-items: center; gap: 8px; }

.secret-box { display: flex; align-items: center; gap: 10px; padding: 12px; background: #f6f8fa; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); }
.secret-box code { font-size: 16px; letter-spacing: .5px; user-select: all; }

/* ---------- Auth / error pages */
body.auth { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, #d9eef2 0%, transparent 60%) no-repeat, var(--bg); }
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 64px 16px 32px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-brand strong { display: block; font-size: 18px; }
.auth-brand div span { display: block; color: var(--muted); font-size: 13px; }
.auth-card { padding: 24px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
.error-status { font-size: 40px; font-weight: 700; color: var(--line-strong); margin: 0; }
.error-details { padding-left: 18px; }

/* ---------- Responsive */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; z-index: 40; }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 20, 30, .35); }
    .nav-toggle { display: inline-flex; padding: 6px 10px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-sm); font: inherit; cursor: pointer; }
    .topbar { padding: 10px 16px; }
    .user-roles { display: none; }
    .content { padding: 16px; }
    .diff { grid-template-columns: 1fr; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---------- Gate 2: forms, masters, orders */
textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; color: var(--ink); background: #fff; resize: vertical; }
textarea:focus { border-color: var(--accent); outline: 2px solid rgba(11, 114, 133, .2); outline-offset: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.req { color: var(--err); }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; cursor: pointer; }
.alias-list { list-style: none; padding: 0; margin: 0 0 12px; }
.alias-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-pad { padding: 18px 20px 0; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 12px 0; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; }

.stop-row { border: 1px solid var(--line); border-left: 4px solid #7cc4d2; border-radius: var(--radius-sm); padding: 12px 14px 8px; margin: 0 0 12px; background: #fcfdfe; }
.stop-row.stop-pickup { border-left-color: #2f7d4f; }
.stop-legend { padding: 0 6px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.stop-no { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 13px; background: var(--sidebar); color: #fff; font-size: 12px; }
.stop-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.stop-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 6px; }
.stop-row.stop-pickup .weight-field { display: none; }
[data-load="FTL"] .weight-field .hint::after { content: " Opsional untuk FTL."; }
[data-load="LTL"] .stop-dropoff .weight-field label::after { content: " *"; color: var(--err); }
.chip-pickup { background: #e5f4ea; color: #1f7a46; }
.chip-dropoff { background: #e8f0fb; color: #1d4f91; }

.status { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #edf0f3; color: var(--ink-2); vertical-align: middle; font-family: var(--font); }
.status-confirmed { background: var(--info-soft); color: var(--info); }
.status-assigned { background: #efe9fb; color: #5b3a9e; }
.status-in_transit { background: var(--warn-soft); color: var(--warn); }
.status-delivered_awaiting_pod { background: #fff0e0; color: #9a4b00; }
.status-completed { background: var(--ok-soft); color: var(--ok); }
.status-cancelled { background: var(--err-soft); color: var(--err); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 12px 10px; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #9fb3c4; }
[data-assign-panel][hidden] { display: none; }

@media (max-width: 860px) {
    .form-grid, .stop-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
}

/* ---- Pricing (Gate 3) */
[hidden] { display: none !important; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.card-head .h3 { margin: 0; }
.table-scroll { overflow-x: auto; }
.table.compact th, .table.compact td { padding: 6px 8px; }
.table.compact input, .table.compact select { min-width: 110px; }
.pricing-sides { gap: 20px; }
.pricing-side { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; min-width: 0; }
.pricing-side .h4 { margin-top: 0; }
.price-total { font-size: 22px; font-weight: 700; margin: 0 0 4px; font-variant-numeric: tabular-nums; }
.price-lines td.right { font-variant-numeric: tabular-nums; }
.pricing-preview { border-top: 1px dashed var(--line-strong); margin-top: 10px; padding-top: 8px; }
.pricing-side details { margin-top: 8px; }
.pricing-side summary, details.version summary { cursor: pointer; color: var(--ink-2); }
.compact-form { margin-top: 8px; }
.compact-form .field { margin-bottom: 8px; }
.contribution { margin-top: 14px; }
details.version { border-top: 1px solid var(--line); padding: 8px 0; }
details.version[open] summary { margin-bottom: 8px; }

/* ---- POD (Gate 4) */
.pod-scope { border-top: 1px solid var(--line); padding: 10px 0; }
.pod-scope:first-child { border-top: 0; padding-top: 0; }
.pod-scope p { margin: 0 0 6px; }
.pod-docs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pod-doc { display: flex; gap: 12px; align-items: flex-start; }
.pod-thumb { width: 72px; height: 72px; object-fit: cover; border: 1px solid var(--line); border-radius: var(--radius-sm); flex: none; background: #f8fafc; }
.pod-pdf { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--err); text-decoration: none; }
.pod-meta { min-width: 0; overflow-wrap: anywhere; }
.pod-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; margin-top: 6px; }
.inline-form { display: inline; margin: 0; }

/* ---- Internal costs (Gate 4) */
.cost-summary { margin-bottom: 8px; }
tr.voided td { color: var(--muted); }
.allowance { border-top: 1px solid var(--line); padding: 8px 0; }
.allowance p { margin: 0 0 4px; }
.add-cost { margin: 10px 0; }
