/* ==========================================================================
   ERP Baru — app.css (versi poles)
   Poles tampilan saja: tidak ada perubahan logika, nama class, maupun
   struktur HTML. Semua selector dari versi sebelumnya dipertahankan,
   sehingga file ini cukup ditimpa tanpa migrate dan tanpa ubah database.
   Identitas tetap navy / putih / abu-abu sesuai rancangan Tahap 4.
   ========================================================================== */

:root {
  --navy: #0f172a;
  --navy2: #1e293b;
  --navy3: #334155;
  --blue: #2563eb;
  --blue2: #1d4ed8;
  --green: #15803d;
  --amber: #b45309;
  --red: #dc2626;
  --bg: #eef2f7;
  --card: #fff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --ring: rgba(37, 99, 235, 0.35);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.06);
  --radius: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* Fokus keyboard yang jelas dan konsisten di semua kontrol. */
:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 1px;
  border-radius: 6px;
}

/* ---------- Sidebar ---------- */
aside {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: 220px;
  background: var(--navy);
  padding: 18px 12px;
  overflow-y: auto;
  transition: width 0.18s ease;
  z-index: 10;
  scrollbar-width: thin;
  scrollbar-color: var(--navy3) transparent;
}
body.collapsed aside { width: 64px; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  padding: 4px 2px 14px;
  border-bottom: 1px solid var(--navy2);
  margin-bottom: 14px;
  white-space: nowrap;
}
.brand-initial, .brand-logo {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-initial {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #0f172a;
  font-size: 16px;
  font-weight: 800;
}
.brand-logo {
  object-fit: contain;
  background: #fff;
  padding: 3px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-name {
  color: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.collapsed .brand { justify-content: center; padding: 8px 2px 12px; }
body.collapsed .brand-text { display: none; }

.grp {
  color: #7d8ca3;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 16px 10px 6px;
  white-space: nowrap;
  overflow: hidden;
}
body.collapsed .grp { display: none; }

aside a.nav, aside button.nav {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #cbd5e1;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  margin: 2px 0;
  white-space: nowrap;
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
aside a.nav:hover, aside button.nav:hover { background: var(--navy2); color: #fff; text-decoration: none; }
aside a.nav.on {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}
aside a.nav .ic, aside button.nav .ic { flex: 0 0 20px; text-align: center; }
body.collapsed aside a.nav span.lb, body.collapsed aside button.nav span.lb { display: none; }
body.collapsed aside a.nav, body.collapsed aside button.nav { justify-content: center; padding: 9px 4px; }

/* ---------- Area konten ---------- */
main { margin-left: 220px; padding: 24px 28px; transition: margin-left 0.18s ease; }
body.collapsed main { margin-left: 64px; }

header {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
header h1, header h2 { letter-spacing: -0.01em; }
.search { flex: 1; min-width: 200px; max-width: 460px; display: flex; gap: 8px; }
.search input[type="search"] { flex: 1; min-width: 0; }
.search .btn { padding: 9px 14px; white-space: nowrap; }

/* ---------- Form ---------- */
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--ring);
}
input:disabled, select:disabled, textarea:disabled { background: #f1f5f9; color: var(--muted); cursor: not-allowed; }
textarea { resize: vertical; min-height: 72px; }
label { font-size: 12px; color: #475569; margin: 10px 0 4px; display: block; font-weight: 600; }

/* ---------- Tombol ---------- */
.btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  color: #fff;
  border: 0;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(37, 99, 235, 0.35);
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3); }
.btn.o { background: #e2e8f0; color: var(--text); box-shadow: none; }
.btn.o:hover { background: #cbd5e1; }
.btn.danger { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 3px 8px rgba(220, 38, 38, 0.35); }
.btn:disabled { opacity: 0.55; cursor: wait; transform: none; }

/* ---------- Teks bantu ---------- */
.crumbs {
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 700;
  margin-bottom: 8px;
}
.muted { color: var(--muted); font-size: 12px; }

/* ---------- Kartu & KPI ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 14px; }
/* Dashboard: 9 kartu KPI disusun 3x3 agar lebarnya seragam. */
.cards.kpi { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
@media (min-width: 980px) {
  .cards.kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
/* Bila jumlah kartu ganjil pada layar dua kolom, kartu terakhir
   melebar penuh agar tidak menyisakan celah di kanan. */
@media (max-width: 979px) {
  .cards.kpi > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.cards .card { margin-bottom: 0; position: relative; overflow: hidden; }
.cards .card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--blue), #22c55e);
}
.t { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.v { font-size: 22px; font-weight: 800; margin-top: 4px; letter-spacing: -0.01em; }

/* ---------- Tabel ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
th {
  background: #f8fafc;
  text-align: left;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #475569;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 12px; border-top: 1px solid #eef2f7; font-size: 13px; vertical-align: middle; }
tbody tr { transition: background 0.12s ease; }
tr:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Kolom kode/nomor: jangan dilipat ke baris berikut agar terbaca utuh. */
.nowrap { white-space: nowrap; }
/* Kode/SKU dengan huruf monospace supaya rapi seperti kode barang. */
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12px; }
/* Tombol aksi (Ubah/Nonaktifkan) berdampingan dalam satu baris. */
td.actions { white-space: nowrap; }
td.actions .btn { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
/* Baris kecil di bawah nilai utama (mis. satuan & rak di bawah nama produk). */
.sub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
/* Keadaan kosong (belum ada data): ikon dan teks sama-sama di tengah. */
.empty { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 13px; }

/* ---------- Badge & alert ---------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.b-green { background: #dcfce7; color: var(--green); }
.b-red { background: #fee2e2; color: var(--red); }
.b-amber { background: #fef3c7; color: var(--amber); }
.b-blue { background: #dbeafe; color: #1d4ed8; }
.b-grey { background: #e2e8f0; color: #475569; }
.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}
.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ---------- Halaman login ---------- */
.login-page main { margin-left: 0; }
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card {
  max-width: 420px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px 28px 24px;
}
.brand-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
  text-align: left;
}
.login-initial, .login-logo {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 14px;
}
.login-initial {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #0f172a;
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-logo {
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  padding: 5px;
}
.login-brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.login-company { font-weight: 800; font-size: 17px; color: #0f172a; letter-spacing: -0.01em; }
.login-card h1 { font-size: 19px; text-align: center; margin-bottom: 6px; }
.login-card .muted { text-align: center; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  /* Sidebar menjadi panel geser: tersembunyi secara bawaan, dibuka
     lewat tombol Sidebar (menambahkan class collapsed pada body). */
  aside {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 250px;
    display: block;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    z-index: 60;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.35);
  }
  body.collapsed aside { width: 250px; transform: none; }
  body.collapsed .brand { justify-content: flex-start; padding: 10px 6px 14px; }
  body.collapsed .brand-text { display: flex; }
  body.collapsed .grp { display: block; }
  body.collapsed aside a.nav span.lb,
  body.collapsed aside button.nav span.lb { display: inline; }
  body.collapsed aside a.nav,
  body.collapsed aside button.nav { justify-content: flex-start; padding: 9px 12px; }
  main, body.collapsed main { margin-left: 0; padding: 16px; }
  table { display: block; overflow-x: auto; }
  .cards { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 22px 18px; }
  .top-product { grid-template-columns: 110px 1fr 60px; }
}

/* ---------- Ikon SVG ---------- */
.icn {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.15em;
  flex: 0 0 auto;
}
aside .nav .icn, aside button.nav .icn { width: 17px; height: 17px; }
.btn .icn { width: 15px; height: 15px; vertical-align: -2px; margin-right: 5px; }
h1 .icn, h2 .icn, h3 .icn { width: 1.05em; height: 1.05em; vertical-align: -0.15em; margin-right: 6px; }
th .icn { width: 13px; height: 13px; vertical-align: -2px; margin-right: 5px; }
.badge .icn { width: 12px; height: 12px; vertical-align: -1px; }
.empty .icn { display: block; margin: 0 auto 8px; width: 28px; height: 28px; color: #94a3b8; }
a .icn { vertical-align: -0.15em; }

/* ---------- Grafik dashboard ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.chart-grid .card { margin-bottom: 0; }
.chart { width: 100%; height: auto; display: block; }
.chart-axis { stroke: #e2e8f0; stroke-width: 1; }
.chart-gridline { stroke: #f1f5f9; stroke-width: 1; }
.chart-bar { fill: #2563eb; }
.chart-bar:hover { fill: #1d4ed8; }
.chart-bar.alt { fill: #22c55e; }
.chart-bar.alt:hover { fill: #16a34a; }
.chart-label { font-size: 14px; fill: #64748b; text-anchor: middle; font-family: inherit; }
.chart-value { font-size: 14px; fill: #334155; text-anchor: middle; font-family: inherit; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: #475569; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.top-products { margin-top: 4px; }
.top-product {
  display: grid;
  grid-template-columns: minmax(110px, 220px) 1fr 70px;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
  font-size: 12.5px;
}
.top-product .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-product .track { display: block; background: #eef2f7; border-radius: 6px; height: 10px; overflow: hidden; }
.top-product .fill { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #22c55e); border-radius: 6px; }
.top-product .qty { text-align: right; font-variant-numeric: tabular-nums; color: #475569; }
