:root {
  --sidebar-w: 260px;
  --primary: #0e7a5f;
  --primary-dark: #0a5c48;
  --primary-light: #e6f4f0;
  --danger: #e74c3c;
  --bg: #f4f7f9;
  --card-border: #e3e8ec;
  --text: #1f2d3d;
  --muted: #6b7a8d;
  --sidebar-bg: #0d2137;
  --sidebar-text: #b7c4d3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0d2137 0%, #12314d 100%);
  color: var(--sidebar-text);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s ease;
}

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

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.content { padding: 24px; flex: 1; }

/* ---------- Sidebar ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
  width: 42px; height: 42px;
  background: var(--primary);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px;
}
.brand h1 { font-size: 16px; margin: 0; color: #fff; }
.brand small { color: #7e93a8; font-size: 11px; }

.nav-group { padding: 14px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #5d7187; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin: 2px 8px;
  border-radius: 9px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  transition: all .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(14,122,95,.35); }
.nav-link .icon { width: 20px; text-align: center; font-size: 16px; }
.badge-float { margin-left: auto; }

.sidebar-footer {
  padding: 16px;
  font-size: 11px;
  color: #5d7187;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ---------- Topbar ---------- */
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar .date { color: var(--muted); font-size: 12.5px; margin-left: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--primary-light);
  padding: 6px 12px 6px 6px;
  border-radius: 30px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.user-chip .name { font-weight: 600; font-size: 13px; line-height: 1.1; }
.user-chip .role { font-size: 11px; color: var(--muted); }

.hamburger {
  display: none;
  border: none; background: none; font-size: 22px; cursor: pointer; color: var(--text);
}

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(16,42,67,.05);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-header h5 { margin: 0; font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 4px; }

.stat-card { display: flex; align-items: center; gap: 16px; padding: 20px; }
.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff;
}
.stat-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13px; }

.bg-soft-primary { background: var(--primary); }
.bg-soft-info { background: #2c9cdb; }
.bg-soft-warning { background: #e8a33d; }
.bg-soft-danger { background: #e74c3c; }
.bg-soft-success { background: #27ae60; }
.bg-soft-purple { background: #8e5bd0; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; margin: 0; }
.table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  border-bottom: 2px solid var(--card-border);
  white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
.table tbody tr:hover { background: #f8fafb; }
.table-responsive { overflow-x: auto; }

/* ---------- Forms ---------- */
.form-label { font-size: 12.5px; font-weight: 600; color: #33475b; margin-bottom: 4px; }
.form-control, .form-select {
  border: 1px solid #cfd8e0;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13.5px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,122,95,.12);
  outline: none;
}
textarea.form-control { resize: vertical; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; border-radius: 9px;
  padding: 8px 16px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all .15s; line-height: 1.4;
}
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border: 1px solid #cfd8e0; color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #219150; }
.btn-warning { background: #e8a33d; color: #fff; }
.btn-info { background: #2c9cdb; color: #fff; }
.btn-secondary { background: #8fa3b8; color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef1f4; color: var(--text); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13.5px; }
.alert-success { background: #e8f8ef; color: #1e7e3f; border: 1px solid #bfe9cf; }
.alert-danger { background: #fdeceb; color: #b71c1c; border: 1px solid #f5c6c3; }
.alert-warning { background: #fef6e7; color: #8a5b00; border: 1px solid #f7e0ae; }
.alert-info { background: #e7f4fc; color: #1a6d9e; border: 1px solid #bfe0f4; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.bg-success { background: #e3f6ec !important; color: #17733c; }
.badge.bg-danger { background: #fde5e3 !important; color: #b71c1c; }
.badge.bg-warning { background: #fef3dd !important; color: #9c6a00; }
.badge.bg-primary { background: #e2f2ef !important; color: #0a5c48; }
.badge.bg-info { background: #e2f0fa !important; color: #1a6d9e; }
.badge.bg-secondary { background: #eef1f4 !important; color: #5d7187; }
.badge.bg-dark { background: #2c3e50 !important; color: #fff; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0d2137 0%, #12314d 55%, #0e7a5f 130%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 18px;
  width: 100%; max-width: 400px;
  padding: 36px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; margin: 0 auto 14px;
}

/* ---------- AI ---------- */
.ai-result {
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
  border-radius: 0 12px 12px 0;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.ai-conf { font-size: 12px; font-weight: 700; }
.ai-bar { height: 8px; border-radius: 6px; background: #dbe7e2; overflow: hidden; }
.ai-bar > div { height: 100%; background: linear-gradient(90deg, var(--primary), #35c99b); border-radius: 6px; }
.diagnostic-badge {
  position: absolute; top: 14px; right: 14px;
  background: linear-gradient(135deg, #8e5bd0, #6a3fb5);
  color: #fff; border-radius: 20px; padding: 6px 14px;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; gap: 6px;
}

/* ---------- Misc ---------- */
.text-muted { color: var(--muted); }
.text-success { color: #1e7e3f; }
.text-danger { color: #b71c1c; }
.text-warning { color: #9c6a00; }
.text-primary { color: var(--primary); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.fs-15 { font-size: 15px; }
.fs-20 { font-size: 20px; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 4px } .mt-2 { margin-top: 8px } .mt-3 { margin-top: 16px } .mt-4 { margin-top: 24px }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: 4px } .mb-2 { margin-bottom: 8px } .mb-3 { margin-bottom: 16px } .mb-4 { margin-bottom: 24px }
.ms-auto { margin-left: auto; }
.me-1 { margin-right: 4px } .me-2 { margin-right: 8px }
.gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; } .flex-wrap { flex-wrap: wrap; }
.d-none { display: none; }
.text-center { text-align: center; }
.img-round { border-radius: 50%; object-fit: cover; }
.pointer { cursor: pointer; }
.w-100 { width: 100%; }
.min-w-120 { min-width: 120px; }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .no-print, .btn { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .content { padding: 14px; }
  .topbar-title span { display: none; }
}
