:root {
  --ink:       #1a1a1a;
  --ink2:      #4a4a4a;
  --ink3:      #8a8a8a;
  --surface:   #ffffff;
  --surface2:  #f5f5f4;
  --surface3:  #eeede9;
  --border:    #e0deda;
  --accent:    #2563eb;
  --accent-bg: #eff6ff;
  --success:   #16a34a;
  --success-bg:#f0fdf4;
  --warn:      #d97706;
  --warn-bg:   #fffbeb;
  --danger:    #dc2626;
  --danger-bg: #fef2f2;
  --radius:    8px;
  --radius-lg: 12px;
  --nav-w:     220px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface2);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Typography ── */
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem;   font-weight: 600; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout shell ── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--nav-w);
  background: var(--ink);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .shop-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  display: block;
}
.sidebar-logo .shop-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-nav { flex: 1; padding: 0.75rem 0; }
.nav-section { padding: 0.5rem 0; }
.nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  padding: 0.25rem 1.25rem 0.4rem;
  display: block;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1.25rem;
  color: rgba(255,255,255,0.65);
  font-size: 0.875rem;
  transition: background 0.1s, color 0.1s;
  border-left: 2px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255,255,255,0.1); color: #fff; border-left-color: var(--accent); }
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.cashier-name { font-size: 0.8rem; color: rgba(255,255,255,0.55); margin-bottom: 0.5rem; }
.cashier-name strong { color: #fff; display: block; }

/* ── Main content ── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }

.page-content { flex: 1; padding: 1.5rem; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.75rem;
}
.card-title { font-size: 0.875rem; font-weight: 600; color: var(--ink2); }

/* ── Forms ── */
.form-group { margin-bottom: 0.875rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--ink2); margin-bottom: 0.3rem; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  height: 38px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.875rem;
  font-family: var(--font);
  transition: border-color 0.1s, box-shadow 0.1s;
}
.form-textarea { height: auto; padding: 0.5rem 0.75rem; resize: vertical; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 0.875rem;
  height: 36px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.1s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 15px; height: 15px; }

.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink2); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface2); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-lg { height: 44px; padding: 0 1.25rem; font-size: 0.95rem; }
.btn-sm { height: 30px; padding: 0 0.65rem; font-size: 0.78rem; }
.btn-xl { height: 56px; padding: 0 2rem; font-size: 1rem; font-weight: 600; border-radius: var(--radius-lg); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink3);
  padding: 0.6rem 0.875rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-ok      { background: var(--success-bg); color: var(--success); }
.badge-low     { background: var(--warn-bg);    color: var(--warn); }
.badge-out     { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--accent-bg);  color: var(--accent); }
.badge-neutral { background: var(--surface3);   color: var(--ink2); }

/* ── Alerts ── */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); font-size: 0.85rem; margin-bottom: 1rem; }
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #86efac; }
.alert-warn    { background: var(--warn-bg);    color: var(--warn);    border: 1px solid #fcd34d; }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; }
.stat-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink3); margin-bottom: 0.35rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); line-height: 1; }
.stat-value.green { color: var(--success); }
.stat-value.warn  { color: var(--warn); }
.stat-value.red   { color: var(--danger); }
.stat-delta { font-size: 0.75rem; color: var(--ink3); margin-top: 0.25rem; }

/* ── POS specific ── */
.pos-grid { display: grid; grid-template-columns: 1fr 380px; gap: 1.25rem; height: calc(100vh - 64px); }
.pos-products { overflow-y: auto; padding-right: 0.25rem; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.product-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.875rem;
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
}
.product-tile:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.product-tile.out { opacity: 0.45; cursor: not-allowed; }
.product-tile .tile-name { font-size: 0.82rem; font-weight: 500; margin-bottom: 0.25rem; line-height: 1.3; }
.product-tile .tile-price { font-size: 1rem; font-weight: 700; color: var(--ink); }
.product-tile .tile-qty { font-size: 0.72rem; color: var(--ink3); margin-top: 0.2rem; }
.product-tile.low-stock .tile-qty { color: var(--warn); font-weight: 600; }

.cart-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cart-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.cart-items { flex: 1; overflow-y: auto; padding: 0.5rem; }
.cart-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius);
  transition: background 0.1s;
}
.cart-item:hover { background: var(--surface2); }
.cart-item-name { flex: 1; font-size: 0.82rem; font-weight: 500; }
.cart-item-price { font-size: 0.82rem; color: var(--ink2); min-width: 60px; text-align: right; }
.qty-ctrl { display: flex; align-items: center; gap: 0.25rem; }
.qty-btn {
  width: 24px; height: 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink2);
}
.qty-btn:hover { background: var(--surface3); }
.qty-val { font-size: 0.82rem; font-weight: 600; min-width: 20px; text-align: center; }

.cart-totals { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }
.total-row { display: flex; justify-content: space-between; font-size: 0.85rem; padding: 0.2rem 0; }
.total-row.grand { font-weight: 700; font-size: 1.05rem; padding-top: 0.5rem; border-top: 1px solid var(--border); margin-top: 0.25rem; }
.cart-actions { padding: 0.875rem 1.25rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.5rem; }

/* ── Payment modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.modal h2 { margin-bottom: 1.25rem; }
.modal-footer { display: flex; gap: 0.75rem; margin-top: 1.5rem; justify-content: flex-end; }

/* ── Numpad ── */
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; margin-top: 0.75rem; }
.numpad-btn {
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  font-size: 1.1rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.1s;
}
.numpad-btn:hover { background: var(--surface3); }
.numpad-btn.del { color: var(--danger); }
.numpad-btn.clear { color: var(--ink3); font-size: 0.8rem; }

/* ── Login page ── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 360px;
  max-width: 95vw;
}
.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo h1 { font-size: 1.4rem; margin-top: 0.5rem; }
.login-logo p { font-size: 0.82rem; color: var(--ink3); }

.pin-display {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0;
}
.pin-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all 0.1s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }

/* ── Charts (bar) ── */
.bar-chart { display: flex; flex-direction: column; gap: 0.4rem; }
.bar-row { display: flex; align-items: center; gap: 0.75rem; }
.bar-name { font-size: 0.78rem; color: var(--ink2); min-width: 130px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 8px; background: var(--surface3); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar-val { font-size: 0.78rem; color: var(--ink2); min-width: 52px; text-align: right; }

/* ── Pagination ── */
.pagination { display: flex; gap: 0.4rem; align-items: center; justify-content: center; padding: 1rem 0; }
.page-link {
  min-width: 32px; height: 32px; padding: 0 0.5rem;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--ink2);
  text-decoration: none;
  transition: all 0.1s;
}
.page-link:hover { background: var(--surface2); }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Receipt ── */
.receipt-page { max-width: 400px; margin: 2rem auto; font-family: 'Courier New', monospace; }
.receipt-header { text-align: center; margin-bottom: 1rem; }
.receipt-divider { border: none; border-top: 1px dashed var(--ink3); margin: 0.75rem 0; }
.receipt-row { display: flex; justify-content: space-between; font-size: 0.85rem; margin: 0.25rem 0; }
.receipt-total { font-weight: 700; font-size: 1rem; }
@media print {
  .no-print { display: none !important; }
  body { background: white; }
  .receipt-page { margin: 0; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .pos-grid { grid-template-columns: 1fr; height: auto; }
  .cart-panel { height: 400px; }
  .sidebar { display: none; }
}

/* ── Utility ── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 0.8rem; }
.text-muted { color: var(--ink3); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warn    { color: var(--warn); }
.fw-600 { font-weight: 600; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-gap { display: flex; gap: 0.75rem; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.hidden { display: none; }
