:root {
  --bg: #f3f1ec; --panel: #ffffff; --ink: #18212b; --muted: #6b7380; --line: #e2ded5;
  --nav: #16202c; --nav-ink: #c9d2dc; --accent: #f2a900; --accent-ink: #1b1400;
  --blue: #2c6bed; --red: #c8352e; --green: #1d8a4e; --amber-bg: #fff4d6; --green-bg: #e3f5ea; --red-bg: #fde8e6;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14.5px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
a { color: var(--blue); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
input, select, textarea, button { font: inherit; color: inherit; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 30% 20%, #24364a, #121a24 70%); }
.login-card { background: #fff; padding: 28px 24px; border-radius: 14px; width: 100%; max-width: 340px; text-align: center; display: grid; gap: 10px; }
.login-card img { width: 170px; margin: 0 auto; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; }
.side { background: var(--nav); color: var(--nav-ink); position: sticky; top: 0; height: 100vh; padding: 16px 10px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.brand img { width: 40px; background: #fff; border-radius: 8px; padding: 2px; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--nav-ink); text-decoration: none; }
.side nav a i { font-style: normal; width: 18px; text-align: center; opacity: .8; }
.side nav a:hover { background: rgba(255,255,255,.06); }
.side nav a.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.view { padding: 22px 26px 90px; min-width: 0; max-width: 1180px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); z-index: 20; }
  .brand { display: none; }
  .side nav { grid-template-columns: repeat(6, 1fr); }
  .side nav a { flex-direction: column; gap: 1px; padding: 6px 2px; font-size: 10.5px; text-align: center; }
  .side nav a i { font-size: 17px; }
  .view { padding: 14px 12px 96px; }
}

/* blocks */
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.head h1 { font-size: 21px; }
.head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid2 { display: grid; gap: 10px 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 21px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12px; }

label.f { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.in, select.in, textarea.in { width: 100%; border: 1px solid #cfcabf; background: #fff; border-radius: 8px; padding: 8px 10px; color: var(--ink); font-weight: 400; font-size: 14.5px; }
.in:focus { outline: 2px solid #f2a90066; border-color: var(--accent); }
.in.num { text-align: right; font-variant-numeric: tabular-nums; }
textarea.in { min-height: 70px; resize: vertical; }

a.btn { text-decoration: none; color: inherit; display: inline-block; }
.btn { border: 1px solid #cfcabf; background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: #f7f5f0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.96); }
.btn.dark { background: var(--nav); color: #fff; border-color: var(--nav); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 9px 8px; border-bottom: 1px solid #efece5; vertical-align: middle; }
table.tbl tr.click { cursor: pointer; }
table.tbl tr.click:hover td { background: #faf8f3; }
.r { text-align: right; font-variant-numeric: tabular-nums; }
.c { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--amber-bg); color: #8a5a00; }
.badge.ok { background: var(--green-bg); color: var(--green); }
.badge.late { background: var(--red-bg); color: var(--red); }
.badge.part { background: #e5eefc; color: var(--blue); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* item editor */
table.items { width: 100%; border-collapse: collapse; }
table.items th { font-size: 12px; color: var(--muted); text-align: left; padding: 4px; }
table.items td { padding: 3px; }
table.items .in { padding: 6px 8px; }
table.items td.no { width: 28px; text-align: center; color: var(--muted); font-size: 12px; }
table.items td.q { width: 86px; }
table.items td.t { width: 150px; }
table.items td.x { width: 34px; }
.totals { margin-left: auto; max-width: 380px; display: grid; gap: 6px; margin-top: 12px; }
.totals .line { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.totals .grand { font-size: 19px; font-weight: 800; border-top: 1px solid var(--line); padding-top: 8px; }
.warn { background: var(--amber-bg); color: #7a5000; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-top: 8px; }

/* customer picker */
.cpick { position: relative; }
.cpick .dd { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 3px; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 260px; overflow: auto; }
.cpick .dd div { padding: 8px 10px; cursor: pointer; }
.cpick .dd div:hover, .cpick .dd div.hl { background: #fff6dc; }
.cpick .dd small { color: var(--muted); display: block; }
.cpick .tag { font-size: 12px; margin-top: 4px; }
.chk { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); font-weight: 400; }

/* progress */
.prog { height: 10px; background: #ece8df; border-radius: 99px; overflow: hidden; }
.prog > div { height: 100%; background: linear-gradient(90deg, #1d8a4e, #49b77a); }

/* foto */
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs a { position: relative; display: block; width: 64px; height: 64px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); background: #f4f2ed; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.thumbs .pdf { display: grid; place-items: center; height: 100%; font-size: 12px; font-weight: 700; color: var(--red); }
.thumbs button { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; cursor: pointer; padding: 0 5px; }

/* modal / toast */
.modal { position: fixed; inset: 0; background: rgba(15,20,28,.55); display: grid; place-items: center; z-index: 50; padding: 12px; }
.modal-card { background: #fff; border-radius: 12px; padding: 18px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; }
.modal-card h3 { margin-bottom: 12px; }
.modal-card.wide { max-width: 900px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(30px); background: #16202c; color: #fff; padding: 10px 16px;
  border-radius: 8px; opacity: 0; transition: .25s; z-index: 60; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }
@media (max-width: 820px) { .toast { bottom: 84px; } }

/* rincian nota di HP: keterangan satu baris penuh, jumlah & total di bawahnya */
@media (max-width: 620px) {
  table.items.nota-items thead { display: none; }
  table.items.nota-items tr { display: grid; grid-template-columns: 22px 1fr 1.4fr 34px; gap: 5px; padding: 7px 0; border-bottom: 1px solid var(--line); }
  table.items.nota-items td { display: block; width: auto !important; padding: 0; }
  table.items.nota-items td.no { grid-row: 1; align-self: center; }
  table.items.nota-items td:nth-child(2) { grid-column: 2 / 5; }
  table.items.nota-items td.q { grid-column: 2; }
  table.items.nota-items td.t { grid-column: 3; }
  table.items.nota-items td.x { grid-column: 4; }
}
