/* ===================== USAHAKU — Design Tokens ===================== */
:root{
  --blue-900:#0B1E6B;
  --blue-700:#1747E0;
  --blue-600:#2A5CF0;
  --blue-500:#4B74FF;
  --blue-100:#E7EDFF;
  --blue-50:#F2F5FF;

  --ink-900:#0B0E14;
  --ink-700:#20242E;
  --ink-500:#5B6270;
  --ink-300:#9AA1AF;
  --ink-100:#E7E9EE;

  --white:#FFFFFF;
  --bg:#F5F6FA;
  --surface:#FFFFFF;
  --border:#E9EBF1;

  --green:#16A34A;
  --green-bg:#E8F8EE;
  --red:#DC2626;
  --red-bg:#FCEAEA;
  --amber:#D97706;
  --amber-bg:#FDF3E3;

  --radius:16px;
  --radius-sm:10px;
  --radius-lg:22px;

  --shadow-sm:0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.03);
  --shadow-md:0 8px 24px rgba(15,23,42,.08);
  --shadow-lg:0 16px 40px rgba(15,23,42,.14);

  --font-display:'Sora', 'Plus Jakarta Sans', sans-serif;
  --font-body:'Plus Jakarta Sans', sans-serif;

  --nav-h:68px;
  --top-h:60px;

  color-scheme: light;
}

[data-theme="dark"]{
  --ink-900:#F4F6FB;
  --ink-700:#DDE1EA;
  --ink-500:#9AA1AF;
  --ink-300:#666E7E;
  --ink-100:#2A2E3A;

  --bg:#0B0E14;
  --surface:#151923;
  --border:#242938;

  --blue-100:#152046;
  --blue-50:#101733;

  --green-bg:#0F2A1B;
  --red-bg:#2E1414;
  --amber-bg:#2E230D;

  --shadow-sm:0 1px 2px rgba(0,0,0,.3);
  --shadow-md:0 8px 24px rgba(0,0,0,.35);
  --shadow-lg:0 16px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}

*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{height:100%;}
body{
  margin:0;
  font-family:var(--font-body);
  background:var(--bg);
  color:var(--ink-900);
  -webkit-font-smoothing:antialiased;
  padding-bottom:calc(var(--nav-h) + 14px);
  transition:background .25s ease, color .25s ease;
}
h1,h2,h3{font-family:var(--font-display); margin:0; letter-spacing:-0.01em;}
input,select,button,textarea{font-family:var(--font-body); font-size:16px;}
button{cursor:pointer; border:none; background:none;}
a{color:inherit;}

::-webkit-scrollbar{width:0; height:0;}

/* ===================== TOP BAR ===================== */
.topbar{
  position:sticky; top:0; z-index:40;
  height:var(--top-h);
  display:flex; align-items:center; justify-content:space-between;
  padding:0 16px;
  background:color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter:blur(14px);
  border-bottom:1px solid var(--border);
}
.topbar-left{display:flex; align-items:center; gap:10px;}
.brand-mark{
  width:36px; height:36px; border-radius:11px;
  background:linear-gradient(155deg, var(--blue-600), var(--blue-900));
  color:#fff; display:flex; align-items:center; justify-content:center;
  font-family:var(--font-display); font-weight:800; font-size:17px;
  box-shadow:var(--shadow-sm);
  overflow:hidden;
}
.brand-mark img{width:100%; height:100%; object-fit:cover;}
.brand-text{display:flex; flex-direction:column; line-height:1.1;}
.brand-name{font-family:var(--font-display); font-weight:800; font-size:15px; letter-spacing:.02em;}
.brand-sub{font-size:11px; color:var(--ink-500); max-width:150px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.topbar-right{display:flex; align-items:center; gap:6px;}
.icon-btn{
  position:relative; width:38px; height:38px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  color:var(--ink-700); background:var(--bg);
  transition:transform .15s ease, background .2s;
}
.icon-btn:active{transform:scale(.92);}
.badge{
  position:absolute; top:2px; right:2px; min-width:16px; height:16px; padding:0 4px;
  border-radius:8px; background:var(--red); color:#fff; font-size:10px; font-weight:700;
  display:flex; align-items:center; justify-content:center; line-height:1;
}

/* ===================== LAYOUT / PAGES ===================== */
#app{max-width:640px; margin:0 auto; padding:16px; padding-bottom:24px;}
.page{display:none; animation:fadeUp .28s ease;}
.page.active{display:block;}
@keyframes fadeUp{from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:translateY(0);}}

.page-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:14px;}
.page-head h1{font-size:22px; font-weight:800;}
.page-date{font-size:12px; color:var(--ink-500); font-weight:600;}

.link-btn{color:var(--blue-700); font-weight:700; font-size:13px;}
.fab-inline{
  display:flex; align-items:center; gap:6px;
  background:var(--blue-700); color:#fff; font-weight:700; font-size:13px;
  padding:9px 14px; border-radius:12px; box-shadow:var(--shadow-sm);
  transition:transform .15s ease;
}
.fab-inline:active{transform:scale(.95);}

/* ===================== PERIOD PILLS ===================== */
.period-pills{display:flex; gap:8px; overflow-x:auto; margin-bottom:16px; padding-bottom:2px;}
.pill{
  flex:0 0 auto; padding:8px 14px; border-radius:999px; font-size:13px; font-weight:700;
  background:var(--surface); color:var(--ink-500); border:1px solid var(--border);
  transition:all .18s ease;
}
.pill.active{background:var(--blue-700); color:#fff; border-color:var(--blue-700);}

/* ===================== KPI CARDS ===================== */
.kpi-grid{display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-bottom:18px;}
.kpi-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:14px; box-shadow:var(--shadow-sm); position:relative; overflow:hidden;
  display:flex; flex-direction:column; gap:6px;
}
.kpi-icon{
  width:32px; height:32px; border-radius:10px; display:flex; align-items:center; justify-content:center;
  font-size:14px; margin-bottom:2px;
}
.kpi-card.income .kpi-icon{background:var(--green-bg); color:var(--green);}
.kpi-card.expense .kpi-icon{background:var(--red-bg); color:var(--red);}
.kpi-card.profit .kpi-icon{background:var(--blue-100); color:var(--blue-700);}
.kpi-card.trx .kpi-icon{background:var(--blue-50); color:var(--blue-600);}
.kpi-card.sold .kpi-icon{background:var(--amber-bg); color:var(--amber);}
.kpi-card.low .kpi-icon{background:var(--red-bg); color:var(--red);}
.kpi-label{font-size:11.5px; color:var(--ink-500); font-weight:600;}
.kpi-value{font-family:var(--font-display); font-size:17px; font-weight:700; letter-spacing:-.01em;}

/* ===================== QUICK ACTIONS ===================== */
.quick-actions{display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-bottom:18px;}
.qa-btn{
  background:var(--surface); border:1px solid var(--border); border-radius:14px;
  padding:12px 4px; display:flex; flex-direction:column; align-items:center; gap:6px;
  font-size:11px; font-weight:700; color:var(--ink-700); box-shadow:var(--shadow-sm);
  transition:transform .15s ease;
}
.qa-btn:active{transform:scale(.94);}
.qa-btn i{font-size:16px; color:var(--blue-700);}

/* ===================== CARDS ===================== */
.card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg);
  padding:16px; margin-bottom:14px; box-shadow:var(--shadow-sm);
}
.card-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:12px;}
.card-head h3{font-size:14.5px; font-weight:700;}
.chart-card canvas{max-width:100%;}
.empty-hint{text-align:center; color:var(--ink-300); font-size:13px; padding:24px 8px;}

/* ===================== LISTS ===================== */
.list{display:flex; flex-direction:column; gap:10px;}
.list-item{
  display:flex; align-items:center; gap:12px; padding:11px; border-radius:14px;
  background:var(--bg); border:1px solid var(--border); transition:transform .12s ease;
}
.list-item:active{transform:scale(.985);}
.li-icon{
  width:40px; height:40px; border-radius:12px; flex:0 0 40px;
  display:flex; align-items:center; justify-content:center; font-size:15px;
  background:var(--blue-100); color:var(--blue-700); overflow:hidden;
}
.li-icon img{width:100%; height:100%; object-fit:cover;}
.li-body{flex:1; min-width:0;}
.li-title{font-weight:700; font-size:13.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.li-sub{font-size:11.5px; color:var(--ink-500); margin-top:1px;}
.li-right{text-align:right; flex:0 0 auto;}
.li-amount{font-weight:800; font-size:13.5px; font-family:var(--font-display);}
.li-amount.pos{color:var(--green);}
.li-amount.neg{color:var(--red);}
.li-tag{
  font-size:10px; font-weight:700; padding:2px 8px; border-radius:999px; margin-top:3px; display:inline-block;
}
.li-tag.belum{background:var(--amber-bg); color:var(--amber);}
.li-tag.lunas{background:var(--green-bg); color:var(--green);}

/* ===================== PRODUK GRID ===================== */
.search-row{display:flex; gap:8px; margin-bottom:14px;}
.search-box{
  flex:1; display:flex; align-items:center; gap:8px; background:var(--surface);
  border:1px solid var(--border); border-radius:12px; padding:10px 12px;
}
.search-box i{color:var(--ink-300); font-size:13px;}
.search-box input{border:none; outline:none; background:transparent; width:100%; color:var(--ink-900);}
#produkKategoriFilter{
  border:1px solid var(--border); border-radius:12px; background:var(--surface); color:var(--ink-700);
  padding:0 10px; font-size:13px; font-weight:600;
}
.produk-grid{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.produk-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden;
  box-shadow:var(--shadow-sm); transition:transform .15s ease;
}
.produk-card:active{transform:scale(.97);}
.produk-thumb{
  height:96px; background:var(--blue-50); display:flex; align-items:center; justify-content:center;
  color:var(--blue-500); font-size:26px; position:relative;
}
.produk-thumb img{width:100%; height:100%; object-fit:cover;}
.produk-low-flag{
  position:absolute; top:6px; right:6px; background:var(--red); color:#fff; font-size:9px; font-weight:800;
  padding:2px 6px; border-radius:999px;
}
.produk-info{padding:10px;}
.produk-name{font-weight:700; font-size:12.5px; margin-bottom:3px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.produk-price{font-family:var(--font-display); font-weight:800; font-size:13.5px; color:var(--blue-700);}
.produk-meta{display:flex; justify-content:space-between; align-items:center; margin-top:5px;}
.produk-stok{font-size:10.5px; color:var(--ink-500); font-weight:600;}
.produk-cat{
  font-size:9.5px; font-weight:700; color:var(--ink-500); background:var(--bg);
  padding:2px 7px; border-radius:999px; display:inline-block; margin-top:5px;
}

/* ===================== TABLE ===================== */
.table-wrap{overflow-x:auto; border-radius:var(--radius); border:1px solid var(--border); background:var(--surface);}
.data-table{width:100%; border-collapse:collapse; font-size:12.5px; min-width:520px;}
.data-table th{
  text-align:left; padding:11px 12px; background:var(--bg); color:var(--ink-500);
  font-weight:700; font-size:11px; text-transform:uppercase; letter-spacing:.03em;
}
.data-table td{padding:11px 12px; border-top:1px solid var(--border); font-weight:600;}
.data-table tr td:first-child{font-weight:700;}
.stok-low-row td{color:var(--red);}

/* ===================== TABS ===================== */
.tabs{display:flex; gap:8px; margin-bottom:14px; background:var(--bg); padding:4px; border-radius:14px;}
.tab-btn{flex:1; padding:9px; border-radius:11px; font-weight:700; font-size:12.5px; color:var(--ink-500); transition:all .18s ease;}
.tab-btn.active{background:var(--surface); color:var(--blue-700); box-shadow:var(--shadow-sm);}

/* ===================== REPORT ===================== */
.custom-date-row{display:flex; flex-direction:column; gap:10px; margin-bottom:14px;}
.custom-date-inputs{display:flex; align-items:center; gap:8px;}
.custom-date-inputs span{flex:0 0 auto; font-size:12px; color:var(--ink-500); font-weight:600;}
.custom-date-inputs input{flex:1; min-width:0; border:1px solid var(--border); border-radius:10px; padding:9px; background:var(--surface); color:var(--ink-900);}
.custom-date-row .btn-secondary{width:100%;}
.report-summary div{display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px dashed var(--border); font-size:13px; font-weight:600; color:var(--ink-500);}
.report-summary div b{color:var(--ink-900); font-family:var(--font-display);}
.report-summary .total{border-bottom:none; margin-top:2px;}
.report-summary .total b{color:var(--blue-700); font-size:16px;}
.export-row{display:flex; gap:10px; margin-top:6px;}
.export-row button{flex:1;}

/* ===================== BUTTONS ===================== */
.btn-primary{
  background:var(--blue-700); color:#fff; font-weight:700; font-size:14px;
  padding:13px 18px; border-radius:14px; box-shadow:var(--shadow-sm); transition:transform .15s ease, opacity .15s;
}
.btn-primary:active{transform:scale(.97);}
.btn-primary.full{width:100%; margin-top:6px;}
.btn-primary.danger{background:var(--red);}
.btn-secondary{
  background:var(--bg); color:var(--ink-700); font-weight:700; font-size:14px;
  padding:13px 18px; border-radius:14px; border:1px solid var(--border); transition:transform .15s ease;
}
.btn-secondary:active{transform:scale(.97);}
.btn-secondary.small{padding:8px 12px; font-size:12.5px;}
.btn-secondary.danger{color:var(--red); border-color:var(--red-bg);}

/* ===================== FORMS ===================== */
.field{margin-bottom:12px;}
.field label{display:block; font-size:12px; font-weight:700; color:var(--ink-500); margin-bottom:6px;}
.field input, .field select, .field textarea{
  width:100%; padding:12px 13px; border-radius:12px; border:1px solid var(--border);
  background:var(--bg); color:var(--ink-900); outline:none; transition:border-color .15s ease;
  font-size:16px; /* prevents iOS zoom */
}
.field input:focus, .field select:focus{border-color:var(--blue-600);}
.field-row{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
.calc-box{
  background:var(--blue-50); border-radius:14px; padding:12px 14px; margin:12px 0;
  display:flex; flex-direction:column; gap:6px;
}
.calc-box div{display:flex; justify-content:space-between; font-size:12.5px; font-weight:600; color:var(--ink-500);}
.calc-box div b{color:var(--blue-700); font-family:var(--font-display);}

.form-photo-row{display:flex; align-items:center; gap:12px; margin-bottom:14px;}
.form-photo-box{
  width:56px; height:56px; border-radius:14px; flex:0 0 56px;
  background:var(--blue-50) center/cover no-repeat;
  display:flex; align-items:center; justify-content:center; color:var(--blue-500); font-size:20px;
  transition:background .2s ease;
}

/* ===================== PROFILE ===================== */
.profile-card{display:flex; flex-direction:column; align-items:center; text-align:center;}
.profile-logo-wrap{position:relative; margin-bottom:16px;}
.profile-logo, .profile-logo-placeholder{
  width:84px; height:84px; border-radius:22px; object-fit:cover; background:var(--blue-50);
  display:flex; align-items:center; justify-content:center; color:var(--blue-500); font-size:28px;
}
.logo-upload-btn{
  position:absolute; bottom:-4px; right:-4px; width:28px; height:28px; border-radius:9px;
  background:var(--blue-700); color:#fff; display:flex; align-items:center; justify-content:center;
  font-size:11px; box-shadow:var(--shadow-sm); cursor:pointer;
}
.profile-card .field{width:100%; text-align:left;}

.setting-row{
  display:flex; align-items:center; justify-content:space-between; padding:12px 0;
  border-bottom:1px solid var(--border); font-size:13.5px; font-weight:600;
}
.setting-row:last-child{border-bottom:none;}
.setting-row span{display:flex; align-items:center; gap:10px;}
.setting-row span i{color:var(--blue-700); width:16px;}
.setting-row.danger span i{color:var(--red);}

.switch{position:relative; display:inline-block; width:42px; height:24px; flex:0 0 42px;}
.switch input{opacity:0; width:0; height:0;}
.slider{position:absolute; inset:0; background:var(--ink-100); border-radius:999px; transition:.2s; cursor:pointer;}
.slider::before{content:''; position:absolute; height:18px; width:18px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.2s; box-shadow:var(--shadow-sm);}
.switch input:checked + .slider{background:var(--blue-700);}
.switch input:checked + .slider::before{transform:translateX(18px);}

/* ===================== BOTTOM NAV ===================== */
.bottom-nav{
  position:fixed; bottom:0; left:0; right:0; height:var(--nav-h); z-index:50;
  background:color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter:blur(16px);
  border-top:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-around;
  padding-bottom:env(safe-area-inset-bottom);
  max-width:640px; margin:0 auto;
}
.nav-item{
  display:flex; flex-direction:column; align-items:center; gap:3px; color:var(--ink-300);
  font-size:10px; font-weight:700; flex:1; padding:6px 0; transition:color .18s ease;
}
.nav-item i{font-size:18px;}
.nav-item.active{color:var(--blue-700);}
.nav-fab{
  position:relative; top:-18px; flex:0 0 54px; width:54px; height:54px; border-radius:18px;
  background:linear-gradient(155deg, var(--blue-600), var(--blue-900)); color:#fff;
  box-shadow:0 10px 22px rgba(23,71,224,.4); display:flex; align-items:center; justify-content:center;
  transition:transform .18s ease;
}
.nav-fab i{font-size:19px;}
.nav-fab:active{transform:scale(.9) rotate(90deg);}

/* ===================== SHEETS / MODALS ===================== */
.modal-overlay{
  position:fixed; inset:0; background:rgba(8,11,20,.5); z-index:90; opacity:0; visibility:hidden;
  transition:opacity .22s ease; backdrop-filter:blur(2px);
}
.modal-overlay.show{opacity:1; visibility:visible;}
.sheet{
  position:fixed; left:0; right:0; bottom:0; z-index:95; max-width:640px; margin:0 auto;
  background:var(--surface); border-radius:24px 24px 0 0; padding:10px 18px 22px;
  transform:translateY(105%); transition:transform .3s cubic-bezier(.32,.72,0,1);
  max-height:88vh; overflow-y:auto; box-shadow:var(--shadow-lg);
}
.sheet.show{transform:translateY(0);}
.sheet-handle{width:38px; height:4px; background:var(--ink-100); border-radius:999px; margin:0 auto 14px;}
.sheet h3{font-size:17px; font-weight:800; margin-bottom:16px;}
.sheet-btn-row{display:flex; gap:10px; margin-top:6px;}
.sheet-btn-row .btn-primary{flex:1;}
.sheet-btn-row .btn-secondary{flex:0 0 auto;}
.sheet-actions{display:flex; flex-direction:column; gap:8px;}
.sheet-actions button{
  display:flex; align-items:center; gap:12px; padding:13px 14px; border-radius:14px; background:var(--bg);
  font-weight:700; font-size:14px; color:var(--ink-700); transition:transform .15s ease;
}
.sheet-actions button:active{transform:scale(.98);}
.sheet-actions button i{color:var(--blue-700); width:18px;}

/* ===================== CONFIRM DIALOG ===================== */
.confirm-box{
  position:fixed; top:50%; left:50%; transform:translate(-50%,-50%) scale(.92); z-index:120;
  background:var(--surface); border-radius:20px; padding:22px; width:86%; max-width:340px;
  box-shadow:var(--shadow-lg); opacity:0; visibility:hidden; transition:all .2s ease; text-align:center;
}
.confirm-box.show{opacity:1; visibility:visible; transform:translate(-50%,-50%) scale(1);}
.confirm-box p{font-size:14px; font-weight:600; margin-bottom:18px;}
.confirm-btn-row{display:flex; gap:10px;}
.confirm-btn-row button{flex:1;}

.notif-detail-icon{width:48px; height:48px; border-radius:14px; display:flex; align-items:center; justify-content:center; font-size:20px; background:var(--blue-100); color:var(--blue-700); margin-bottom:12px;}
.notif-detail-time{font-size:12px; color:var(--ink-500); font-weight:600; margin:-6px 0 12px;}
.notif-detail-text{font-size:14.5px; font-weight:500; line-height:1.6; color:var(--ink-900); margin-bottom:18px;}
.li-unread-dot{width:9px; height:9px; border-radius:50%; background:var(--blue-700); flex:0 0 9px; align-self:flex-start; margin-top:4px;}

/* ===================== TOAST ===================== */
.toast-stack{position:fixed; top:14px; left:50%; transform:translateX(-50%); z-index:200; display:flex; flex-direction:column; gap:8px; width:90%; max-width:380px;}
.toast{
  background:var(--ink-900); color:var(--white); padding:12px 16px; border-radius:14px; font-size:13px; font-weight:600;
  display:flex; align-items:center; gap:10px; box-shadow:var(--shadow-lg);
  animation:toastIn .25s ease;
}
[data-theme="dark"] .toast{background:var(--surface); border:1px solid var(--border);}
.toast i{color:var(--blue-500);}
.toast.success i{color:var(--green);}
.toast.error i{color:var(--red);}
@keyframes toastIn{from{opacity:0; transform:translateY(-10px);} to{opacity:1; transform:translateY(0);}}

/* ===================== SKELETON ===================== */
.skeleton-overlay{position:fixed; inset:0; z-index:150; background:var(--bg); padding:16px; padding-top:80px;}
.skeleton-card{height:90px; border-radius:16px; margin-bottom:14px; background:linear-gradient(90deg, var(--ink-100) 25%, var(--border) 37%, var(--ink-100) 63%); background-size:400% 100%; animation:shimmer 1.4s ease infinite;}
@keyframes shimmer{0%{background-position:100% 0;} 100%{background-position:-100% 0;}}

/* ===================== RESPONSIVE (tablet/desktop) ===================== */
@media (min-width: 720px){
  #app{max-width:960px; padding:28px 24px;}
  .topbar{max-width:960px; margin:0 auto; border-radius:0 0 18px 18px;}
  .bottom-nav{max-width:960px;}
  .kpi-grid{grid-template-columns:repeat(3,1fr);}
  .produk-grid{grid-template-columns:repeat(4,1fr);}
  .quick-actions{grid-template-columns:repeat(4,220px); justify-content:start;}
  .sheet{
    left:auto; right:24px; bottom:24px; max-width:420px; border-radius:22px;
    transform:translateY(30px) scale(.96); opacity:0; visibility:hidden;
  }
  .sheet.show{transform:translateY(0) scale(1); opacity:1; visibility:visible;}
  .page-head h1{font-size:26px;}
}

@media (min-width: 720px) and (max-width: 1080px){
  .produk-grid{grid-template-columns:repeat(3,1fr);}
}

/* Desktop-only side nav replacement hint */
@media (min-width:720px){
  #app{padding-bottom:40px;}
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  *{animation-duration:.001ms !important; transition-duration:.001ms !important;}
}
