/* B/L Desk — antarmuka meja dokumen Bill of Lading.
   Bahasa visual: terminal peti kemas. Baja, dinding bergelombang, pelat nomor kuning,
   cap karet untuk status. Tanpa font eksternal dan tanpa build step. */

:root {
    --ink: #1d272e;
    --ink-2: #44525c;
    --ink-3: #66757f;
    --paper: #edf0ef;
    --paper-2: #e3e8e6;
    --card: #fafbfa;
    --rule: #c6cfcc;
    --rule-2: #dde3e0;

    --yard: #1e6b57;
    --yard-ink: #14493b;
    --yard-tint: #d9eae4;
    --sea: #2d5e7e;
    --sea-tint: #dbe8f0;
    --mustard: #8a5f00;
    --mustard-tint: #f4e8c8;
    --plate: #e0a526;
    --oxide: #a8432c;
    --oxide-tint: #f4ddd6;

    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --font-display: Bahnschrift, "DIN Alternate", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
    --font-mono: "Cascadia Mono", "SF Mono", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 15px/1.5 var(--font-body);
    color: var(--ink);
    background: var(--paper);
}

a { color: var(--sea); }
a:hover { color: var(--ink); }

:focus-visible { outline: 3px solid var(--sea); outline-offset: 2px; }

h1, h2, h3, p { margin: 0; }

h1 { font: 600 1.9rem/1.15 var(--font-display); letter-spacing: .01em; margin-top: .1rem; }

h2 {
    font: 600 .8rem/1.2 var(--font-display);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin-bottom: .8rem;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.caps { text-transform: uppercase; }
.dim, .muted { color: var(--ink-3); }
.block { white-space: pre-line; margin: 0; }
.r { text-align: right; }

.sr {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
    position: absolute; left: -999px; top: 0; background: var(--plate); color: var(--ink);
    padding: .5rem 1rem; z-index: 10; font-weight: 600;
}
.skip:focus { left: 0; }

/* ------------------------------------------------------------ Kerangka */

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

.rail {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column;
    padding: 1.25rem 1.4rem 1.25rem 1.1rem;
    background: var(--ink); color: #dce4e1;
}

/* Dinding peti kemas: rusuk vertikal di tepi sidebar. */
.rail::after {
    content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 10px;
    background: repeating-linear-gradient(90deg, #2c3a43 0 3px, #1d272e 3px 6px);
}

.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; margin-bottom: 1.8rem; }

.brand-mark {
    font: 700 1.05rem/1 var(--font-display);
    letter-spacing: .06em;
    background: var(--plate); color: var(--ink);
    padding: .3rem .45rem; border-radius: 2px;
}

.brand-word { font: 600 1.1rem/1 var(--font-display); letter-spacing: .24em; text-transform: uppercase; }

.nav { display: grid; gap: .15rem; }

.nav a {
    display: block; padding: .55rem .75rem;
    color: #c4cfcb; text-decoration: none;
    border-left: 3px solid transparent;
    font: 600 .86rem var(--font-display); letter-spacing: .08em; text-transform: uppercase;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.nav a.active { color: #fff; background: rgba(255, 255, 255, .08); border-left-color: var(--plate); }

.rail-foot { margin-top: auto; display: grid; gap: .7rem; }
.who { display: grid; line-height: 1.3; }
.who strong { font-weight: 600; }
.who span { color: #93a19b; font-size: .8rem; }

.main { padding: 2rem clamp(1rem, 3vw, 2.5rem) 4rem; max-width: 1240px; width: 100%; }

.page { display: grid; gap: 1rem; align-content: start; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }

.eyebrow { font: 600 .72rem/1 var(--font-display); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }

.sub { color: var(--ink-2); margin-top: .4rem; }

.docno { font-size: 2.2rem; letter-spacing: .02em; font-weight: 600; }

/* ------------------------------------------------------------ Kartu & tabel */

.card {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 1.1rem 1.25rem;
}
.card.flush { padding: 0; overflow: hidden; }
.card-pad { padding: 1rem 1.25rem .15rem; }

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

.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }

.tbl th {
    text-align: left; white-space: nowrap;
    font: 600 .7rem/1.2 var(--font-display); letter-spacing: .12em; text-transform: uppercase;
    color: var(--ink-2); background: var(--paper-2);
    padding: .6rem .9rem;
}
.tbl th.r, .tbl td.r { text-align: right; }

.tbl td { padding: .7rem .9rem; border-top: 1px solid var(--rule-2); vertical-align: top; }
.tbl tbody tr:hover { background: #f1f5f3; }
.tbl tfoot th { border-top: 2px solid var(--ink); background: var(--card); font-size: .8rem; color: var(--ink); }

.docno-link { font-weight: 600; color: var(--ink); text-underline-offset: 3px; }
.ver {
    font: 600 .7rem var(--font-mono); margin-left: .4rem; padding: .05rem .35rem;
    border: 1px solid var(--rule); border-radius: 3px; color: var(--ink-3);
}
.route-cell { white-space: nowrap; }
.arrow { color: var(--ink-3); }

/* ------------------------------------------------------------ Status */

.st-draft            { --tone: #5d6b74; --tone-bg: #e6ebe9; }
.st-pending_approval { --tone: #8a5f00; --tone-bg: #f4e8c8; }
.st-approved         { --tone: #2d5e7e; --tone-bg: #dbe8f0; }
.st-issued           { --tone: #1e6b57; --tone-bg: #d9eae4; }
.st-released         { --tone: #0f5568; --tone-bg: #d3e8ee; }
.st-closed           { --tone: #33424b; --tone-bg: #d9dfdd; }
.st-cancelled        { --tone: #a8432c; --tone-bg: #f4ddd6; }

.bk-open      { --tone: #2d5e7e; --tone-bg: #dbe8f0; }
.bk-confirmed { --tone: #1e6b57; --tone-bg: #d9eae4; }
.bk-closed    { --tone: #33424b; --tone-bg: #d9dfdd; }
.bk-cancelled { --tone: #a8432c; --tone-bg: #f4ddd6; }

.badge {
    display: inline-block; white-space: nowrap;
    font: 600 .7rem/1 var(--font-display); letter-spacing: .1em; text-transform: uppercase;
    color: var(--tone); background: var(--tone-bg);
    border: 1px solid var(--tone); border-radius: 3px;
    padding: .28rem .5rem;
}

/* Cap karet: tanda tangan visual halaman detail. */
.stamp {
    color: var(--tone);
    font: 700 1.15rem/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase;
    padding: .55rem .9rem;
    border: 2px solid currentColor; border-radius: 3px;
    box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3px currentColor;
    transform: rotate(-2.5deg);
    opacity: .92;
    user-select: none;
}

/* ------------------------------------------------------------ Rel siklus hidup */

.lifecycle { display: flex; list-style: none; margin: 0; padding: 0; }

.lifecycle li {
    flex: 1; position: relative; text-align: center;
    font: 600 .72rem/1.2 var(--font-display); letter-spacing: .1em; text-transform: uppercase;
    color: var(--ink-3);
}

.lifecycle li + li::before {
    content: ""; position: absolute; top: 8px; right: 50%; width: 100%; height: 3px;
    background: var(--rule);
}

.lifecycle .dot {
    position: relative; z-index: 1; display: block; margin: 0 auto;
    width: 19px; height: 19px; border-radius: 50%;
    background: var(--card); border: 3px solid var(--rule);
}

.step-label { display: block; margin-top: .5rem; }

.lifecycle .is-done::before, .lifecycle .is-now::before { background: var(--yard); }
.lifecycle .is-done .dot { background: var(--yard); border-color: var(--yard); }
.lifecycle .is-now .dot { border-color: var(--yard); box-shadow: 0 0 0 5px var(--yard-tint); }
.lifecycle .is-now { color: var(--ink); }

/* ------------------------------------------------------------ Aksi */

.actionbar { display: grid; gap: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.pdfs { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1.1rem; font-size: .9rem; }

.panel { display: grid; gap: .8rem; border-top: 1px dashed var(--rule); padding-top: 1rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: 600 .9rem/1.2 var(--font-body);
    padding: .58rem 1.05rem; border-radius: 4px; border: 1px solid transparent;
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn[disabled], .btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--yard); color: #fff; }
.btn-primary:hover { background: var(--yard-ink); color: #fff; }

.btn-quiet { background: var(--card); color: var(--ink); border-color: var(--rule); }
.btn-quiet:hover { background: var(--paper-2); color: var(--ink); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--oxide); background: var(--oxide-tint); }

.btn-danger { background: var(--card); color: var(--oxide); border-color: var(--oxide); }
.btn-danger:hover { background: var(--oxide-tint); color: var(--oxide); }

.btn-rail { background: transparent; color: #dce4e1; border-color: rgba(255, 255, 255, .28); width: 100%; }
.btn-rail:hover { background: rgba(255, 255, 255, .08); }

.btn-sm { padding: .32rem .65rem; font-size: .82rem; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------ Rute */

.route-card { padding-top: 1.4rem; padding-bottom: 1.2rem; }
.route { display: flex; align-items: center; gap: 1.2rem; }
.route-end { display: grid; gap: .1rem; min-width: 7rem; }
.route-end.right { text-align: right; }
.route-end strong { font-size: 1.8rem; letter-spacing: .06em; line-height: 1.1; }

.route-line {
    position: relative; flex: 1; height: 2px;
    background: repeating-linear-gradient(90deg, var(--ink-3) 0 7px, transparent 7px 13px);
}
.route-line span {
    position: absolute; right: -2px; top: -6px;
    border-left: 10px solid var(--ink-3); border-top: 7px solid transparent; border-bottom: 7px solid transparent;
}

.facts {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem 1.2rem;
    margin: 1.1rem 0 0; padding-top: 1rem; border-top: 1px solid var(--rule-2);
}
.facts dt, .totals dt {
    font: 600 .68rem/1.2 var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3);
}
.facts dd, .totals dd { margin: .2rem 0 0; }

.lbl {
    font: 600 .72rem/1.2 var(--font-display); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
}

/* ------------------------------------------------------------ Grid & form */

.grid { display: grid; gap: .9rem 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: 1.7fr 1fr .8fr .9fr auto; }
.split { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
.span-1 { grid-column: span 1; }
.span-2 { grid-column: span 2; }

.stack { display: grid; gap: .9rem; align-content: start; }
.stack-lg { display: grid; gap: 1rem; }

.field { display: grid; gap: .3rem; align-content: start; min-width: 0; }

input, select, textarea {
    font: inherit; color: var(--ink); background: #fff;
    width: 100%; padding: .5rem .6rem;
    border: 1px solid var(--rule); border-radius: 4px;
}
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--yard); box-shadow: 0 0 0 3px var(--yard-tint);
}
select:disabled { background: var(--paper-2); color: var(--ink-3); }

.hint { color: var(--ink-3); font-size: .78rem; }
.err { color: var(--oxide); font-size: .82rem; font-weight: 600; }

.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.check.inline { margin-top: .35rem; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.section-head h2 { margin: 0; }

.rowcard {
    display: grid; gap: .8rem;
    background: #fff; border: 1px solid var(--rule); border-radius: 6px;
    padding: .9rem; margin-bottom: .8rem;
}
.rowcard.compact { padding: .7rem .9rem; }
.rowcard-head { display: flex; justify-content: space-between; align-items: center; }
.rowcard-title { font: 600 .72rem/1 var(--font-display); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.row-end { align-self: end; }

.totals {
    display: flex; flex-wrap: wrap; gap: .5rem 2.5rem;
    margin: .4rem 0 0; padding-top: .9rem; border-top: 2px solid var(--ink);
}
.totals > div { display: block; }

.formbar {
    position: sticky; bottom: 0; z-index: 2;
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .9rem 0 .4rem;
    background: linear-gradient(to bottom, transparent, var(--paper) 35%);
}

/* ------------------------------------------------------------ Komponen kecil */

.alert {
    padding: .75rem 1rem; border: 1px solid; border-left-width: 5px; border-radius: 4px;
    background: var(--card);
}
.alert ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.alert.ok   { border-color: var(--yard);    background: var(--yard-tint); color: var(--yard-ink); }
.alert.bad  { border-color: var(--oxide);   background: var(--oxide-tint); color: #7a2d1c; }
.alert.warn { border-color: var(--mustard); background: var(--mustard-tint); color: #5c4000; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: .8rem 1.5rem; flex-wrap: wrap; }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; }
.tab {
    font: 600 .8rem/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase;
    padding: .55rem .8rem; border-radius: 3px; cursor: pointer;
    background: transparent; color: var(--ink-2); border: 1px solid transparent;
}
.tab:hover { background: var(--paper-2); }
.tab.on { background: var(--ink); color: #fff; }
.count { font-family: var(--font-mono); margin-left: .35rem; opacity: .7; }

.search input { min-width: 270px; }
.filter select { min-width: 180px; }

.pager {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: .7rem 1rem; border-top: 1px solid var(--rule-2); color: var(--ink-3); font-size: .88rem;
}
.pager-btns { display: flex; gap: .4rem; }

.empty { display: grid; gap: .4rem; justify-items: center; text-align: center; padding: 2.5rem 1rem; color: var(--ink-2); }
.empty strong { color: var(--ink); font-size: 1.05rem; }
.empty .btn { margin-top: .6rem; }

.entry { padding: .65rem 0; border-top: 1px solid var(--rule-2); }
.entry:first-of-type { border-top: 0; padding-top: 0; }
.entry.log { display: grid; grid-template-columns: 150px 1fr; gap: .75rem; }
.when { color: var(--ink-3); font-size: .85rem; }

/* ------------------------------------------------------------ Halaman masuk */

body.guest { background: repeating-linear-gradient(90deg, #25323b 0 6px, #1d272e 6px 12px); }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }

.gate-card {
    width: min(410px, 100%);
    background: var(--card); border-radius: 6px; border-top: 6px solid var(--plate);
    padding: 2rem 2rem 1.6rem; display: grid; gap: .9rem;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.gate-logo { background: #fff; border: 1px solid var(--rule-2); border-radius: 4px; padding: .6rem; display: grid; place-items: center; }
.gate-logo img { display: block; width: 100%; max-width: 250px; height: auto; }

.demo { font-size: .85rem; color: var(--ink-2); border-top: 1px solid var(--rule-2); padding-top: .8rem; }
.demo summary { cursor: pointer; font-weight: 600; }
.demo ul { margin: .4rem 0 0; padding-left: 1.1rem; }
.demo code { font-family: var(--font-mono); }

/* ------------------------------------------------------------ Dashboard */

.queue { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem; }
.qtile {
    display: grid; gap: .2rem; align-content: start;
    padding: .9rem 1.1rem 1rem;
    background: var(--card); border: 1px solid var(--rule); border-left: 5px solid var(--rule);
    border-radius: 6px; text-decoration: none; color: var(--ink);
}
.qtile:hover { background: #fff; border-color: var(--ink-3); }
.qtile.mine { border-left-color: var(--tone); background: var(--tone-bg); }
.qtile.mine:hover { filter: brightness(.97); }
.qtile-n { font-size: 2.3rem; font-weight: 700; line-height: 1; color: var(--ink-3); }
.qtile.mine .qtile-n { color: var(--tone); }
.qtile-label { font: 600 .82rem/1.2 var(--font-display); letter-spacing: .08em; text-transform: uppercase; margin-top: .35rem; }
.qtile-hint { font-size: .85rem; color: var(--ink-2); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; }
.kpi { display: grid; gap: .1rem; padding: .8rem 1.1rem; background: var(--card); border: 1px solid var(--rule); border-radius: 6px; }
.kpi-n { font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.kpi-l { font-size: .85rem; color: var(--ink-2); }

.dist-bar { display: flex; height: 22px; gap: 2px; border-radius: 3px; overflow: hidden; background: var(--paper-2); }
.dist-seg { background: var(--tone); min-width: 4px; }
.legend { list-style: none; margin: .9rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .35rem 1rem; }
.legend a { display: flex; align-items: center; gap: .5rem; color: var(--ink); text-decoration: none; font-size: .9rem; }
.legend a:hover { text-decoration: underline; text-underline-offset: 3px; }
.legend b { margin-left: auto; }
.sw { width: .8rem; height: .8rem; border-radius: 2px; background: var(--tone); flex: none; }

.trend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: .6rem; align-items: end; height: 170px; }
.trend-col { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; align-items: end; gap: .3rem; height: 100%; }
.trend-bar { width: 100%; max-width: 46px; background: var(--rule); border-radius: 3px 3px 0 0; align-self: end; }
.trend-col.now .trend-bar { background: var(--yard); }
.trend-n { font-size: .85rem; color: var(--ink-2); }
.trend-l { font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }

.count-pill { background: var(--ink); color: var(--card); border-radius: 999px; padding: .1rem .55rem; font-size: .8rem; }
.bk-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.bk-meta { font-size: .85rem; margin: .15rem 0 .45rem; }
.tag { font: 600 .68rem/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase; padding: .22rem .45rem; border-radius: 3px; color: var(--ink-2); background: var(--paper-2); }
.tag.soon { color: var(--mustard); background: var(--mustard-tint); }
.tag.late { color: var(--oxide); background: var(--oxide-tint); }
.more { margin-top: .8rem; font-size: .88rem; }

/* ------------------------------------------------------------ Responsif */

@media (max-width: 1100px) {
    .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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

    .rail {
        position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
        gap: .6rem 1.2rem; padding: .8rem 1rem;
    }
    .rail::after { display: none; }
    .brand { margin-bottom: 0; }
    .nav { display: flex; flex-wrap: wrap; }
    .nav a { padding: .4rem .6rem; }
    .rail-foot { margin: 0 0 0 auto; display: flex; align-items: center; gap: .8rem; }
    .who span { display: none; }
    .btn-rail { width: auto; }

    .main { padding-top: 1.2rem; }
    h1 { font-size: 1.55rem; }
    .docno { font-size: 1.7rem; }

    .g2, .g3, .g4, .g5, .split { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }

    .route-end strong { font-size: 1.4rem; }
    .search input { min-width: 0; width: 100%; }
    .search { flex: 1 1 100%; }
    .entry.log { grid-template-columns: 1fr; gap: .1rem; }
    .lifecycle li { font-size: .62rem; letter-spacing: .04em; }
    .trend { height: 140px; gap: .3rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
    .rail, .actionbar, .formbar, .toolbar { display: none; }
    .shell { display: block; }
    body { background: #fff; }
}
