/* Sukli — A Store System : design system
   Navy/white shell with purple accent, green/blue/orange/purple KPI cards —
   matching the approved UI illustrations. */

:root {
  --navy-900: #12192b;
  --navy-800: #1a2338;
  --navy-700: #232f49;
  --navy-600: #303f5f;
  --purple: #6d5bd0;
  --purple-dark: #5b48c2;
  --green: #16a34a;
  --green-dark: #128a3e;
  --blue: #2563eb;
  --orange: #f97316;
  --red: #ef4444;
  --amber: #f59e0b;

  --bg: #f2f4f9;
  --card-bg: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e6e9f0;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);

  --sidebar-w: 250px;
  --topbar-h: 64px;
  --bottomnav-h: 60px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 700; }
p { margin: 0 0 8px; }
table { width: 100%; border-collapse: collapse; }
button { font-family: inherit; cursor: pointer; }

.container { max-width: 1400px; margin: 0 auto; }

/* ---------------------------------------------------------------------- */
/* App shell / sidebar                                                    */
/* ---------------------------------------------------------------------- */

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy-900);
  color: #cbd3e1;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .brand-icon {
  width: 34px; height: 34px;
  background: var(--green);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand small { display: block; font-weight: 400; font-size: 11px; color: #9aa5ba; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #b7c0d4;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-nav a svg { flex-shrink: 0; opacity: 0.85; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.is-active { background: var(--green); color: #fff; }
.sidebar-nav a.is-active svg { opacity: 1; }
.sidebar-nav .nav-section-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: #6b7690; padding: 14px 12px 6px;
}

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-foot form button {
  width: 100%; background: rgba(255,255,255,0.06); color: #cbd3e1;
  border: none; border-radius: 8px; padding: 9px; font-size: 13px; font-weight: 600;
}
.sidebar-foot form button:hover { background: rgba(255,255,255,0.12); color: #fff; }

.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(10,14,26,0.5);
  z-index: 35; display: none;
}

/* ---------------------------------------------------------------------- */
/* Main / topbar                                                          */
/* ---------------------------------------------------------------------- */

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
  gap: 16px;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.hamburger {
  display: none; background: none; border: none; padding: 6px;
  border-radius: 8px; color: var(--text);
}
.hamburger:hover { background: var(--bg); }

.user-chip { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--purple);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-chip .user-meta { line-height: 1.25; }
.user-chip .user-name { font-weight: 600; font-size: 13px; }
.user-chip .user-role { font-size: 11px; color: var(--text-muted); }

.content { padding: 22px 24px 90px; flex: 1; }

/* ---------------------------------------------------------------------- */
/* Bottom nav (tablet/mobile)                                              */
/* ---------------------------------------------------------------------- */

.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottomnav-h);
  background: #fff; border-top: 1px solid var(--border);
  z-index: 30;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a, .bottom-nav button.more-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10.5px; color: var(--text-muted); background: none; border: none;
}
.bottom-nav a.is-active, .bottom-nav button.more-btn.is-active { color: var(--green); }
.bottom-nav svg { flex-shrink: 0; }

/* ---------------------------------------------------------------------- */
/* Cards / KPI                                                             */
/* ---------------------------------------------------------------------- */

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.card-subtitle { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.kpi-card {
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  color: #fff;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi-card .kpi-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.03em; opacity: 0.9; text-transform: uppercase; }
.kpi-card .kpi-value { font-size: 24px; font-weight: 700; margin: 6px 0 4px; }
.kpi-card .kpi-delta { font-size: 12px; font-weight: 600; opacity: 0.95; }
.kpi-card .kpi-icon { position: absolute; right: 14px; top: 14px; opacity: 0.35; }
.kpi-green { background: linear-gradient(135deg, #22c55e, #16a34a); }
.kpi-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.kpi-orange { background: linear-gradient(135deg, #fb923c, #f97316); }
.kpi-purple { background: linear-gradient(135deg, #8b7cf6, #6d5bd0); }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; padding: 9px 16px;
  font-size: 13px; font-weight: 600; background: #fff; color: var(--text);
  border-color: var(--border);
}
.btn:hover { background: var(--bg); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 13px 18px; font-size: 14.5px; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-purple { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn-purple:hover { background: var(--purple-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pay-cash { background: var(--green); border-color: var(--green); color: #fff; }
.pay-gcash { background: var(--blue); border-color: var(--blue); color: #fff; }
.pay-utang { background: var(--orange); border-color: var(--orange); color: #fff; }
.pay-btn.is-selected { outline: 3px solid rgba(0,0,0,0.15); }

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */

.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13.5px; background: #fff; color: var(--text); font-family: inherit;
}
.form-control:focus, select:focus, textarea:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(109,91,208,0.15); }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.input-icon-group { position: relative; }
.input-icon-group svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: 0.5; }
.input-icon-group .form-control { padding-left: 36px; }

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfe; }

/* ---------------------------------------------------------------------- */
/* Badges / status pills                                                   */
/* ---------------------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f2f6; color: #4b5563; }
.badge-purple { background: #ede9fe; color: #6d5bd0; }

/* ---------------------------------------------------------------------- */
/* Alerts / flash                                                          */
/* ---------------------------------------------------------------------- */

.alert { border-radius: 10px; padding: 12px 16px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.alert-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ---------------------------------------------------------------------- */
/* Auth / login page                                                       */
/* ---------------------------------------------------------------------- */

.auth-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--navy-900), var(--purple-dark));
  padding: 20px;
}
.auth-card { background: #fff; border-radius: 18px; padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-brand .brand-icon { width: 40px; height: 40px; background: var(--green); border-radius: 10px; display:flex; align-items:center; justify-content:center; }
.auth-brand strong { font-size: 18px; }
.auth-brand small { display: block; font-size: 11.5px; color: var(--text-muted); }

/* ---------------------------------------------------------------------- */
/* Misc                                                                    */
/* ---------------------------------------------------------------------- */

.error-screen { text-align: center; padding: 90px 20px; }
.error-screen h1 { font-size: 56px; color: var(--purple); }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.section-tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.section-tabs a { padding: 9px 4px; margin-right: 18px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.section-tabs a.is-active { color: var(--text); border-color: var(--green); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10,14,26,0.5); display: none; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal-backdrop.is-open { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-lg { max-width: 560px; }

/* ---------------------------------------------------------------------- */
/* Responsive: tablet / mobile                                             */
/* ---------------------------------------------------------------------- */

@media (max-width: 1199px) {
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,0.3); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar.is-open ~ .sidebar-overlay { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .bottom-nav { display: flex; }
  .content { padding: 18px 16px 90px; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .topbar h1 { font-size: 16px; }
  .card { padding: 14px 16px; }
  .user-chip .user-meta { display: none; }
}

/* ---------------------------------------------------------------------- */
/* POS                                                                     */
/* ---------------------------------------------------------------------- */

.pos-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 1024px) {
  .pos-layout { grid-template-columns: 1fr; }
  .pos-cart { order: 2; }
  .pos-products { order: 1; }
}

.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.pos-product {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  text-align: left; cursor: pointer; transition: box-shadow .15s ease, transform .1s ease;
}
.pos-product:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.pos-product:active { transform: translateY(0); }
.pos-product-thumb { width: 100%; height: 84px; border-radius: 8px; margin-bottom: 8px; font-size: 11px; }
.pos-product-name { font-weight: 600; font-size: 13px; margin-bottom: 6px; min-height: 34px; }
.pos-product-price { color: var(--green-dark); font-weight: 700; font-size: 14px; }
.pos-product-stock { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.pos-product.is-hidden { display: none; }
.pos-product.is-active-product { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue) inset; }

.settings-layout { grid-template-columns: 2.2fr 1fr; align-items: start; }
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } }

.pos-cart { position: sticky; top: calc(var(--topbar-h) + 16px); }
.pos-cart-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.pos-cart-item .pci-name { font-size: 13px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-cart-item .pci-price { font-size: 11.5px; color: var(--text-muted); }
.pos-qty-controls { display: flex; align-items: center; gap: 6px; }
.pos-qty-controls button { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: #fff; line-height: 1; }
.pos-cart-item .pci-total { font-size: 13px; font-weight: 700; width: 64px; text-align: right; }
.pos-cart-item .pci-remove { color: var(--red); background: none; border: none; font-size: 16px; padding: 0 2px; }
@media (max-width: 1024px) { .pos-cart { position: static; } }

.pos-customer-results { position: relative; margin-top: 4px; }
.pos-customer-results:not(:empty) {
  border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: var(--shadow);
  max-height: 180px; overflow-y: auto;
}
.pos-customer-result { padding: 8px 12px; cursor: pointer; font-size: 13px; }
.pos-customer-result:hover { background: var(--bg-soft, #f4f5fa); }
.pos-customer-result .pcr-contact { color: var(--text-muted); font-size: 11.5px; }
.pos-customer-selected-chip {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; padding: 6px 10px;
  background: var(--bg-soft, #f4f5fa); border-radius: 8px; font-size: 12.5px;
}
.pos-customer-selected-chip button { border: none; background: none; color: var(--red); font-size: 14px; line-height: 1; cursor: pointer; }

.pos-split-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pos-split-row select { flex: 1.2; }
.pos-split-row input { flex: 1; }
.pos-split-row .psr-remove { border: none; background: none; color: var(--red); font-size: 16px; padding: 0 2px; cursor: pointer; }

.product-thumb {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover; display: block;
  border: 1px solid var(--border);
}
.product-thumb-placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--bg-soft, #f4f5fa); color: var(--text-muted); font-size: 8px; font-weight: 700;
  line-height: 1.2;
}
.product-thumb-lg { width: 84px; height: 84px; border-radius: 12px; font-size: 11px; }
