:root {
  --navy: #2d3e6e;
  --navy-dark: #1e2d54;
  --navy-light: #3d5080;
  --gold: #c9a227;
  --gold-light: #e8c347;
  --gold-pale: #f5e9be;
  --white: #ffffff;
  --gray-50: #f8f9fc;
  --gray-100: #f0f2f8;
  --gray-200: #e2e6f0;
  --gray-400: #9aa5c4;
  --gray-600: #5a6580;
  --gray-800: #2c3347;
  --green: #2ecc71;
  --red: #e74c3c;
  --orange: #f39c12;
  --blue: #3498db;
  --sidebar-w: 260px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Barlow', sans-serif; background: var(--gray-100); color: var(--gray-800); display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w); background: var(--navy-dark); color: #fff;
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 100; transition: transform .3s;
  box-shadow: 4px 0 20px rgba(0,0,0,.3);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px; padding: 20px 18px;
  border-bottom: 1px solid rgba(201,162,39,.3);
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%);
}
.brand-logo { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--gold); object-fit: cover; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-family: 'Barlow Condensed', sans-serif; font-size: 1.1rem; font-weight: 700; color: var(--gold-light); letter-spacing: 1px; }
.brand-sub { font-size: .7rem; color: var(--gray-400); letter-spacing: .5px; text-transform: uppercase; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section-label { font-size: .65rem; color: var(--gray-400); letter-spacing: 1.5px; font-weight: 600; padding: 14px 20px 6px; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 20px;
  color: rgba(255,255,255,.7); text-decoration: none; font-size: .88rem; font-weight: 500;
  transition: all .2s; border-left: 3px solid transparent; margin: 1px 0;
}
.nav-item i { width: 20px; text-align: center; font-size: .9rem; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--gold); }
.nav-item.active { background: rgba(201,162,39,.15); color: var(--gold-light); border-left-color: var(--gold); }

.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: 10px;
}
.user-info { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.user-avatar {
  width: 46px; height: 46px; border-radius: 50%; overflow: hidden;
  background: rgba(255,255,255,.08); display: grid; place-items: center;
  flex: 0 0 46px;
  min-width: 46px; min-height: 46px; max-width: 46px; max-height: 46px;
  color: var(--gold); font-size: 1.7rem;
  border: 2px solid var(--gold);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.user-avatar i {
  color: var(--gold);
  font-size: 1.5rem;
  line-height: 1;
}
.user-details { flex: 1; }
.user-name { display: block; font-size: .85rem; font-weight: 600; color: #fff; }
.user-role { font-size: .72rem; color: var(--gray-400); text-transform: capitalize; }
.logout-btn { color: rgba(255,255,255,.5); font-size: 1.1rem; padding: 6px; transition: color .2s; }
.logout-btn:hover { color: var(--red); }
.profile-image-preview {
  width: 96px; height: 96px; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--gold); margin-bottom: 16px;
  flex: 0 0 96px;
  min-width: 96px; min-height: 96px; max-width: 96px; max-height: 96px;
}
.profile-image-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* MAIN WRAPPER */
.main-wrapper { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* TOPBAR */
.topbar {
  background: #fff; height: 60px; display: flex; align-items: center;
  padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 12px rgba(0,0,0,.08); border-bottom: 2px solid var(--gold);
}
.sidebar-toggle { background: none; border: none; font-size: 1.2rem; color: var(--navy); cursor: pointer; display: none; }
.topbar-title { font-family: 'Barlow Condensed', sans-serif; font-size: 1.3rem; font-weight: 700; color: var(--navy); letter-spacing: .5px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.date-display { font-size: .82rem; color: var(--gray-600); display: flex; align-items: center; gap: 6px; }

/* Notification bell (admin / staff / manager / customer) */
.topbar-notif-wrap { position: relative; flex-shrink: 0; }
.topbar-notif-btn {
  position: relative; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--gray-200);
  background: var(--gray-50); color: var(--navy); cursor: pointer; display: grid; place-items: center;
  transition: background 0.2s, border-color 0.2s;
}
.topbar-notif-btn:hover { background: #fff; border-color: var(--gold); }
.topbar-notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: #e74c3c; color: #fff; font-size: 0.65rem; font-weight: 700; line-height: 18px; text-align: center;
}
.topbar-notif-badge--hidden { display: none !important; }
.topbar-notif-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(100vw - 24px, 380px); max-height: min(70vh, 440px);
  overflow: auto; background: #fff; border: 1px solid var(--gray-200); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16); z-index: 200;
}
.topbar-notif-panel-head {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--gray-200);
  font-weight: 700; color: var(--navy); font-size: 0.92rem;
}
.topbar-notif-close { border: none; background: transparent; font-size: 1.35rem; line-height: 1; cursor: pointer; color: var(--gray-600); padding: 0 4px; }
.topbar-notif-close:hover { color: var(--navy); }
.topbar-notif-loading { padding: 14px 12px; font-size: 0.85rem; color: var(--gray-600); }
.topbar-notif-list { list-style: none; margin: 0; padding: 0; }
.topbar-notif-item { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); font-size: 0.82rem; color: var(--gray-800); }
.topbar-notif-item-title { font-weight: 600; color: var(--navy); text-transform: capitalize; margin-bottom: 4px; }
.topbar-notif-item time { display: block; font-size: 0.72rem; color: var(--gray-600); margin-top: 4px; }
.topbar-notif-footer { padding: 10px 12px; border-top: 1px solid var(--gray-200); }
.topbar-notif-footer a { font-size: 0.82rem; font-weight: 600; color: var(--navy); text-decoration: underline; }

/* CONTENT AREA */
.content-area { padding: 28px 30px; flex: 1; }

/* PAGE HEADER */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.7rem; color: var(--navy); font-weight: 700; }
.page-header p { color: var(--gray-600); font-size: .88rem; margin-top: 3px; }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 248px), 1fr)); gap: 20px; margin-bottom: 28px; }
.stats-grid--financial { gap: 16px; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 18px 18px;
  display: flex; align-items: flex-start; gap: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06); transition: transform .2s;
  border-left: 4px solid var(--gold);
  container-type: inline-size;
  container-name: statcard;
  min-width: 0;
  overflow: visible;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-info { min-width: 0; flex: 1; overflow: visible; }
.stat-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon.blue { background: rgba(52,152,219,.1); color: var(--blue); }
.stat-icon.green { background: rgba(46,204,113,.1); color: var(--green); }
.stat-icon.orange { background: rgba(243,156,18,.1); color: var(--orange); }
.stat-icon.red { background: rgba(231,76,60,.1); color: var(--red); }
.stat-icon.navy { background: rgba(45,62,110,.1); color: var(--navy); }
.stat-info h3 {
  font-size: clamp(0.92rem, 0.88rem + 1.1vw, 1.65rem);
  font-weight: 700;
  color: var(--navy);
  line-height: 1.4;
  min-width: 0;
  margin: 0;
}
@supports (font-size: 1cqi) {
  .stat-info h3 {
    font-size: clamp(0.92rem, 3.2cqi + 0.55rem, 1.65rem);
  }
}
.stat-info p { font-size: .8rem; color: var(--gray-600); margin-top: 4px; font-weight: 500; }

/* Currency: one line, scales down inside narrow stat cards (no clipped ₱ / digits) */
.currency-text {
  display: inline;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: inherit;
  font-weight: inherit;
  font-size: inherit;
  color: inherit;
}

/* CARDS */
.card { background: #fff; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,.06); margin-bottom: 24px; overflow: hidden; }
.card-header { padding: 16px 22px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; }
.card-header h2 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.15rem; font-weight: 700; color: var(--navy); }
.card-body { padding: 20px 22px; }

/* TABLES */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th { background: var(--navy); color: #fff; padding: 11px 14px; text-align: left; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
thead th:first-child { border-radius: 0; }
tbody tr { border-bottom: 1px solid var(--gray-200); transition: background .15s; }
tbody tr:hover { background: var(--gray-50); }
tbody td { padding: 11px 14px; vertical-align: middle; color: var(--gray-800); }

/* BADGES */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .73rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.badge-success { background: rgba(46,204,113,.12); color: #27ae60; }
.badge-danger { background: rgba(231,76,60,.12); color: #c0392b; }
.badge-warning { background: rgba(243,156,18,.12); color: #d68910; }
.badge-info { background: rgba(52,152,219,.12); color: #2980b9; }
.badge-secondary { background: rgba(90,101,128,.12); color: var(--gray-600); }
.badge-navy { background: rgba(45,62,110,.12); color: var(--navy); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: 8px; border: none; font-family: 'Barlow', sans-serif; font-size: .85rem; font-weight: 600; cursor: pointer; text-decoration: none; transition: all .2s; white-space: nowrap; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-light); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-light); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #27ae60; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-400); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn-outline { background: transparent; border: 1.5px solid; }
.btn-outline-navy { border-color: var(--navy); color: var(--navy); }
.btn-outline-navy:hover { background: var(--navy); color: #fff; }

/* FORMS */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .83rem; font-weight: 600; color: var(--gray-800); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-family: 'Barlow', sans-serif; font-size: .88rem;
  color: var(--gray-800); background: #fff; transition: border-color .2s;
  outline: none;
}
.form-control:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(45,62,110,.1); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; justify-content: flex-end; }

/* MODAL — overrides Bootstrap .modal (loaded for toasts) so app dialogs stay visible */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,.5); z-index: 1055; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex !important; }
.modal-overlay .modal {
  display: none;
  position: relative !important;
  top: auto !important;
  left: auto !important;
  width: 90% !important;
  height: auto !important;
  max-height: 90vh;
  overflow-y: auto;
  transform: none !important;
  opacity: 1 !important;
  pointer-events: auto;
  background: #fff;
  border-radius: 14px;
  max-width: 600px;
  animation: slideIn .25s ease;
  box-shadow: 0 12px 40px rgba(0,0,0,.22);
}
.modal-overlay.open .modal {
  display: block !important;
}
.modal-lg { max-width: 800px; }
@keyframes slideIn { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; background: linear-gradient(135deg, var(--navy-dark), var(--navy)); color: #fff; border-radius: 14px 14px 0 0; }
.modal-header h3 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.2rem; font-weight: 700; }
.modal-close { background: none; border: none; color: rgba(255,255,255,.7); font-size: 1.3rem; cursor: pointer; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }

/* ALERTS */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: .88rem; display: flex; align-items: center; gap: 10px; }
.alert-success { background: rgba(46,204,113,.12); color: #27ae60; border: 1px solid rgba(46,204,113,.3); }
.alert-danger { background: rgba(231,76,60,.12); color: #c0392b; border: 1px solid rgba(231,76,60,.3); }
.alert-warning { background: rgba(243,156,18,.12); color: #d68910; border: 1px solid rgba(243,156,18,.3); }
.alert-info { background: rgba(52,152,219,.12); color: #2980b9; border: 1px solid rgba(52,152,219,.3); }

/* SEARCH BAR */
.search-bar { display: flex; gap: 10px; align-items: center; }
.search-input { padding: 9px 14px; border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: .85rem; font-family: 'Barlow', sans-serif; outline: none; min-width: 220px; }
.search-input:focus { border-color: var(--navy); }

/* LOW STOCK */
.low-stock { color: var(--red) !important; font-weight: 600; }
.out-stock { color: #999 !important; font-weight: 600; }

/* PROGRESS */
.progress { height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width .5s; }
.progress-bar.green { background: var(--green); }
.progress-bar.orange { background: var(--orange); }
.progress-bar.red { background: var(--red); }

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .content-area { padding: 18px 16px; }
}

@media (max-width: 1024px) {
  .content-area { padding: 22px 18px; }
  .topbar { padding: 0 16px; }
  .search-bar { flex-wrap: wrap; }
  .search-input { min-width: 170px; width: 100%; }
}

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .btn { width: 100%; justify-content: center; }
  .modal { width: calc(100% - 20px); max-height: calc(100vh - 20px); }
  .card-body, .modal-body { padding: 16px; }
  tbody td, thead th { padding: 9px 8px; }
}

/* LOGIN */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy-light) 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { width: 90px; height: 90px; border-radius: 50%; border: 3px solid var(--gold); }
.login-logo h2 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.4rem; color: var(--navy); margin-top: 12px; font-weight: 700; }
.login-logo p { color: var(--gray-600); font-size: .82rem; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 50px 20px; color: var(--gray-400); }
.empty-state i { font-size: 3rem; margin-bottom: 12px; display: block; }
.empty-state p { font-size: .9rem; }

/* ITEM CODE */
.item-code { font-family: monospace; background: var(--gray-100); padding: 2px 8px; border-radius: 4px; font-size: .8rem; color: var(--navy); }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 3px; }
