/* KURONOA Inventory — style.css · Credit by drummergimbal */
:root {
  --gold: #ecd27d;
  --gold-soft: #f7ebc4;
  --gold-tint: #fdf6e1;
  --gold-deep: #b8932f;
  --bg: #fdfbf6;
  --surface: #ffffff;
  --cream: #fffaf0;
  --ink: #3b2a1a;
  --ink-2: #5c4631;
  --muted: #8a7862;
  --line: #efe6d3;
  --line-2: #e5d8bb;
  --danger: #b4382c;
  --danger-soft: #fdecea;
  --warn: #9a6a00;
  --warn-soft: #fff4d6;
  --ok: #2e7d4f;
  --ok-soft: #e6f4ec;
  --info: #3c6e91;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(59, 42, 26, .05), 0 6px 20px rgba(59, 42, 26, .06);
  --shadow-lg: 0 18px 50px rgba(59, 42, 26, .18);
  --font: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
.muted { color: var(--muted); }
em.muted { font-style: normal; font-weight: 400; }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: radial-gradient(circle at 50% 35%, var(--gold-tint), var(--cream) 60%);
  transition: opacity .4s ease, visibility .4s;
}
.splash.hide { opacity: 0; visibility: hidden; }
.splash-logo { width: 220px; height: auto; object-fit: contain; animation: breathe 1.6s ease-in-out infinite; }
.splash-name { font-weight: 800; letter-spacing: .3em; font-size: 13px; color: var(--gold-deep); }
.splash-bar { width: 140px; height: 4px; border-radius: 4px; background: var(--gold-soft); overflow: hidden; }
.splash-bar span { display: block; width: 40%; height: 100%; background: var(--gold-deep); border-radius: 4px; animation: slide 1.1s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04); } }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------- Login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 20% 0%, var(--gold-tint), transparent 50%), radial-gradient(circle at 100% 100%, var(--gold-soft), transparent 45%), var(--cream);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: 32px 24px 20px; box-shadow: var(--shadow-lg); display: grid; gap: 14px; text-align: center;
}
.login-logo { width: 210px; height: auto; object-fit: contain; margin: 0 auto 4px; }
.login-card h1 { font-size: 15px; font-weight: 800; letter-spacing: .3em; text-transform: uppercase; color: var(--gold-deep); }
.login-card .field { text-align: left; }
.login-card p { margin: 0; }

/* ---------- Form ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--danger); margin-left: 2px; }
.field small.hint { color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(236, 210, 125, .45); }
input[readonly] { background: var(--gold-tint); color: var(--ink-2); border-style: dashed; }
.field.invalid input, .field.invalid select { border-color: var(--danger); background: var(--danger-soft); }
.field .err { color: var(--danger); font-size: 12px; font-weight: 600; }
.input-group { display: flex; gap: 8px; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; text-align: left; margin: 0; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost, .btn-danger, .btn-soft {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 12px; border: 1.5px solid transparent; font-weight: 700; cursor: pointer; transition: transform .08s, background .15s, box-shadow .15s;
}
.btn-primary { background: var(--gold); color: var(--ink); box-shadow: 0 4px 14px rgba(184, 147, 47, .28); }
.btn-primary:hover { background: #e6c860; }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--gold-tint); }
.btn-soft { background: var(--gold-tint); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-primary:active, .btn-ghost:active, .btn-danger:active, .btn-soft:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: not-allowed; }
.block { width: 100%; }
.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--gold-tint); }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.danger { color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Layout ---------- */
.app { min-height: 100%; display: flex; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; padding-bottom: calc(72px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: rgba(253, 251, 246, .9); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-left h1 { font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-left small { font-size: 12px; display: block; }
.topbar-logo { height: 38px; width: auto; object-fit: contain; flex: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-online { background: var(--ok-soft); color: var(--ok); }
.pill-offline { background: var(--danger-soft); color: var(--danger); }
.pill-sync { background: var(--warn-soft); color: var(--warn); }
.pill-sync i { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.view { padding: 16px; max-width: 1200px; width: 100%; margin: 0 auto; outline: none; flex: 1; }
.credit { font-size: 12px; color: var(--muted); text-align: center; padding: 14px 16px; }
.credit b { color: var(--ink-2); }

.update-banner, .outbox-banner {
  margin: 12px 16px 0; padding: 10px 14px; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 600;
}
.update-banner { background: var(--ink); color: var(--gold-soft); }
.outbox-banner { background: var(--warn-soft); color: var(--warn); cursor: pointer; }

/* bottom nav (mobile) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--safe-b));
}
.bottom-nav a {
  display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; color: var(--muted);
  text-decoration: none; font-size: 11px; font-weight: 600;
}
.bottom-nav a.active { color: var(--ink); background: var(--gold-tint); }
.bottom-nav a.active svg { stroke: var(--gold-deep); }

.fab {
  position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); z-index: 25; width: 56px; height: 56px; border-radius: 18px;
  border: 0; background: var(--gold); color: var(--ink); box-shadow: 0 10px 26px rgba(184, 147, 47, .45); display: grid; place-items: center; cursor: pointer;
}
.fab svg.i { width: 26px; height: 26px; stroke-width: 2.4; }

/* ---------- Cards / dashboard ---------- */
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 10px; }
.section-title h2 { font-size: 16px; font-weight: 800; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kpi { padding: 14px; display: grid; gap: 6px; position: relative; overflow: hidden; }
.kpi .kpi-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--gold-tint); color: var(--gold-deep); }
.kpi .kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi .kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.kpi .kpi-value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.kpi.alert { background: linear-gradient(180deg, #fff, var(--danger-soft)); border-color: #f5cfcb; }
.kpi.alert .kpi-ic { background: var(--danger-soft); color: var(--danger); }
.kpi.alert .kpi-value { color: var(--danger); }
.grid-2 { display: grid; gap: 12px; }
.chart-card { padding: 16px; }
.chart-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.chart-card p { margin: 0 0 10px; font-size: 12px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 11px; }
.chart .val { fill: var(--ink); font-weight: 700; }
.low-list { padding: 4px 0; }
.low-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.low-item:first-child { border-top: 0; }
.low-item b { font-size: 14px; }
.low-item small { display: block; color: var(--muted); font-size: 12px; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }
.empty svg.i { width: 40px; height: 40px; stroke: var(--gold-deep); margin-bottom: 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; background: var(--gold-tint); color: var(--ink-2); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.pending { background: #eef3f8; color: var(--info); }

/* ---------- Toolbar ---------- */
.toolbar { display: grid; gap: 8px; margin-bottom: 12px; }
.search { position: relative; }
.search svg.i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input { padding-left: 38px; }
.toolbar-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.toolbar-row select { min-height: 40px; padding: 8px 10px; font-size: 13px; }
.count-line { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.chooser { display: grid; gap: 12px; }
.chooser a { display: flex; align-items: center; gap: 14px; padding: 16px; text-decoration: none; color: inherit; }
.chooser a .kpi-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--gold-tint); color: var(--gold-deep); flex: none; }
.chooser a b { display: block; font-size: 15px; }
.chooser a small { color: var(--muted); }
.chooser a .chev { margin-left: auto; color: var(--muted); }
.chooser a.danger .kpi-ic { background: var(--danger-soft); color: var(--danger); }

/* ---------- Table → cards on mobile ---------- */
.table-wrap { overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; }
table.data thead { display: none; }
table.data tbody tr {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 14px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer;
}
table.data td { display: block; min-width: 0; font-size: 13.5px; overflow-wrap: anywhere; }
table.data td::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
table.data td.primary { grid-column: 1 / -1; font-size: 15px; font-weight: 700; }
table.data td.primary::before { display: none; }
table.data td.actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; border-top: 1px dashed var(--line); }
table.data td.actions::before { display: none; }
table.data td.num { font-variant-numeric: tabular-nums; }
table.data tr.low { border-color: #f2c4bf; background: linear-gradient(180deg, #fff, var(--danger-soft)); }
table.data tr.pending { border-style: dashed; border-color: #b9cde0; }
.more { display: flex; justify-content: center; padding: 8px 0 16px; }

/* ---------- Skeleton ---------- */
.skeleton { display: grid; gap: 10px; }
.sk { height: 76px; border-radius: var(--radius); background: linear-gradient(90deg, #f4eee0 25%, #fbf7ec 37%, #f4eee0 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
.sk.sm { height: 18px; width: 40%; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(43, 30, 18, .42); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; background: var(--surface);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg); animation: up .2s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; font-weight: 800; }
.modal-body { padding: 16px 18px; overflow: auto; display: grid; gap: 14px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
.modal-foot > * { flex: 1; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 0; }
.detail-grid div { min-width: 0; }
.detail-grid dt { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.detail-grid dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.diff { display: grid; gap: 8px; }
.diff-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.diff-row b { display: block; margin-bottom: 4px; }
.diff-row .mine { color: var(--info); }
.diff-row .theirs { color: var(--ok); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

/* ---------- Toast ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + var(--safe-b)); z-index: 90; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--ink); color: #fff; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); animation: up .2s ease; }
.toast.ok { background: #1f5c3a; }
.toast.err { background: var(--danger); }
.toast.warn { background: #7a5400; }

/* ---------- View tabs (grid / petunjuk) ---------- */
.lines { padding: 6px 0; }
.lines .ln { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 14px; }
.lines .ln:first-child { border-top: 0; }
.lines .ln.head { font-weight: 800; background: var(--gold-tint); }
.lines .ln span + span::before { content: ' · '; color: var(--muted); }
.about { padding: 24px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.about img { width: 200px; height: auto; object-fit: contain; }
.about h2 { font-size: 20px; font-weight: 800; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; text-align: left; font-size: 14px; margin-top: 8px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; }

/* ---------- Tablet / desktop ---------- */
@media (min-width: 640px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .toolbar { grid-template-columns: 1fr auto; align-items: center; }
  .toolbar-row { grid-template-columns: 180px 180px auto; }
  .chooser { grid-template-columns: repeat(2, 1fr); }
  .modal-backdrop { align-items: center; padding: 16px; }
  .modal { border-radius: 22px; }
  .modal-foot > * { flex: 0 0 auto; }
}
@media (min-width: 900px) {
  .sidebar {
    display: flex; flex-direction: column; width: 248px; flex: none; position: sticky; top: 0; height: 100vh;
    background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px 0;
  }
  .brand { display: grid; justify-items: center; gap: 4px; padding: 4px 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .brand img { width: 128px; height: auto; object-fit: contain; }
  .brand small { color: var(--gold-deep); font-weight: 800; letter-spacing: .3em; text-transform: uppercase; font-size: 11px; }
  .side-nav { display: grid; gap: 2px; overflow: auto; flex: 1; align-content: start; }
  .side-nav .grp { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; }
  .side-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 14px; }
  .side-nav a:hover { background: var(--gold-tint); }
  .side-nav a.active { background: var(--gold); color: var(--ink); }
  .bottom-nav, .main-credit { display: none; }
  .main { padding-bottom: 0; }
  .topbar-logo { display: none; }
  .topbar { padding: 14px 24px; }
  .view { padding: 20px 24px 32px; }
  .fab { bottom: 28px; right: 28px; }
  .toasts { bottom: 28px; }

  table.data thead { display: table-header-group; }
  table.data thead th {
    text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px; background: var(--gold-tint);
    border-bottom: 1px solid var(--line-2); white-space: nowrap; cursor: pointer; user-select: none;
  }
  table.data thead th.sorted { color: var(--ink); }
  table.data tbody tr { display: table-row; margin: 0; box-shadow: none; border-radius: 0; border: 0; background: var(--surface); }
  table.data tbody tr:hover { background: var(--cream); }
  table.data td { display: table-cell; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: normal; white-space: nowrap; }
  table.data td.primary { white-space: normal; min-width: 180px; }
  table.data td::before { display: none; }
  table.data td.primary { font-size: 13.5px; }
  table.data td.actions { border-top: 0; display: table-cell; white-space: nowrap; text-align: right; }
  table.data td.actions .icon-btn { margin-left: 6px; }
  table.data tr.low td { background: var(--danger-soft); }
  table.data tr.pending td:first-child { box-shadow: inset 3px 0 0 var(--info); }
  .table-wrap.card { overflow: auto; }
}
