:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-alt: #f8faf9;
  --border: #dce4df;
  --text: #16241d;
  --muted: #5c6f65;
  --primary: #0f766e;
  --primary-dark: #0b5a54;
  --primary-soft: #e6f4f1;
  --accent: #b45309;
  --accent-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --success: #15803d;
  --success-soft: #dcfce7;
  --sidebar-bg: #0f241d;
  --sidebar-text: #d7e5de;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(15, 36, 29, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.text-right { text-align: right; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-md { display: flex; flex-direction: column; gap: 14px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-gap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f241d 0%, #134e4a 100%);
}
.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-card h1 { margin: 10px 0 4px; font-size: 1.5rem; }
.brand-badge {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--primary); color: #fff; font-weight: 700;
  display: grid; place-items: center; font-size: 1.05rem;
}
.brand-badge.sm { width: 36px; height: 36px; font-size: 0.9rem; }

.demo-box { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.demo-title { font-size: 0.78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; }
.demo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.demo-pill {
  border: 1px solid var(--border); background: var(--surface-alt); border-radius: 8px;
  padding: 8px 6px; cursor: pointer; text-align: left; font-size: 0.74rem;
  display: flex; flex-direction: column; gap: 2px;
}
.demo-pill:hover { border-color: var(--primary); background: var(--primary-soft); }

/* App Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-name { font-weight: 700; color: #fff; font-size: 1rem; }
.brand-sub { font-size: 0.74rem; color: #9ab3a7; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.nav-section { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: #839d90; padding: 10px 10px 4px; }
.nav-item {
  width: 100%; border: none; background: transparent; color: var(--sidebar-text);
  text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 0.9rem; display: flex; align-items: center; justify-content: space-between;
}
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-badge { margin-bottom: 8px; font-size: 0.82rem; }
.user-badge strong { display: block; color: #fff; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar h2 { margin: 0; font-size: 1.2rem; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-content { padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; }

/* Cards & Grids */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.kpi-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-value { font-size: 1.45rem; font-weight: 700; margin-top: 6px; color: var(--text); }
.kpi-sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card-title { margin: 0 0 12px; font-size: 1.02rem; font-weight: 650; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 0.9rem; font-family: inherit; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25); border-color: var(--primary);
}

/* Buttons & Pills */
.btn {
  border: 1px solid transparent; border-radius: 7px; padding: 8px 14px;
  font-size: 0.88rem; font-weight: 600; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface-alt); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: #e8efeb; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: inherit; }
.btn-ghost:hover { background: rgba(0,0,0,0.06); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-block { width: 100%; }

.pill {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600;
}
.pill-emerald { background: var(--primary-soft); color: var(--primary-dark); }
.pill-slate { background: #e2e8f0; color: #334155; }
.pill-green { background: var(--success-soft); color: var(--success); }
.pill-amber { background: var(--accent-soft); color: var(--accent); }
.pill-red { background: var(--danger-soft); color: var(--danger); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: var(--surface-alt); }
tr:hover td { background: #fafcfb; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 0.86rem; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--primary-soft); color: var(--primary-dark); }

/* Modal & Toast */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 36, 29, 0.55);
  display: grid; place-items: center; padding: 16px; z-index: 100;
}
.modal-dialog {
  width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 18px; }

.toast-container { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #16241d; color: #fff; padding: 10px 14px; border-radius: 8px;
  font-size: 0.86rem; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.toast.error { background: var(--danger); }

.mobile-only { display: none; }
@media (max-width: 860px) {
  .mobile-only { display: inline-flex; }
  .sidebar { position: fixed; left: -270px; top: 0; bottom: 0; z-index: 90; transition: left 0.2s; }
  .sidebar.open { left: 0; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .modal-backdrop { position: static; background: #fff; }
  .modal-dialog { box-shadow: none; max-height: none; }
}
