/* ============================================================
   DistriNusa — Sistem Distribusi Multi-Depo
   Identitas: petrol "laut Jawa" + amber "gula jawa"
   Tipografi: Plus Jakarta Sans (variable) + IBM Plex Mono
   ============================================================ */

@font-face {
  font-family: 'Plus Jakarta Sans';
  src: url('/static/fonts/plus-jakarta-sans-wght.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/ibm-plex-mono-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/ibm-plex-mono-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}

:root {
  --bg: #EFF3F2;
  --surface: #FFFFFF;
  --surface2: #F6FAF9;
  --line: #DFE7E5;
  --line2: #CBD8D5;
  --ink: #152528;
  --ink2: #46595C;
  --ink3: #75898B;

  --teal-950: #062E33;
  --teal-900: #0A3A40;
  --teal-800: #0D4A52;
  --teal-700: #0F5A63;
  --teal-600: #127078;
  --teal-500: #178A91;
  --teal-100: #D8ECEC;
  --teal-50: #ECF6F6;

  --amber-700: #8F5715;
  --amber-600: #B26E1E;
  --amber-500: #D98A2B;
  --amber-100: #F7E7CC;
  --amber-50: #FBF4E6;

  --green-700: #17663A;
  --green-600: #1E7B47;
  --green-50: #E6F4EC;
  --red-700: #96302A;
  --red-600: #B23B34;
  --red-50: #F9E9E7;
  --blue-600: #2A78D6;
  --blue-50: #E8F0FB;

  --r-lg: 16px;
  --r-md: 11px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(6, 46, 51, .05), 0 10px 28px -14px rgba(6, 46, 51, .14);
  --shadow-sm: 0 1px 2px rgba(6, 46, 51, .07);
  --sidebar-w: 248px;
  --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.015em; }
.ic { width: 18px; height: 18px; flex: 0 0 auto; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.muted { color: var(--ink3); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
:focus-visible { outline: 2px solid var(--teal-500); outline-offset: 2px; border-radius: 4px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 22px 26px 48px; max-width: 1460px; width: 100%; margin: 0 auto; }

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: linear-gradient(178deg, var(--teal-950) 0%, var(--teal-900) 62%, #0B3E45 100%);
  color: #AFCFD2;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.side-logo {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 18px 16px;
}
.side-logo img { width: 38px; height: 38px; }
.side-logo .nm { font-size: 17.5px; font-weight: 800; color: #fff; letter-spacing: -.02em; line-height: 1.1; }
.side-logo .tg { font-size: 10.5px; color: #7FB2B6; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; }
.side-route { padding: 0 18px 6px; opacity: .55; }
.side-nav { padding: 6px 12px 12px; flex: 1; }
.nav-sec {
  font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: #6FA4A9; padding: 16px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8.5px 10px; margin: 1px 0;
  border-radius: 9px; color: #C6DDDF; font-weight: 550; font-size: 13.5px;
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255, 255, 255, .10); color: #fff; font-weight: 700; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3.5px;
  border-radius: 0 4px 4px 0; background: var(--amber-500);
}
.nav-item .ic { width: 17px; height: 17px; opacity: .85; }
.side-user {
  margin: 10px 12px 14px; padding: 11px 12px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 12px; display: flex; align-items: center; gap: 10px;
}
.side-user .who { flex: 1; min-width: 0; }
.side-user .who b { color: #fff; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { font-size: 11.5px; color: #8FBBBF; }
.side-user form { margin: 0; }
.side-user button {
  background: none; border: 0; color: #9CC3C7; cursor: pointer; padding: 6px; border-radius: 8px; display: flex;
}
.side-user button:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--amber-500), #C2761F);
  color: #FFF8EC; font-weight: 800; font-size: 13px; letter-spacing: .02em;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 15px 26px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.tb-title h1 { font-size: 19px; font-weight: 800; }
.tb-title .tb-sub { font-size: 12.5px; color: var(--ink3); margin-top: 1px; }
.tb-right { display: flex; align-items: center; gap: 10px; }
.tb-date { font-size: 12.5px; color: var(--ink3); padding-right: 6px; }
.burger { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px; cursor: pointer; color: var(--ink2); }

/* ---------- kartu & grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; } .col-12 { grid-column: span 12; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 20px 0;
}
.card-head.bordered { padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.card-title { font-size: 14.5px; font-weight: 800; letter-spacing: -.01em; }
.card-title .muted { font-weight: 550; }

/* KPI */
.kpi { padding: 16px 18px 15px; position: relative; overflow: hidden; }
.kpi .lbl { font-size: 12px; color: var(--ink2); font-weight: 650; letter-spacing: .02em; }
.kpi .val { font-size: 24px; font-weight: 800; letter-spacing: -.03em; margin-top: 3px; }
.kpi .foot { margin-top: 7px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.kpi .ic-wrap {
  position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.kpi.k-teal .ic-wrap { background: var(--teal-50); color: var(--teal-600); }
.kpi.k-amber .ic-wrap { background: var(--amber-50); color: var(--amber-600); }
.kpi.k-green .ic-wrap { background: var(--green-50); color: var(--green-600); }
.kpi.k-red .ic-wrap { background: var(--red-50); color: var(--red-600); }
.delta { font-size: 11.5px; font-weight: 750; padding: 2px 7px; border-radius: 99px; }
.delta.up { background: var(--green-50); color: var(--green-700); }
.delta.down { background: var(--red-50); color: var(--red-700); }

/* ---------- tombol ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent; border-radius: 9px; cursor: pointer;
  padding: 8.5px 14px; font: 650 13.5px var(--font); letter-spacing: .005em;
  transition: background .12s, border-color .12s, color .12s;
  text-decoration: none !important;
}
.btn .ic { width: 15.5px; height: 15.5px; }
.btn-primary { background: var(--teal-600); color: #fff; }
.btn-primary:hover { background: var(--teal-700); }
.btn-amber { background: var(--amber-500); color: #fff; }
.btn-amber:hover { background: var(--amber-600); }
.btn-ghost { background: var(--surface); color: var(--ink2); border-color: var(--line2); }
.btn-ghost:hover { border-color: var(--teal-500); color: var(--teal-600); background: var(--teal-50); }
.btn-danger { background: var(--surface); color: var(--red-600); border-color: var(--red-50); }
.btn-danger:hover { background: var(--red-50); }
.btn-sm { padding: 5.5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn { white-space: nowrap; }
/* input di dalam tabel: padding lebih rapat agar angka tidak terpotong */
.tbl td .input { padding: 7px 8px; }

/* ---------- badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 750; letter-spacing: .03em;
  padding: 2.5px 9px; border-radius: 99px; white-space: nowrap;
}
.b-teal { background: var(--teal-50); color: var(--teal-700); }
.b-amber { background: var(--amber-50); color: var(--amber-700); }
.b-green { background: var(--green-50); color: var(--green-700); }
.b-red { background: var(--red-50); color: var(--red-700); }
.b-blue { background: var(--blue-50); color: #1C5CA8; }
.b-gray { background: #EDF1F0; color: var(--ink2); }
.b-solid-red { background: var(--red-600); color: #fff; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------- tabel ---------- */
.tbl-wrap { overflow-x: auto; border-radius: 0 0 var(--r-lg) var(--r-lg); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink3); font-weight: 750; padding: 11px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface2);
  white-space: nowrap;
}
.tbl td { padding: 10.5px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #F4F9F8; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.num { text-align: right; }
.tfoot td { background: var(--surface2); font-weight: 750; }

/* matriks stok */
.tbl .sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 210px; box-shadow: 2px 0 0 var(--line); }
.tbl tbody tr:hover .sticky-col { background: #F4F9F8; }
.cell-low { background: var(--red-50) !important; color: var(--red-700); font-weight: 750; }
.cell-warn { background: var(--amber-50) !important; color: var(--amber-700); font-weight: 700; }

/* ---------- form ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 700; color: var(--ink2); }
.field .req { color: var(--red-600); }
.field input, .field select, .field textarea, .input {
  font: 500 13.5px var(--font); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line2); border-radius: 9px;
  padding: 9px 12px; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(23, 138, 145, .14);
}
.field .hint { font-size: 11.5px; color: var(--ink3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.radio-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-cards label {
  flex: 1; min-width: 120px; cursor: pointer;
  border: 1.5px solid var(--line2); border-radius: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px; font-size: 13px;
}
.radio-cards input { display: none; }
.radio-cards label:has(input:checked) { border-color: var(--teal-600); background: var(--teal-50); }
.radio-cards b { font-size: 13.5px; }

/* filter bar */
.filterbar {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.filterbar .field { margin: 0; min-width: 130px; }
.filterbar .field.grow { flex: 1; min-width: 190px; }
.filterbar input, .filterbar select { padding: 7.5px 11px; font-size: 13px; }

/* ---------- pager ---------- */
.pager { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 13px 20px; }
.pager .pg-info { margin-right: auto; font-size: 12.5px; color: var(--ink3); }
.pager a, .pager span.cur {
  min-width: 30px; height: 30px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--line2); font-size: 13px; font-weight: 600; color: var(--ink2);
}
.pager a:hover { border-color: var(--teal-500); color: var(--teal-600); text-decoration: none; }
.pager span.cur { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }

/* ---------- flash ---------- */
.flash {
  position: fixed; top: 18px; right: 18px; z-index: 100;
  display: flex; gap: 10px; align-items: flex-start;
  max-width: 380px; padding: 13px 16px; border-radius: 12px;
  box-shadow: var(--shadow); font-weight: 600; font-size: 13.5px;
  animation: flashin .25s ease;
}
.flash.sukses { background: #0E5133; color: #E7F8EE; }
.flash.gagal { background: #7C271F; color: #FDECEA; }
@keyframes flashin { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- meter row (bar chart HTML) ---------- */
.meter { display: flex; flex-direction: column; gap: 11px; }
.meter-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.meter-row .m-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: var(--ink2); }
.meter-row .m-bar { height: 14px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.meter-row .m-bar > i { display: block; height: 100%; border-radius: 4px; background: var(--teal-500); min-width: 2px; }
.meter-row.alt .m-bar > i { background: var(--amber-500); }
.meter-row .m-val { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12.5px; white-space: nowrap; }

/* daftar ringkas (list rows) */
.rows { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: 0; }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .t { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .s { font-size: 12px; color: var(--ink3); }

/* ---------- produk card ---------- */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.prod-card { display: flex; flex-direction: column; }
.prod-img {
  height: 150px; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(90px 90px at 50% 46%, rgba(23,138,145,.10), transparent 70%),
    linear-gradient(180deg, var(--surface2), #EDF4F3);
  border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 1px solid var(--line);
}
.prod-img img { height: 116px; }
.prod-body { padding: 14px 16px 15px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.prod-body .p-name { font-weight: 800; font-size: 14.5px; letter-spacing: -.01em; }
.prod-body .p-pack { font-size: 12px; color: var(--ink3); margin-top: 1px; }
.tier { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; }
.tier b { font-variant-numeric: tabular-nums; }
.tiers { border-top: 1px dashed var(--line2); padding-top: 8px; }
.prod-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 9px; border-top: 1px dashed var(--line2); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; }
.login-left {
  background:
    radial-gradient(560px 420px at 82% -10%, rgba(217,138,43,.18), transparent 62%),
    radial-gradient(700px 520px at -12% 108%, rgba(23,138,145,.24), transparent 60%),
    linear-gradient(160deg, var(--teal-950) 8%, var(--teal-900) 55%, #0C4149 100%);
  color: #D6E9EA; padding: 46px 54px; display: flex; flex-direction: column;
}
.login-left .brand { display: flex; align-items: center; gap: 13px; }
.login-left .brand img { width: 44px; height: 44px; }
.login-left .brand .nm { font-size: 21px; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.login-left .brand .tg { font-size: 11px; color: #8FBBBF; letter-spacing: .15em; text-transform: uppercase; font-weight: 650; }
.login-hero { margin: auto 0; padding: 30px 0; }
.login-hero img { width: 100%; max-width: 520px; display: block; margin-bottom: 30px; }
.login-hero h2 { color: #fff; font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; max-width: 430px; }
.login-hero p { color: #A8CBCE; max-width: 430px; font-size: 14px; }
.login-chips { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 18px; }
.login-chips span {
  font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 99px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); color: #CFE5E6;
}
.login-right { display: flex; align-items: center; justify-content: center; padding: 36px 26px; background: var(--bg); }
.login-card { width: 100%; max-width: 392px; }
.login-card .card { padding: 30px 30px 26px; }
.login-card h1 { font-size: 21px; margin-bottom: 2px; }
.login-card .sub { color: var(--ink3); font-size: 13px; margin-bottom: 20px; }
.login-demo {
  margin-top: 16px; font-size: 12.5px; color: var(--ink2);
  background: var(--amber-50); border: 1px dashed var(--amber-500);
  border-radius: 10px; padding: 10px 13px;
}
.login-err {
  background: var(--red-50); color: var(--red-700); font-weight: 650; font-size: 13px;
  padding: 9px 13px; border-radius: 9px; margin-bottom: 14px;
}

/* ---------- halaman faktur / cetak ---------- */
.inv-head { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.inv-no { font-family: var(--mono); font-weight: 600; font-size: 17px; }
.totals { margin-left: auto; max-width: 330px; width: 100%; }
.totals .trow { display: flex; justify-content: space-between; padding: 5.5px 0; font-size: 13.5px; }
.totals .trow.grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; font-size: 16.5px; font-weight: 800; }

/* ---------- dialog ---------- */
dialog.dlg {
  border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 0; width: 400px; max-width: calc(100vw - 40px);
}
dialog.dlg::backdrop { background: rgba(6, 46, 51, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px 0; }
.dlg-body { padding: 12px 18px 18px; }

/* ---------- lain-lain ---------- */
.empty { padding: 34px 20px; text-align: center; color: var(--ink3); }
.empty .ic { width: 34px; height: 34px; opacity: .4; margin-bottom: 8px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.route-dots { color: var(--amber-500); }
.chart-box { padding: 6px 18px 16px; height: 300px; position: relative; }
.chart-box canvas { max-width: 100%; }
.legend-inline { display: flex; gap: 14px; font-size: 12px; color: var(--ink2); align-items: center; }
.legend-inline .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.stat-inline { display: flex; gap: 26px; flex-wrap: wrap; }
.stat-inline .si b { display: block; font-size: 17px; letter-spacing: -.02em; }
.stat-inline .si span { font-size: 12px; color: var(--ink3); }

/* ---------- print ---------- */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .flash { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .print-only { display: block; }
  @page { margin: 14mm; }
}

/* ---------- responsif ---------- */
@media (max-width: 1180px) {
  .col-3 { grid-column: span 6; }
  .col-4 { grid-column: span 6; }
  .col-5, .col-7, .col-8, .col-9, .col-6 { grid-column: span 12; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 90;
    transform: translateX(-100%); transition: transform .2s ease; height: 100dvh;
  }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(6,46,51,.4); }
  .burger { display: inline-flex; }
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
  .tb-date { display: none; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .col-3, .col-4 { grid-column: span 12; }
  .meter-row { grid-template-columns: 96px 1fr auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
