:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --border: #e8eaf2;
  --text: #171c2e;
  --text-muted: #7a8199;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0fe;
  --accent: #7c6cf6;
  --success: #10b981;
  --success-soft: #e7f8f2;
  --warning: #f59e0b;
  --warning-soft: #fdf3e0;
  --danger: #ef4444;
  --danger-soft: #feecec;
  --sidebar-bg: #12141f;
  --sidebar-bg-2: #181b2b;
  --sidebar-text: #8d93ad;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(23,28,46,0.05), 0 1px 6px rgba(23,28,46,0.04);
  --shadow-md: 0 4px 16px rgba(23,28,46,0.07), 0 1px 4px rgba(23,28,46,0.05);
  --shadow-lg: 0 18px 44px rgba(23,28,46,0.13);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--primary-soft); }

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(124,108,246,0.35), transparent 60%),
    radial-gradient(700px 500px at -10% 100%, rgba(79,70,229,0.28), transparent 55%),
    #12141f;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  padding: 42px 38px;
  border-radius: 22px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 1.45rem; margin: 0 0 4px; font-weight: 800; letter-spacing: -0.02em; }
.login-card p { color: var(--text-muted); margin: 0 0 26px; font-size: 0.9rem; }

/* ===== App shell ===== */
.app-shell { display: flex; min-height: 100vh; }

/* ===== Sidebar (putih, gaya brand Mitrayasa) ===== */
.sidebar {
  width: 264px;
  background: #ffffff;
  border-right: 1px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 4px;
}
.sidebar-backdrop { display: none; }

.sidebar-brand {
  padding: 4px 4px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.brand-logo-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
}
.brand-logo-card img {
  width: 100%;
  height: auto;
  display: block;
}

.sidebar-section-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a6abc0;
  padding: 0 12px 10px;
}

.sidebar-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.16s ease, color 0.16s ease;
}
.sidebar-nav a .nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: flex; }
.sidebar-nav a .nav-icon svg { width: 20px; height: 20px; }
.sidebar-nav a .nav-indicator {
  position: absolute;
  right: 12px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.sidebar-nav a:hover { background: #f1f2f8; color: var(--text); }
.sidebar-nav a.active {
  background: linear-gradient(135deg, #2b3087, var(--primary));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(43,48,135,0.32);
}
.sidebar-nav a.active .nav-indicator { opacity: 1; transform: scale(1); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  background: #f6f7fb;
  border: 1px solid var(--border);
}
.sidebar-avatar {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2b3087, var(--primary));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name {
  color: var(--text); font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 0.72rem; color: var(--text-muted); }

/* ===== Main area & navbar ===== */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.navbar {
  min-height: 72px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.navbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.navbar .page-title { font-weight: 800; font-size: 1.28rem; letter-spacing: -0.02em; }
.navbar .page-date { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.navbar .user-menu { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; color: var(--text); }
.navbar .user-menu .role-text { font-weight: 600; }

.navbar-avatar {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  padding: 5px;
  flex-shrink: 0;
}
.navbar-avatar img { width: 100%; height: 100%; object-fit: contain; }

.btn-logout {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 0;
}
.btn-logout svg { width: 17px; height: 17px; }
.btn-logout:hover { color: var(--danger); border-color: #fbd2d2; background: var(--danger-soft); }

.btn-install { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.btn-install svg { width: 15px; height: 15px; }
@media (max-width: 640px) {
  .quality-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .manual-item-row { grid-template-columns:1fr 72px; }
  .individual-filter-card { flex-direction:column; align-items:stretch; }
  .btn-install span { display: none; }
  .btn-install { padding: 8px; }
}

.navbar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 0;
  margin-right: 6px;
}
.navbar-toggle svg { width: 18px; height: 18px; }

.content { padding: 22px 28px 32px; flex: 1; min-width: 0; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.summary-card .label { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 6px; font-weight: 500; }
.summary-card .value { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

/* ===== Dashboard ===== */

.dash-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(600px 300px at 90% -20%, rgba(124,108,246,0.55), transparent 60%),
    radial-gradient(500px 300px at -5% 120%, rgba(99,102,241,0.4), transparent 55%),
    linear-gradient(135deg, #1c1e33, #23264a);
  border-radius: 22px;
  padding: 28px 30px;
  color: #fff;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
}
.dash-hero-pattern {
  position: absolute;
  right: -20px; bottom: -30px;
  width: 240px; height: 240px;
  background-image: radial-gradient(rgba(255,255,255,0.14) 1.5px, transparent 1.5px);
  background-size: 17px 17px;
  opacity: 0.6;
  pointer-events: none;
  mask-image: radial-gradient(closest-side, #000, transparent);
  -webkit-mask-image: radial-gradient(closest-side, #000, transparent);
}
.dash-hero-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.dash-hero-badge {
  position: relative;
  display: inline-block;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.16);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  backdrop-filter: blur(4px);
}
.dash-hero-logo {
  width: 156px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 13px;
  background: rgba(255,255,255,0.94);
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
}
.dash-hero-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.dash-hero-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: space-between;
  align-items: flex-end;
}
.dash-balance-label { font-size: 0.78rem; opacity: 0.7; margin-bottom: 6px; font-weight: 500; }
.dash-balance-value { font-size: 2.35rem; font-weight: 800; letter-spacing: -0.035em; }
.dash-hero-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.dash-hero-stat {
  display: flex; align-items: center; gap: 11px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 15px;
  padding: 11px 16px 11px 11px;
  backdrop-filter: blur(4px);
}
.dash-hero-stat-icon {
  width: 36px; height: 36px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; font-weight: 700; flex-shrink: 0;
}
.dash-hero-stat-icon.income { background: rgba(16,185,129,0.22); color: #4ade9d; }
.dash-hero-stat-icon.expense { background: rgba(251,146,60,0.2); color: #fdba74; }
.dash-hero-stat .stat-label { font-size: 0.7rem; opacity: 0.7; }
.dash-hero-stat .stat-value { font-size: 0.98rem; font-weight: 700; }

.mini-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.mini-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.mini-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.clickable-card { cursor: pointer; }
.clickable-card:focus-visible { outline: 3px solid rgba(79,70,229,.25); outline-offset: 2px; }
.milk-data-card, .manual-invoice-box, .individual-filter-card, .individual-profile { background:var(--surface,#fff); border:1px solid var(--border,#e5e7eb); border-radius:12px; padding:14px; margin-bottom:14px; }
.purchase-extra-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-bottom:14px; }
.purchase-extra-card { display:flex; align-items:flex-start; gap:11px; background:var(--surface,#fff); border:1px solid var(--border,#e5e7eb); border-radius:12px; padding:14px; }
.purchase-extra-card .field { flex:1; margin:0; }
.purchase-extra-card textarea { resize:vertical; min-height:76px; }
.purchase-extra-card small { display:block; margin-top:6px; font-size:.76rem; }
.purchase-extra-icon { width:34px; height:34px; flex:0 0 34px; display:grid; place-items:center; border-radius:10px; font-size:1rem; font-weight:800; }
.purchase-extra-icon.note { color:#4f46e5; background:rgba(79,70,229,.1); }
.purchase-extra-icon.deduction { color:#b45309; background:rgba(245,158,11,.13); }
.deduction-item-row { display:grid; grid-template-columns:minmax(120px,1.35fr) minmax(100px,.8fr) 34px; gap:6px; margin-bottom:7px; }
.deduction-item-row input { width:100%; min-width:0; }
.deduction-footer { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-top:3px; }
.detail-deduction-list { border:1px solid var(--border,#e5e7eb); border-radius:10px; padding:11px 13px; margin-bottom:14px; background:var(--bg-soft,#f6f7fb); }
.detail-deduction-list > strong { display:block; margin-bottom:7px; }
.detail-deduction-row { display:flex; justify-content:space-between; gap:12px; padding:4px 0; border-top:1px dashed var(--border,#dfe2ea); font-size:.86rem; }
.detail-deduction-row span:last-child { color:var(--danger,#dc2626); font-weight:650; }
.milk-data-title { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
.milk-data-title span { color:var(--primary,#4f46e5); background:rgba(79,70,229,.09); padding:4px 9px; border-radius:999px; font-size:.8rem; font-weight:700; }
.quality-grid { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:8px; }
.quality-grid .field { margin:0; }
.quality-grid input { width:100%; min-width:0; }
.transaction-metrics { display:flex; flex-wrap:wrap; gap:8px 20px; padding:10px 12px; background:var(--bg-soft,#f6f7fb); border-radius:9px; margin-bottom:14px; font-size:.86rem; }
.detail-print-actions { display:flex; justify-content:flex-end; padding-top:10px; border-top:1px solid var(--border,#e5e7eb); margin-top:14px; }
.transaction-input-switch { display:flex; align-items:center; flex-wrap:wrap; gap:7px; margin:8px 0 12px; }
.transaction-input-switch label { display:flex; align-items:center; gap:6px; border:1px solid var(--border,#e5e7eb); border-radius:9px; padding:8px 12px; cursor:pointer; font-size:.84rem; font-weight:650; }
.transaction-input-switch label.active { color:var(--primary,#4f46e5); border-color:var(--primary,#4f46e5); background:rgba(79,70,229,.08); }
.transaction-input-switch input { box-shadow:none; }
.transaction-input-switch select { margin-left:auto; min-width:110px; }
.sumber-toggle { display:grid; grid-template-columns:1fr 1fr; gap:6px; padding:4px; margin-bottom:16px; background:var(--bg); border:1px solid var(--border); border-radius:10px; }
.sumber-toggle button { padding:9px 10px; border:0; border-radius:8px; background:transparent; color:var(--text-muted); font-weight:600; cursor:pointer; }
.sumber-toggle button.active { background:var(--surface); color:var(--primary); box-shadow:var(--shadow-sm); }
.tagihan-list { display:flex; flex-direction:column; gap:6px; max-height:260px; overflow-y:auto; margin:6px 0 12px; padding:2px; }
.tagihan-list .empty-state { padding:20px; margin:0; }
.tagihan-item { display:flex; justify-content:space-between; align-items:center; gap:12px; width:100%; padding:10px 12px; text-align:left; background:var(--surface); border:1px solid var(--border); border-radius:10px; cursor:pointer; color:var(--text); }
.tagihan-item:hover { border-color:var(--primary); }
.tagihan-item.active { border-color:var(--primary); background:var(--primary-soft); }
.tagihan-utama, .tagihan-angka { display:flex; flex-direction:column; gap:2px; min-width:0; font-size:0.86rem; }
.tagihan-utama strong { overflow-wrap:anywhere; }
.tagihan-angka { text-align:right; flex-shrink:0; }
.tagihan-ringkas { display:flex; flex-wrap:wrap; gap:6px 16px; padding:10px 12px; margin-bottom:12px; background:var(--success-soft); border-radius:10px; font-size:0.86rem; }
.manual-invoice-toggle { display:flex; gap:8px; align-items:center; margin:2px 0 14px; font-weight:600; cursor:pointer; }
.manual-item-row { display:grid; grid-template-columns:minmax(150px,2fr) 80px 90px minmax(110px,1fr) 36px; gap:7px; margin:8px 0; }
.individual-filter-card { display:flex; gap:12px; align-items:flex-end; }
.individual-filter-card .field { flex:1; margin:0; }
.individual-filter-card select { width:100%; }
.individual-profile h3 { margin:4px 0; font-size:1.25rem; }
.individual-profile p { margin:0; }
.mini-card.highlight {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  color: #fff;
  box-shadow: 0 14px 30px rgba(79,70,229,0.35);
}
.mini-card .icon-badge {
  width: 40px; height: 40px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; margin-bottom: 14px;
  background: var(--primary-soft); color: var(--primary);
}
.mini-card.highlight .icon-badge { background: rgba(255,255,255,0.18); color: #fff; }
.mini-card .icon-badge.danger { background: var(--danger-soft); color: var(--danger); }
.mini-card .icon-badge.warning { background: var(--warning-soft); color: var(--warning); }
.mini-card .mini-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.mini-card.highlight .mini-label { color: rgba(255,255,255,0.75); }
.mini-card .mini-value { font-size: 1.4rem; font-weight: 800; letter-spacing: -0.02em; }

.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.dash-grid-2 > * { min-width: 0; }
@media (max-width: 900px) { .dash-grid-2 { grid-template-columns: 1fr; } }

.chart-card canvas { max-width: 100%; }
.chart-canvas-wrap { height: 240px; width: 100%; position: relative; }

.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header-row h3 { margin: 0; font-size: 0.98rem; font-weight: 700; letter-spacing: -0.01em; }

.donut-wrap { position: relative; width: 205px; height: 205px; margin: 8px auto 20px; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.donut-center-label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
.donut-center-value { font-size: 1.12rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }

.cashflow-legend { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; }
.cashflow-legend .legend-item { font-size: 0.82rem; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.cashflow-legend .legend-item strong { color: var(--text); font-weight: 700; }
.cashflow-legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cashflow-legend .dot.income { background: #4f46e5; }
.cashflow-legend .dot.expense { background: #10b981; }

.txn-list { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; }
.txn-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.txn-row:last-child { border-bottom: none; }
.txn-icon {
  width: 40px; height: 40px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.txn-icon.penjualan { background: var(--primary-soft); color: var(--primary); }
.txn-icon.pembelian { background: var(--success-soft); color: var(--success); }
.txn-info { flex: 1; min-width: 0; }
.txn-title { font-size: 0.88rem; font-weight: 600; }
.txn-sub { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn-amount { font-size: 0.88rem; font-weight: 700; white-space: nowrap; }
.txn-amount.positive { color: var(--success); }
.txn-amount.negative { color: var(--danger); }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }
.filter-disclosure { display: contents; }
.filter-toggle-control,
.filter-toggle { display: none; }
.filter-disclosure > .filter-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.filter-chevron { transition: transform 0.18s ease; }
.filter-toggle-control:checked + .filter-toggle .filter-chevron { transform: rotate(180deg); }
.report-actions { display: flex; gap: 10px; }

/* ===== Period filter ===== */
.period-filter {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}
.period-presets {
  display: grid;
  grid-template-columns: repeat(4, minmax(76px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.period-presets button {
  min-height: 36px;
  padding: 7px 13px;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
  box-shadow: none;
}
.period-presets button:hover { color: var(--text); background: var(--bg); }
.period-presets button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 12px rgba(79,70,229,0.28);
}
.period-custom-range {
  display: grid;
  grid-template-columns: minmax(145px, 1fr) auto minmax(145px, 1fr);
  align-items: end;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.period-custom-range label { margin: 0; min-width: 0; }
.period-custom-range label span { display: block; margin: 0 0 5px 2px; font-size: 0.68rem; }
.period-custom-range input { width: 100%; min-width: 0; padding: 8px 10px; box-shadow: none; }
.period-range-arrow { align-self: center; color: var(--text-muted); padding-top: 17px; }

/* ===== Form controls ===== */
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.14);
}
label { display: block; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 11px;
  padding: 10px 18px;
  font-size: 0.87rem;
  font-weight: 600;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}
button:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 6px 16px rgba(79,70,229,0.32);
}
.btn-primary:hover { box-shadow: 0 8px 22px rgba(79,70,229,0.42); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--primary-soft); border-color: #d8dbfa; color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fbd9d9; }
.btn-sm { padding: 6px 12px; font-size: 0.79rem; border-radius: 9px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Table ===== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
thead th {
  text-align: left;
  padding: 13px 16px;
  background: #f8f9fd;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8f9fd; }
.quality-detail-row td {
  padding-top: 8px;
  padding-bottom: 8px;
  background: #f8f9fd;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: left;
}
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.empty-state { padding: 44px; text-align: center; color: var(--text-muted); }

.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 4px; font-size: 0.83rem; }

/* ===== Badge ===== */
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: capitalize;
}
.badge-success { background: var(--success-soft); color: #0b8a61; }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-danger { background: var(--danger-soft); color: #cf3434; }
.badge-muted { background: #eef0f6; color: var(--text-muted); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(13,15,26,0.55);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-box {
  background: var(--surface); border-radius: 20px;
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  padding: 24px 26px;
  box-shadow: var(--shadow-lg);
}
.modal-box.modal-lg { max-width: 820px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h3 { margin: 0; font-size: 1.08rem; font-weight: 800; letter-spacing: -0.01em; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-close {
  background: #f1f2f8; color: var(--text-muted);
  width: 32px; height: 32px; border-radius: 10px;
  font-size: 1.1rem; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--danger-soft); color: var(--danger); }

.error-text { color: var(--danger); font-size: 0.84rem; margin: 8px 0; }

/* ===== Tabs ===== */
.tabs {
  display: flex; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 5px;
  margin-bottom: 18px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
  width: fit-content;
  max-width: 100%;
}
.tabs button {
  background: none;
  border-radius: 9px;
  padding: 8px 15px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.83rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.tabs button:hover { color: var(--text); }
.tabs button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}

/* ===== Toast ===== */
.toast-wrap {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 18px 12px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
}
.toast-icon {
  width: 26px; height: 26px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 800;
  flex-shrink: 0;
}
.toast.success .toast-icon { background: var(--success-soft); color: var(--success); }
.toast.error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast.error { border-color: #fbd9d9; }
.toast-enter-active, .toast-leave-active { transition: all 0.28s cubic-bezier(0.2, 0.8, 0.3, 1); }
.toast-enter-from { opacity: 0; transform: translateX(30px); }
.toast-leave-to { opacity: 0; transform: translateY(-8px); }

/* ===== Insight (dashboard) ===== */
.insight-list { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; }
.insight-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.insight-row:last-child { border-bottom: none; }
.insight-row .insight-info { flex: 1; min-width: 0; }
.insight-row .insight-title { font-size: 0.86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insight-row .insight-sub { font-size: 0.74rem; color: var(--text-muted); }
.insight-empty {
  padding: 26px 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.growth-chip {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.growth-chip.up { background: rgba(16,185,129,0.2); color: #4ade9d; }
.growth-chip.down { background: rgba(239,68,68,0.2); color: #fda4a4; }

/* ===== Invoice preview (modal & print) ===== */
.invoice-header {
  position: relative;
  height: 130px;
  overflow: hidden;
  margin: -4px -26px 16px;
  background: #fff;
}
.invoice-header-diagonal {
  position: absolute;
  inset: 0;
  width: 64%;
  background: linear-gradient(135deg, #21398a, #2f57b8);
  clip-path: polygon(0 0, 100% 0, 76% 100%, 0 100%);
  display: flex;
  align-items: center;
  padding-left: 30px;
}
.invoice-header-title {
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.invoice-header-title-long { max-width: 390px; font-size: 1.35rem; line-height: 1.2; }
.invoice-header-logo {
  position: absolute;
  top: 50%;
  right: 30px;
  transform: translateY(-50%);
  height: 44px;
  width: auto;
}
.invoice-meta-row {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 8px;
}
.invoice-divider { height: 2px; background: #21398a; margin: 0 -26px 18px; }

.invoice-info-grid { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.invoice-info-grid p { margin: 3px 0; font-size: 0.86rem; }
.invoice-info-grid .text-right { text-align: right; }
.invoice-milk-metrics { margin-bottom: 18px; }
.invoice-section-title { margin: 18px 0 8px; }

.invoice-table-wrap table thead th { background: #21398a; color: #fff; }

.invoice-totals { display: flex; justify-content: flex-end; margin: 16px 0; }
.invoice-totals-box { width: 260px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }
.invoice-totals-box .row { display: flex; justify-content: space-between; font-size: 0.86rem; padding: 4px 0; color: var(--text-muted); }
.invoice-totals-box .row.total { border-top: 2px solid #21398a; margin-top: 6px; padding-top: 10px; font-size: 1.05rem; font-weight: 800; color: var(--text); }

.invoice-notes { max-width: 520px; margin: 12px 0 18px; padding: 12px 14px; background: var(--bg); border-left: 3px solid #21398a; border-radius: 0 8px 8px 0; font-size: 0.86rem; }
.invoice-notes p { margin: 5px 0 0; color: var(--text-muted); white-space: pre-wrap; overflow-wrap: anywhere; }

.invoice-signature { margin-top: 6px; }
.invoice-signature p { margin: 4px 0; font-size: 0.86rem; }
.invoice-sign-logo { height: 34px; width: auto; margin: 6px 0; display: block; }
.invoice-payment-info { margin-top: 50px; }

.invoice-footer { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--border); text-align: center; font-size: 0.78rem; color: var(--text-muted); }
.invoice-footer p { margin: 3px 0; }

@media (max-width: 640px) {
  .purchase-extra-grid { grid-template-columns:1fr; }
  .deduction-item-row { grid-template-columns:1fr minmax(100px,.75fr) 34px; }
  .invoice-header { height: 108px; margin: -4px -18px 14px; }
  .invoice-header-diagonal { width: 78%; padding-left: 18px; clip-path: polygon(0 0, 100% 0, 62% 100%, 0 100%); }
  .invoice-header-title { font-size: 1.5rem; }
  .invoice-header-title-long { max-width: 210px; font-size: 1rem; }
  .invoice-header-logo { height: 32px; right: 14px; }
  .invoice-divider { margin: 0 -18px 14px; }
  .invoice-info-grid { flex-direction: column; }
  .invoice-info-grid .text-right { text-align: left; }
  .invoice-totals { justify-content: stretch; }
  .invoice-totals-box { width: 100%; }
}

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area {
    position: fixed; top: 0; left: 0; width: 100%;
    padding: 24px; background: #fff;
  }
}

/* =========================================================
   Responsive: tablet / iPad / mobile
   ========================================================= */

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.3, 1);
    z-index: 60;
    box-shadow: none;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 24px 0 60px rgba(0,0,0,0.35); }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(13,15,26,0.5);
    backdrop-filter: blur(2px);
    z-index: 55;
  }

  .navbar-toggle { display: inline-flex; }
}

@media (max-width: 900px) {
  .navbar { padding: 10px 20px; }
  .content { padding: 18px 20px 28px; }
  .period-filter { align-items: stretch; flex-direction: column; }
  .period-presets { width: 100%; }
  .period-custom-range { width: 100%; }
}

@media (max-width: 640px) {
  .navbar { padding: 10px 14px; }
  .content { padding: 14px 14px 24px; }

  .page-title { font-size: 1.05rem; }
  .page-date { display: none; }
  .role-text { display: none; }

  .field-row { grid-template-columns: 1fr; gap: 0; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .spacer { display: none; }
  .toolbar > input,
  .toolbar > select,
  .toolbar > button { width: 100% !important; max-width: none; }

  .filter-toolbar { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
  .filter-toolbar > button { width: auto !important; min-height: 42px; flex-shrink: 0; }
  .filter-disclosure {
    display: block;
    flex: 1 1 110px;
    min-width: 0;
  }
  .filter-toggle-control { display: none; }
  .filter-toggle {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    list-style: none;
    margin: 0;
  }
  .filter-toggle-control:not(:checked) ~ .filter-fields { display: none; }
  .filter-disclosure:has(.filter-toggle-control:checked) { flex-basis: 100%; order: 3; }
  .filter-toggle-control:checked + .filter-toggle {
    color: var(--primary);
    border-color: #d8dbfa;
    background: var(--primary-soft);
  }
  .filter-disclosure > .filter-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .filter-disclosure .filter-fields > input,
  .filter-disclosure .filter-fields > select { width: 100% !important; max-width: none; }
  .filter-disclosure .filter-separator { display: none; }

  .report-toolbar { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .report-period { min-width: 0; }
  .report-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .report-actions button { width: 100%; padding-left: 8px; padding-right: 8px; }

  .modal-overlay { padding: 10px; }
  .modal-box { padding: 20px 18px; }

  .period-filter { margin-bottom: 12px; gap: 8px; }
  .period-presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .period-presets button { min-height: 34px; min-width: 0; padding: 6px 3px; font-size: 0.72rem; }
  .period-custom-range { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 10px; }
  .period-range-arrow { display: none; }
  .period-custom-range input { font-size: 0.78rem; padding: 8px 7px; }

  .summary-card .value { font-size: 1.2rem; }
  .dash-hero { padding: 18px; border-radius: 18px; margin-bottom: 12px; }
  .dash-hero-header { margin-bottom: 16px; }
  .dash-hero-badge { font-size: 0.68rem; padding: 5px 10px; }
  .dash-hero-logo { width: 118px; height: 39px; padding: 7px 9px; border-radius: 11px; }
  .dash-balance-value { font-size: clamp(1.55rem, 8vw, 1.95rem); overflow-wrap: anywhere; }
  .dash-hero-body { align-items: flex-start; gap: 18px; }
  .dash-hero-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 8px; }
  .dash-hero-stat { min-width: 0; padding: 9px; gap: 8px; }
  .dash-hero-stat-icon { width: 32px; height: 32px; border-radius: 9px; }
  .dash-hero-stat .stat-value { font-size: 0.78rem; overflow-wrap: anywhere; }
  .growth-chip { display: block; width: fit-content; margin: 4px 0 0; }

  .mini-card-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
  .mini-card { padding: 13px; border-radius: 14px; }
  .mini-card .icon-badge { width: 32px; height: 32px; border-radius: 10px; margin-bottom: 10px; }
  .mini-card .mini-value { font-size: 1.05rem; overflow-wrap: anywhere; }

  .dash-grid-2 { gap: 12px; margin-bottom: 12px; }
  .card { padding: 16px; }
  .card-header-row { margin-bottom: 12px; }
  .chart-canvas-wrap { height: 210px; }
  .donut-wrap { width: 180px; height: 180px; }
  .cashflow-legend { align-items: flex-start; gap: 8px 16px; }
  .cashflow-legend .legend-item { flex-wrap: wrap; }
  .txn-row { gap: 9px; }
  .txn-icon { width: 34px; height: 34px; border-radius: 10px; }
  .txn-amount { font-size: 0.78rem; }

  /* Item produk di modal transaksi: susun vertikal agar angka tidak terpotong. */
  .product-items-wrap { overflow: visible; border: 0; box-shadow: none; background: transparent; }
  .product-items-table,
  .product-items-table tbody { display: block; width: 100%; }
  .product-items-table thead { display: none; }
  .product-items-table tr {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-bottom: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .product-items-table tr:last-child { margin-bottom: 0; }
  .product-items-table tbody tr:hover { background: var(--surface); }
  .product-items-table td {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    text-align: left;
  }
  .product-items-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin: 0 0 5px 2px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
  }
  .product-items-table select,
  .product-items-table input { width: 100% !important; min-width: 0; }
  .product-items-table .product-item-subtotal {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg);
    font-size: 1rem;
    font-weight: 700;
  }
  .product-items-table .product-item-subtotal::before { margin-left: 0; }
  .product-items-table .product-item-action { text-align: right; }
  .product-items-table .product-item-action button {
    width: 40px !important;
    min-height: 36px;
    font-size: 1.1rem;
  }

  .pagination { justify-content: center; text-align: center; }
}

@media (max-width: 400px) {
  .login-card { padding: 30px 22px; }
}

.dash-balance-hint {
  margin-top: 8px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.7);
}
.dash-balance-hint a {
  color: #fff;
  text-decoration: underline;
}
