/* ============================================================
   Welly Dashboard — mobile-first, Apple-inspired (synergy style)
   ============================================================ */
:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --accent: #0066cc;
  --accent-strong: #0077ed;
  --green: #1a7f37;
  --green-dot: #30b455;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --border: #d2d2d7;
  --hairline: rgba(0, 0, 0, 0.08);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  --card-shadow-hover: 0 18px 44px rgba(0, 0, 0, 0.09);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
::selection { background: rgba(0, 102, 204, 0.16); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
img, svg { display: block; }
button { font-family: inherit; cursor: pointer; }

/* ===== PIN SCREEN ===== */
.pin-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #f5f5f7 0%, #ffffff 60%);
  padding: 24px;
}
.pin-card {
  width: 100%; max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 36px 28px 28px;
  box-shadow: var(--card-shadow-hover);
  text-align: center;
}
.pin-logo {
  width: 64px; height: 64px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  background: var(--bg-alt); border-radius: 20px;
}
.pin-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.pin-sub { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.pin-dots {
  display: flex; gap: 14px; justify-content: center;
  margin: 26px 0 18px;
}
.pin-dots span {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--border); transition: background 0.2s var(--ease-out);
}
.pin-dots span.filled { background: var(--accent); }
.pin-input {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px 14px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.45em;
  text-align: center;
  font-family: inherit;
  margin-bottom: 14px;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.pin-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}
.pin-input::placeholder {
  letter-spacing: 0.02em;
  font-weight: 400;
  font-size: 14px;
  color: var(--text-3);
}
.btn-primary {
  width: 100%;
  background: var(--accent); color: #fff;
  border: none; border-radius: 14px;
  padding: 14px; font-size: 16px; font-weight: 600;
  transition: background 0.2s var(--ease-out), transform 0.1s;
}
.btn-primary:active { transform: scale(0.98); background: var(--accent-strong); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.pin-error { color: var(--red); font-size: 14px; margin-top: 12px; min-height: 20px; }
.pin-hint { color: var(--text-3); font-size: 12.5px; margin-top: 14px; }

/* ===== DASHBOARD ===== */
.dash-screen { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-inner {
  max-width: 620px; margin: 0 auto;
  height: 56px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 22px; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--text-2); }
.btn-logout {
  background: var(--bg-alt); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 14px; font-size: 13px; font-weight: 500;
}
.btn-logout:active { background: var(--border); }

.container { max-width: 620px; margin: 0 auto; padding: 16px 16px 48px; }

.update-line {
  color: var(--text-3); font-size: 12px;
  margin-bottom: 12px;
}

/* Summary */
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  background: var(--bg-alt); border-radius: var(--radius-md);
  padding: 14px 12px;
  border: 1px solid var(--hairline);
}
.stat-card.stat-accent { background: var(--accent); border-color: var(--accent); }
.stat-card.stat-accent .stat-label, .stat-card.stat-accent .stat-sub { color: rgba(255,255,255,0.85); }
.stat-card.stat-accent .stat-value { color: #fff; }
.stat-label { font-size: 11px; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.stat-sub { font-size: 10.5px; color: var(--text-3); }

/* Section titles */
.section-title {
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
  margin: 26px 0 12px;
}

/* Outlet cards */
.outlet-grid { display: grid; gap: 10px; }
.outlet-card {
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 6px 14px;
  align-items: center;
}
.outlet-name { font-size: 15px; font-weight: 700; }
.outlet-tag {
  font-size: 10.5px; font-weight: 600; color: var(--accent);
  background: rgba(0,102,204,0.1); padding: 3px 9px; border-radius: 999px;
  justify-self: end;
}
.outlet-stats { grid-column: 1 / -1; display: flex; gap: 18px; font-size: 12px; color: var(--text-2); }
.outlet-stats b { color: var(--text); font-weight: 650; }
.outlet-bar { grid-column: 1 / -1; height: 6px; background: var(--bg-alt); border-radius: 999px; overflow: hidden; }
.outlet-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.6s var(--ease-out); }

/* Chart card */
.chart-card {
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--card-shadow);
}
.chart-row { display: flex; align-items: center; gap: 18px; }
.donut-wrap { position: relative; flex-shrink: 0; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.donut-total { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; }
.donut-label { font-size: 10px; color: var(--text-3); }
.legend { list-style: none; flex: 1; display: grid; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend .legend-val { margin-left: auto; font-weight: 650; }
.legend .legend-pct { color: var(--text-3); font-size: 11.5px; width: 40px; text-align: right; }

/* Bar list (kategori) */
.bar-list { display: grid; gap: 10px; }
.bar-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; }
.bar-item .bar-name { font-size: 13px; font-weight: 550; }
.bar-item .bar-val { font-size: 12px; color: var(--text-2); }
.bar-item .bar-track { grid-column: 1 / -1; height: 8px; background: var(--bg-alt); border-radius: 999px; overflow: hidden; }
.bar-item .bar-fill { height: 100%; border-radius: 999px; transition: width 0.6s var(--ease-out); }

/* Tabs & filter */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-top: 26px; }
.list-head .section-title { margin: 0; }
.count-pill {
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
  background: var(--bg-alt); padding: 4px 10px; border-radius: 999px;
}
.tabs {
  display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px;
  -webkit-overflow-scrolling: touch; padding-bottom: 2px;
}
.tab {
  flex-shrink: 0;
  background: var(--bg-alt); border: 1px solid transparent; border-radius: 10px;
  padding: 8px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: all 0.2s var(--ease-out);
}
.tab.active { background: var(--accent); color: #fff; }
.filter-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 12px; }
.search {
  width: 100%;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 14px; font-size: 14px; font-family: inherit;
}
.select {
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 10px; font-size: 13px; font-family: inherit;
  max-width: 150px;
}

/* Produk list */
.produk-list { display: grid; gap: 8px; }
.produk-item {
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--card-shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  align-items: center;
}
.produk-nama { font-size: 14px; font-weight: 600; }
.produk-meta { font-size: 11.5px; color: var(--text-2); display: flex; gap: 8px; flex-wrap: wrap; }
.produk-meta .sku { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: var(--text-3); }
.produk-kanan { text-align: right; display: grid; gap: 4px; justify-items: end; }
.stok-pill {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
}
.stok-pill.aman { background: rgba(48,180,85,0.14); color: var(--green); }
.stok-pill.menipis { background: var(--amber-bg); color: var(--amber); }
.stok-pill.habis { background: var(--red-bg); color: var(--red); }
.produk-harga { font-size: 12px; color: var(--text-2); }
.produk-harga b { color: var(--text); }
.badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em;
  padding: 2px 7px; border-radius: 6px;
}
.badge.ikw { background: rgba(0,102,204,0.12); color: var(--accent); }
.badge.akw { background: rgba(107,78,255,0.12); color: #6b4eff; }
.badge.gdg { background: rgba(26,127,55,0.14); color: var(--green); }

.empty-note { text-align: center; color: var(--text-3); font-size: 14px; padding: 30px 0; }

/* Mutasi */
.mutasi-card {
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--card-shadow);
}
.mutasi-empty { color: var(--text-3); font-size: 13.5px; text-align: center; padding: 10px 0; }
.mutasi-list { display: grid; gap: 10px; }
.mutasi-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.mutasi-badge {
  font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; flex-shrink: 0;
}
.mutasi-badge.in { background: rgba(48,180,85,0.14); color: var(--green); }
.mutasi-badge.out { background: rgba(0,102,204,0.12); color: var(--accent); }
.mutasi-badge.sales { background: rgba(180,83,9,0.14); color: var(--amber); }
.mutasi-info { flex: 1; min-width: 0; }
.mutasi-info .m-nama { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mutasi-info .m-meta { font-size: 11px; color: var(--text-3); }
.mutasi-qty { font-weight: 700; font-size: 13px; }

.footer { margin-top: 34px; text-align: center; }
.footer p { font-size: 12px; color: var(--text-3); }
.footer .footer-sub { font-size: 11px; margin-top: 3px; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, #ececf0 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

@media (max-width: 360px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .stat-card:last-child { grid-column: 1 / -1; }
}
