:root {
  --blue: #155cba;
  --blue-deep: #0d3978;
  --green: #1a7a3b;
  --green-light: #e6f4ec;
  --red: #c0392b;
  --red-light: #fdf0ee;
  --yellow: #b45309;
  --yellow-light: #fef9e7;
  --silver: #eef2f7;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --bg: #f4f6fb;
  --white: #ffffff;
  --sidebar-bg: #10294f;
  --sidebar-text: #dce7f7;
  --sidebar-active: rgba(255,255,255,0.15);
  --radius: 10px;
  --shadow: 0 4px 20px rgba(16,41,79,.08);
  --shadow-md: 0 8px 32px rgba(16,41,79,.12);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ── LAYOUT ── */
.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 0 0 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
.brand {
  padding: 20px 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 10px;
}
.brand > span {
  display: block;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 1px;
  color: #fff;
}
.brand small {
  display: block;
  color: #a0b8d8;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.5;
}
.brand-full {
  color: #c8d9f0 !important;
  font-size: 9.5px !important;
  letter-spacing: .3px !important;
  line-height: 1.4 !important;
}
.brand-sub {
  color: #f0c040 !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: 1px !important;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
  flex: 1;
}
.sidebar .nav-link {
  color: var(--sidebar-text);
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}
.sidebar .nav-link i { font-size: 14px; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.09); color: #fff; }
.sidebar .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 700;
}
.sidebar .nav-link.active i { color: #60c8ff; }
.notif-badge {
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
  height: 16px;
}

/* ── MAIN AREA ── */
.main { min-width: 0; display: flex; flex-direction: column; }

/* ── TOPBAR ── */
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.topbar h1 {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  color: var(--ink);
}
.topbar-sub { color: var(--muted); margin: 2px 0 0; font-size: 12.5px; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.badge-pulse {
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 20px;
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  text-align: center;
}
.content { padding: 22px 24px; flex: 1; }

/* ── PANELS ── */
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.panel-title {
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 16px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-title i { color: var(--blue); }

/* ── KPI GRID ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .15s, box-shadow .15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-icon { font-size: 20px; margin-bottom: 4px; }
.kpi span { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi strong { font-size: 22px; font-weight: 800; line-height: 1; }
.kpi.kpi-success strong { color: var(--green); }
.kpi.kpi-danger strong { color: var(--red); }
.kpi.kpi-warning strong { color: var(--yellow); }
.kpi.kpi-info strong { color: var(--blue); }
.kpi-trend { font-size: 11px; color: var(--muted); }
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }

/* ── BUTTONS ── */
.btn-primary { background: var(--blue); border-color: var(--blue); font-weight: 600; }
.btn-primary:hover { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn-success { background: var(--green); border-color: var(--green); font-weight: 600; }
.btn-success:hover { filter: brightness(.9); }
.btn-lg { padding: .6rem 1.4rem; font-size: 15px; }

/* ── FORMS ── */
.form-label { font-weight: 650; font-size: 13px; color: #344054; margin-bottom: 4px; }
.form-control, .form-select {
  border-radius: 7px;
  border-color: var(--line);
  font-size: 13.5px;
  padding: .45rem .75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21,92,186,.12);
}
.input-group-text { background: var(--silver); border-color: var(--line); font-weight: 700; }

/* ── TABLES ── */
.table { font-size: 13px; }
.table th { font-weight: 700; color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .4px; border-bottom: 2px solid var(--line); }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8faff; }

/* ── STATUS BADGES ── */
.badge-available { background: var(--green-light); color: var(--green); border: 1px solid #b7dfc4; }
.badge-low { background: var(--yellow-light); color: var(--yellow); border: 1px solid #f5dfa0; }
.badge-out { background: var(--red-light); color: var(--red); border: 1px solid #f5bfbb; }
.badge-paid { background: var(--green-light); color: var(--green); }
.badge-partial { background: var(--yellow-light); color: var(--yellow); }
.badge-void { background: #f3f4f6; color: #6b7280; }
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ── AUTH PAGES ── */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #10294f 0%, #1a4a8a 40%, #f5f8fd 100%);
  padding: 20px;
}
.auth-panel {
  width: min(440px, 100%);
  background: var(--white);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 24px 60px rgba(16,41,79,.22);
}
.auth-logo {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  font-size: 22px;
  border-radius: 12px;
  margin-bottom: 20px;
  letter-spacing: 1px;
}
.auth-panel h1 { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.auth-panel .company-name { font-size: 12px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.auth-panel p { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }

/* ── POS / SALES ── */
.pos-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px 2px;
}
.product-btn {
  background: var(--white);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
  position: relative;
}
.product-btn:hover { border-color: var(--blue); background: #f0f5ff; transform: translateY(-1px); }
.product-btn.out-of-stock { opacity: .5; cursor: not-allowed; }
.product-btn .prod-name { font-weight: 700; font-size: 12.5px; display: block; margin-bottom: 4px; line-height: 1.3; }
.product-btn .prod-price { color: var(--green); font-weight: 800; font-size: 14px; }
.product-btn .prod-stock { font-size: 10px; color: var(--muted); margin-top: 2px; }
.product-btn .stock-dot {
  width: 7px; height: 7px; border-radius: 50%;
  display: inline-block; margin-right: 2px;
}
.stock-dot.green { background: #2ecc71; }
.stock-dot.orange { background: #f39c12; }
.stock-dot.red { background: #e74c3c; }

.cart-panel { display: flex; flex-direction: column; gap: 0; }
.cart-items { flex: 1; max-height: 340px; overflow-y: auto; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.cart-item-name { font-weight: 600; font-size: 12.5px; }
.cart-item-price { color: var(--green); font-weight: 700; font-size: 13px; white-space: nowrap; }
.cart-qty-input {
  width: 52px !important;
  text-align: center;
  padding: 3px 6px !important;
  font-size: 13px !important;
  font-weight: 700;
}
.cart-empty { text-align: center; padding: 28px 0; color: var(--muted); }
.cart-empty i { font-size: 36px; margin-bottom: 10px; display: block; }
.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 5px 0;
}
.cart-total-row.grand {
  font-size: 18px;
  font-weight: 900;
  color: var(--blue);
  border-top: 2px solid var(--line);
  margin-top: 4px;
  padding-top: 10px;
}
.cart-total-row.profit { color: var(--green); font-weight: 700; }

.search-products { position: relative; }
.search-products input { padding-right: 36px; }
.search-products .clear-search {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  cursor: pointer; color: var(--muted);
}

/* ── INVOICE / RECEIPT ── */
.receipt-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 0;
}
.receipt {
  background: #fff;
  width: 320px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12.5px;
  padding: 20px 18px;
  border: 1px dashed #bbb;
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
}
.receipt-header { text-align: center; margin-bottom: 14px; }
.receipt-company { font-size: 14px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; line-height: 1.3; }
.receipt-sub { font-size: 10.5px; color: #555; margin-top: 2px; }
.receipt-divider { border: none; border-top: 1px dashed #aaa; margin: 10px 0; }
.receipt-meta { font-size: 11.5px; margin-bottom: 10px; }
.receipt-meta td:first-child { color: #555; width: 90px; }
.receipt-meta td:last-child { font-weight: 600; }
.receipt-items th, .receipt-items td { padding: 3px 0; font-size: 12px; vertical-align: top; }
.receipt-items th { border-bottom: 1px dashed #aaa; font-weight: 700; }
.receipt-items .item-total { text-align: right; font-weight: 700; }
.receipt-totals { margin-top: 10px; }
.receipt-totals td { padding: 2px 0; font-size: 12.5px; }
.receipt-totals td:last-child { text-align: right; font-weight: 700; }
.receipt-grand { font-size: 15px; font-weight: 900; border-top: 2px solid #333; padding-top: 5px !important; }
.receipt-footer { text-align: center; font-size: 11px; color: #555; margin-top: 14px; line-height: 1.6; }
.receipt-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }

/* ── DAILY SUMMARY BAR ── */
.daily-summary {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  box-shadow: var(--shadow);
}
.daily-summary-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}
.daily-item {
  display: flex;
  flex-direction: column;
  padding: 6px 20px 6px 0;
  margin-right: 20px;
  border-right: 1px solid var(--line);
  min-width: 110px;
}
.daily-item:last-child { border-right: none; }
.daily-item span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.daily-item strong { font-size: 16px; font-weight: 800; color: var(--ink); }
.daily-item.kpi-success strong { color: var(--green); }

/* ── PRODUCT SEARCH ── */
.search-products { position: relative; }
.search-products .form-control { padding-right: 34px; }
.clear-search {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}
.clear-search:hover { color: var(--red); }

/* ── PRODUCT EDIT MODE ── */
.panel-editing {
  border: 2px solid #f0c040 !important;
}

/* ── SETTINGS ── */
.settings-panel { max-width: 680px; }

/* ── LOW STOCK ALERT ── */
.low-stock-alert {
  background: var(--yellow-light);
  border: 1px solid #f5dfa0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.low-stock-alert i { color: var(--yellow); margin-top: 2px; }

/* ── RECENT SALES TABLE IN DASHBOARD ── */
.recent-sales-table { font-size: 13px; }
.amount-cell { font-weight: 700; color: var(--green); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar .nav-link { padding: 7px 10px; font-size: 12px; }
  .topbar { flex-direction: column; align-items: flex-start; padding: 14px 16px; }
  .content { padding: 14px 16px; }
  .pos-wrap { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* ── PRINT ── */
@media print {
  .sidebar, .topbar, .no-print, .btn, .receipt-actions, nav,
  .alert, .top-actions, .panel-title .btn { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  .panel { border: 0; box-shadow: none; padding: 0; }
  .receipt-wrap { padding: 0; }
  .receipt {
    border: none;
    box-shadow: none;
    width: 100%;
    max-width: 320px;
  }
  body { background: #fff; }
}
