/* ============================================================
   GMS SaaS – Design System
   Font: Syne (headings) + DM Sans (body)
   Theme: Dark navy sidebar, clean white workspace
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── Variables ── */
:root {
  --navy:       #0d1b2a;
  --navy-mid:   #1a2d42;
  --navy-light: #243b55;
  --accent:     #f97316;
  --accent-dim: #c2580d;
  --accent-glow:#fff0e6;
  --blue:       #3b82f6;
  --blue-soft:  #dbeafe;
  --green:      #22c55e;
  --green-soft: #dcfce7;
  --red:        #ef4444;
  --red-soft:   #fee2e2;
  --amber:      #f59e0b;
  --amber-soft: #fef3c7;
  --purple:     #8b5cf6;
  --purple-soft:#ede9fe;

  --bg:         #f4f6f9;
  --surface:    #ffffff;
  --surface2:   #f8fafc;
  --border:     #e2e8f0;
  --border2:    #cbd5e1;

  --text:       #0f172a;
  --text-2:     #475569;
  --text-3:     #94a3b8;
  --text-inv:   #ffffff;

  --sidebar-w:  260px;
  --topbar-h:   64px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.14);

  --font-head:  'Syne', sans-serif;
  --font-body:  'DM Sans', sans-serif;

  --transition: 180ms ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); color: var(--text); background: var(--bg); line-height: 1.6; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 0 20px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sidebar-brand .brand-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon svg { width: 18px; height: 18px; color: #fff; }

.sidebar-brand .brand-text { display: flex; flex-direction: column; }
.sidebar-brand .brand-name { font-family: var(--font-head); font-weight: 700; font-size: .95rem; color: #fff; line-height: 1.2; }
.sidebar-brand .brand-shop { font-size: .72rem; color: rgba(255,255,255,.45); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.1) transparent; }

.nav-section { margin-bottom: 6px; }
.nav-section-label { font-size: .65rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.3); padding: 8px 10px 4px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.6);
  font-size: .875rem;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }

.nav-item.active {
  background: rgba(249,115,22,.18);
  color: #fff;
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--accent);
}

.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .nav-badge { margin-left: auto; background: var(--red); color: #fff; font-size: .65rem; font-weight: 600; padding: 1px 6px; border-radius: 20px; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: rgba(255,255,255,.07); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: .82rem; font-weight: 500; color: rgba(255,255,255,.9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: .7rem; color: rgba(255,255,255,.4); }

/* ── Main ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
  gap: 16px;
}

.topbar-title { font-family: var(--font-head); font-weight: 700; font-size: 1.1rem; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.topbar-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: .83rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #2563eb; }

.btn-icon { padding: 7px; }
.btn-icon svg { width: 16px; height: 16px; }

/* ── Page body ── */
.page-body { padding: 24px 28px; flex: 1; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.page-header-left h1 { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; }
.page-header-left p  { color: var(--text-2); font-size: .85rem; margin-top: 2px; }

/* ── Stat Cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.orange { background: var(--accent-glow); color: var(--accent); }
.stat-icon.blue   { background: var(--blue-soft);   color: var(--blue); }
.stat-icon.green  { background: var(--green-soft);  color: var(--green); }
.stat-icon.red    { background: var(--red-soft);    color: var(--red); }
.stat-icon.purple { background: var(--purple-soft); color: var(--purple); }
.stat-icon.amber  { background: var(--amber-soft);  color: var(--amber); }

.stat-label { font-size: .75rem; color: var(--text-2); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-family: var(--font-head); font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat-sub   { font-size: .75rem; color: var(--text-3); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-title { font-family: var(--font-head); font-weight: 600; font-size: .95rem; }
.card-body  { padding: 20px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

.td-mono { font-family: monospace; font-size: .82rem; }
.td-muted { color: var(--text-2); }
.td-right { text-align: right; }
.td-bold  { font-weight: 600; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: var(--green-soft);  color: #15803d; }
.badge-red    { background: var(--red-soft);    color: #dc2626; }
.badge-amber  { background: var(--amber-soft);  color: #d97706; }
.badge-blue   { background: var(--blue-soft);   color: #1d4ed8; }
.badge-purple { background: var(--purple-soft); color: #7c3aed; }
.badge-gray   { background: #f1f5f9; color: var(--text-2); }
.badge-orange { background: var(--accent-glow); color: var(--accent-dim); }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-full  { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: .8rem; font-weight: 500; color: var(--text-2); }
.form-label.required::after { content: ' *'; color: var(--red); }

.form-control {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}

.form-control::placeholder { color: var(--text-3); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: .75rem; color: var(--text-3); }

.form-section-title {
  font-family: var(--font-head);
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  grid-column: 1 / -1;
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.alert svg { width: 16px; height: 16px; flex-shrink: 0; }
.alert-success { background: var(--green-soft);  color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-soft);    color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--amber-soft);  color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--blue-soft);   color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Dashboard charts placeholder ── */
.chart-container { position: relative; height: 200px; }

/* ── Pagination ── */
.pagination { display: flex; gap: 4px; align-items: center; padding: 16px 0 0; }
.page-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover  { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Search bar ── */
.search-bar { position: relative; }
.search-bar input { padding-left: 36px; }
.search-bar .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; pointer-events: none; }

/* ── Stock level indicator ── */
.stock-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.stock-ok       { background: var(--green-soft);  color: #15803d; }
.stock-low      { background: var(--amber-soft);  color: #b45309; }
.stock-critical { background: var(--red-soft);    color: #dc2626; }
.stock-out      { background: #f1f5f9; color: var(--text-3); }

/* ── Invoice builder ── */
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table th { background: var(--navy); color: rgba(255,255,255,.8); padding: 10px 12px; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.inv-table th:first-child { border-radius: 8px 0 0 0; }
.inv-table th:last-child  { border-radius: 0 8px 0 0; }
.inv-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.inv-table tr:last-child td { border-bottom: none; }
.inv-table tr:hover td { background: var(--surface2); }
.inv-table td input { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: .83rem; width: 100%; }
.inv-table td input:focus { outline: none; border-color: var(--accent); }

.inv-totals { background: var(--surface2); border-radius: var(--radius); padding: 16px 20px; border: 1px solid var(--border); }
.inv-total-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: .9rem; }
.inv-total-row.grand { padding-top: 10px; margin-top: 4px; border-top: 2px solid var(--border2); font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease;
}

@keyframes modalIn { from { opacity: 0; transform: translateY(-16px) scale(.97); } }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-3); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Low stock banner ── */
.low-stock-list { display: flex; flex-direction: column; gap: 8px; }
.low-stock-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius); background: var(--amber-soft); border: 1px solid #fde68a; }
.low-stock-item .ls-name { flex: 1; font-size: .85rem; font-weight: 500; color: #92400e; }
.low-stock-item .ls-qty  { font-size: .8rem; font-weight: 700; color: #b45309; }

/* ── Dropdown ── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  z-index: 150;
  overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: .85rem; color: var(--text); cursor: pointer; transition: background var(--transition); }
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--red); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Print ── */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 0 !important; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ── Utility ── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: .83rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--text-2); }
.font-bold { font-weight: 700; }
.font-head { font-family: var(--font-head); }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
