/* ===================== VARIABLES ===================== */
:root {
  --white: #ffffff;
  --bg: #f7f8fc;
  --bg2: #eef0f7;
  --border: #e2e5ef;
  --text: #1a1c2e;
  --text2: #5a5e78;
  --text3: #9599b0;
  --accent: #2d3a8c;
  --accent2: #4a5bbf;
  --accent-light: #eef0fb;
  --gold: #c9a84c;
  --gold-light: #fdf6e3;
  --red: #e05252;
  --red-light: #fdf0f0;
  --green: #3aaa6e;
  --green-light: #edfaf4;
  --orange: #f07a3a;
  --orange-light: #fff4ee;
  --shadow: 0 2px 12px rgba(45,58,140,0.08);
  --shadow-md: 0 4px 24px rgba(45,58,140,0.12);
  --radius: 12px;
  --sidebar: 240px;
  --topbar: 56px;
}

/* ===================== RESET ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
h1,h2,h3,h4 { font-family: 'Playfair Display', serif; }
a { text-decoration: none; color: inherit; }
input, select, textarea {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.2s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent2); }
textarea { resize: vertical; }
button { cursor: pointer; font-family: 'DM Sans', sans-serif; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar);
  height: 100vh;
  background: var(--text);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 24px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo-icon {
  font-size: 1.5rem;
  background: var(--gold);
  color: var(--white);
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  color: var(--white);
  letter-spacing: 0.3px;
}
.sidebar-nav {
  flex: 1;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,0.55);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); }
.nav-item.active { background: var(--accent); color: var(--white); }
.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-footer {
  padding: 16px 24px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.3);
  border-top: 1px solid rgba(255,255,255,0.06);
  letter-spacing: 0.5px;
}
.sidebar-footer::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 8px; }

/* ===================== TOPBAR (mobile) ===================== */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 99;
}
.topbar-title { font-family: 'Playfair Display', serif; font-size: 1.1rem; }
.menu-btn { background: none; border: none; font-size: 1.4rem; color: var(--text); padding: 4px 8px; }

/* ===================== MAIN CONTENT ===================== */
.main-content {
  margin-left: var(--sidebar);
  padding: 32px;
  min-height: 100vh;
}

/* ===================== PAGE ===================== */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 1.8rem; color: var(--text); }
.subtitle { font-size: 0.9rem; color: var(--text3); margin-top: 2px; }

/* ===================== BUTTONS ===================== */
.btn-primary {
  background: var(--accent);
  color: var(--white);
  border: none;
  padding: 10px 22px;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg2);
  color: var(--text2);
  border: 1.5px solid var(--border);
  padding: 10px 22px;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 500;
}
.btn-icon {
  background: none;
  border: none;
  font-size: 1rem;
  padding: 5px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--bg2); }

/* ===================== CARDS & STATS ===================== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-title { font-size: 1rem; color: var(--text2); margin-bottom: 16px; font-family: 'DM Sans', sans-serif; font-weight: 600; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-info { flex: 1; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.82rem; color: var(--text3); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }

/* ===================== TABLE ===================== */
.table-wrap { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.data-table thead tr { border-bottom: 2px solid var(--border); }
.data-table th { padding: 13px 16px; text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.6px; white-space: nowrap; }
.data-table td { padding: 13px 16px; font-size: 0.92rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table .empty { text-align: center; color: var(--text3); padding: 32px; }

/* ===================== BADGES ===================== */
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-pending    { background: var(--orange-light); color: var(--orange); }
.badge-in-progress{ background: var(--accent-light); color: var(--accent); }
.badge-ready      { background: var(--gold-light); color: var(--gold); }
.badge-delivered  { background: var(--green-light); color: var(--green); }
.badge-paid       { background: var(--green-light); color: var(--green); }
.badge-partial    { background: var(--orange-light); color: var(--orange); }
.badge-low        { background: var(--red-light); color: var(--red); }
.badge-ok         { background: var(--green-light); color: var(--green); }

/* ===================== SEARCH & FILTERS ===================== */
.search-bar { margin-bottom: 16px; }
.search-bar input { max-width: 380px; }
.filter-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-btn {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text2);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}
.filter-btn:hover { border-color: var(--accent2); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: var(--white); border-color: var(--accent); }

/* ===================== MODAL ===================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,28,46,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: modalIn 0.22s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(0.95); } to { opacity:1; transform: scale(1); } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.2rem; }
.modal-close { background: none; border: none; font-size: 1.1rem; color: var(--text3); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--bg2); }
.modal-body { padding: 22px 26px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 16px 26px 22px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--text2); }
.section-label { font-family: 'DM Sans', sans-serif; font-size: 0.82rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; padding-top: 4px; }

/* ===================== CUSTOMER VIEW ===================== */
.meas-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 10px; }
.meas-item { background: var(--bg); border-radius: 8px; padding: 12px; text-align: center; }
.meas-val { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.meas-lbl { font-size: 0.75rem; color: var(--text3); margin-top: 2px; }
.info-row { display: flex; gap: 8px; font-size: 0.9rem; margin-bottom: 6px; }
.info-row strong { color: var(--text2); min-width: 80px; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: var(--text);
  color: var(--white);
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.3s;
  z-index: 500;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===================== ALERT ITEMS ===================== */
.alert-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.alert-item:last-child { border-bottom: none; }
.recent-order-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.recent-order-item:last-child { border-bottom: none; }
.recent-order-top { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; font-weight: 500; }
.recent-order-sub { font-size: 0.8rem; color: var(--text3); margin-top: 3px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .topbar { display: flex; }
  .sidebar { transform: translateX(-100%); top: 0; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px 16px; padding-top: calc(var(--topbar) + 20px); }
  .form-row { grid-template-columns: 1fr; }
  .meas-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }
