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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --nav-h: 60px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── NAV ── */
.nav {
  background: var(--primary);
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.nav-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  flex: 1;
}
.nav-brand span { opacity: .7; font-weight: 400; }
.nav-user {
  color: rgba(255,255,255,.85);
  font-size: .85rem;
  margin-right: 12px;
}
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: .85rem;
  transition: background .15s;
}
.nav-links a:hover, .nav-links a.active { background: rgba(255,255,255,.2); color: #fff; }

/* bottom nav for mobile */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  text-decoration: none;
  color: var(--muted);
  font-size: .65rem;
  gap: 2px;
  transition: color .15s;
}
.bottom-nav a.active, .bottom-nav a:hover { color: var(--primary); }
.bottom-nav .icon { font-size: 1.3rem; line-height: 1; }

/* ── LAYOUT ── */
.page { max-width: 900px; margin: 0 auto; padding: 20px 16px 80px; }
.page-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 16px; }

/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  margin-bottom: 16px;
}
.card-title {
  font-size: .8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.card-value { font-size: 1.8rem; font-weight: 700; }
.card-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

/* ── ALERTS ── */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: .9rem; }
.flash.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash.error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash.warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-outline  { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-sm { padding: 6px 10px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; color: var(--text); }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: #f8fafc;
  padding: 10px 12px;
  text-align: left;
  font-size: .75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }

/* ── SECTION HEADER ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-title { font-size: 1rem; font-weight: 700; }

/* ── LOGIN PAGE ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .logo-icon { font-size: 2.5rem; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; margin-top: 8px; }
.login-logo p { color: var(--muted); font-size: .85rem; }

/* ── ADD SALE BIG BUTTON ── */
.fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: var(--success);
  color: #fff;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(22,163,74,.4);
  z-index: 99;
  transition: transform .15s;
}
.fab:hover { transform: scale(1.1); }

/* ── PRODUCT ITEM ── */
.product-item {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.product-item:last-child { border-bottom: none; }
.product-name { flex: 1; font-weight: 600; }
.product-qty { font-size: .95rem; color: var(--muted); min-width: 60px; text-align: right; }
.product-price { font-size: .95rem; color: var(--primary); font-weight: 600; min-width: 80px; text-align: right; }

/* ── FILTERS ── */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: flex-end;
}
.filters .form-group { margin-bottom: 0; flex: 1; min-width: 120px; }

/* ── USER STAT ROW ── */
.user-stat {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.user-stat:last-child { border-bottom: none; }
.user-stat-name { flex: 1; font-weight: 600; }
.user-stat-count { color: var(--muted); font-size: .85rem; }
.user-stat-amount { font-weight: 700; color: var(--success); font-size: 1rem; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── TOTAL ROW ── */
.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f0fdf4;
  border-radius: 8px;
  margin-top: 8px;
}
.total-label { font-weight: 600; color: var(--muted); }
.total-value { font-size: 1.2rem; font-weight: 700; color: var(--success); }

/* ── EMPTY STATE ── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty .empty-icon { font-size: 2.5rem; margin-bottom: 8px; }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .nav-links { display: none; }
  .nav-user { display: none; }
  .bottom-nav { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .page { padding-bottom: 90px; }
  thead th:nth-child(n+4) { display: none; }
  tbody td:nth-child(n+4) { display: none; }
  .hide-mobile { display: none; }
}

@media (min-width: 601px) {
  .bottom-nav { display: none; }
  .fab { display: none; }
}
