/* ============================================================
   NutriSystem — Nutrition Clinic Management
   Main stylesheet
   ============================================================ */

/* ── 1. Custom Properties ────────────────────────────────── */
:root {
  --primary:        #0ea5e9;
  --primary-dark:   #0284c7;
  --primary-light:  #e0f2fe;
  --accent:         #10b981;
  --accent-dark:    #059669;
  --surface:        #ffffff;
  --bg:             #f0f9ff;
  --text:           #0f172a;
  --muted:          #64748b;
  --border:         #e2e8f0;
  --danger:         #ef4444;
  --danger-light:   #fee2e2;
  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --success:        #10b981;
  --success-light:  #d1fae5;
  --info-light:     #e0f2fe;

  --radius-sm:   6px;
  --radius:      8px;
  --radius-md:   12px;
  --radius-lg:   16px;

  --shadow-sm:   0 1px 2px rgba(0,0,0,.06);
  --shadow:      0 1px 4px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10), 0 1px 4px rgba(0,0,0,.06);

  --sidebar-w:   260px;
  --topbar-h:    56px;

  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --transition: 150ms ease;
}

/* ── 2. Reset + Base ─────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

img,
svg {
  display: block;
  max-width: 100%;
}

ul,
ol {
  list-style: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

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

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

/* ── 4. Sidebar ──────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  z-index: 100;
  overflow: hidden;
  transition: transform var(--transition);
}

/* ── 5. Sidebar Logo ─────────────────────────────────────── */
.sidebar-logo {
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-brand {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.sidebar-subtitle {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── 6. Sidebar Nav ──────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ── 7. Nav Section ──────────────────────────────────────── */
.nav-section {
  margin-bottom: 4px;
}

.nav-section-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  padding: 8px 20px 4px;
}

/* ── 8. Nav Item ─────────────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: var(--radius);
  margin: 1px 8px;
  transition: background var(--transition), color var(--transition);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  user-select: none;
  position: relative;
}

.nav-item svg,
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.65;
  flex-shrink: 0;
  transition: opacity var(--transition);
}

.nav-item:hover {
  background: var(--bg);
  color: var(--primary);
  text-decoration: none;
}

.nav-item:hover svg,
.nav-item:hover .nav-icon {
  opacity: 1;
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.nav-item.active svg,
.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

/* ── 9. Sidebar Footer ───────────────────────────────────── */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  flex-shrink: 0;
  background: var(--surface);
}

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

.sidebar-user:hover {
  background: var(--bg);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.sidebar-logout:hover {
  background: var(--danger-light);
  color: var(--danger);
}

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

.topbar-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.topbar-menu-btn:hover {
  background: var(--bg);
  color: var(--text);
}

/* ── 11. Topbar Title ────────────────────────────────────── */
.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.topbar-spacer {
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.topbar-icon-btn:hover {
  background: var(--bg);
  color: var(--primary);
  border-color: var(--primary);
}

/* ── 12. Content ─────────────────────────────────────────── */
.content {
  padding: 24px;
  max-width: 1400px;
  width: 100%;
  flex: 1;
}

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

/* ── 13. Card ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}

.card + .card {
  margin-top: 16px;
}

.card-flat {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px;
}

/* ── 14. Card Header ─────────────────────────────────────── */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 1px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 15. Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition), opacity var(--transition);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1.2;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(14,165,233,.25);
}

.btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(14,165,233,.35);
  transform: translateY(-1px);
  text-decoration: none;
  color: #fff;
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Secondary */
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: #e2edf5;
  color: var(--text);
  border-color: #c5d5e2;
  box-shadow: var(--shadow-sm);
}

/* Danger */
.btn-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 1px 3px rgba(239,68,68,.25);
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 2px 8px rgba(239,68,68,.35);
  color: #fff;
}

/* Success */
.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 1px 3px rgba(16,185,129,.25);
}

.btn-success:hover {
  background: var(--accent-dark);
  box-shadow: 0 2px 8px rgba(16,185,129,.35);
  color: #fff;
}

/* Warning */
.btn-warning {
  background: var(--warning);
  color: #fff;
  box-shadow: 0 1px 3px rgba(245,158,11,.25);
}

.btn-warning:hover {
  background: #d97706;
  box-shadow: 0 2px 8px rgba(245,158,11,.35);
  color: #fff;
}

/* Small */
.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  gap: 4px;
}

.btn-sm svg {
  width: 13px;
  height: 13px;
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  box-shadow: none;
}

.btn-outline:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: none;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
  box-shadow: none;
}

.btn-outline-danger:hover {
  background: var(--danger-light);
  color: var(--danger);
  box-shadow: none;
}

/* Icon only */
.btn-icon {
  padding: 7px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: none;
  transform: none;
}

/* ── 16. Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.badge-ok,
.badge-success {
  background: var(--success-light);
  color: var(--accent-dark);
}

.badge-warn,
.badge-warning {
  background: var(--warning-light);
  color: #b45309;
}

.badge-danger,
.badge-error {
  background: var(--danger-light);
  color: #b91c1c;
}

.badge-info,
.badge-primary {
  background: var(--info-light);
  color: var(--primary-dark);
}

.badge-gray,
.badge-muted {
  background: #f1f5f9;
  color: var(--muted);
}

.badge-accent {
  background: #d1fae5;
  color: #065f46;
}

/* ── 17. Tables ──────────────────────────────────────────── */
.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.t thead {
  background: #f8fafc;
}

.t thead tr {
  border-bottom: 1.5px solid var(--border);
}

.t th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  white-space: nowrap;
}

.t td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text);
  vertical-align: middle;
}

.t tbody tr:last-child td {
  border-bottom: none;
}

.t tbody tr:hover td {
  background: #f8fafc;
}

.t .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 13px;
}

.t .center {
  text-align: center;
}

.t-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.t-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0 !important;
  font-size: 13px;
}

/* ── 18. Forms ───────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="tel"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="tel"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f8fafc;
  color: var(--muted);
  cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* ── 19. Form Groups ─────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 4px;
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.form-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
  display: none;
}

.form-error.show {
  display: block;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group input,
.input-group select {
  border-radius: 0;
  flex: 1;
}

.input-group input:first-child,
.input-group select:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.input-group input:last-child,
.input-group select:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.input-addon {
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.input-addon:first-child {
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
}

.input-addon:last-child {
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── 20. Grid System ─────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

@media (max-width: 1100px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ── 21. Stat Cards ──────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
}

.stat-icon-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.stat-icon-success {
  background: var(--success-light);
  color: var(--accent-dark);
}

.stat-icon-warning {
  background: var(--warning-light);
  color: #b45309;
}

.stat-icon-danger {
  background: var(--danger-light);
  color: #b91c1c;
}

.stat-body {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 3px;
}

.stat-change {
  font-size: 11px;
  font-weight: 700;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-change.up {
  color: var(--success);
}

.stat-change.down {
  color: var(--danger);
}

/* ── 22. Tab Bar ─────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1.5px solid var(--border);
  padding: 0 0 0 4px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-bar::-webkit-scrollbar {
  height: 0;
}

/* ── 23. Tab Button ──────────────────────────────────────── */
.tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1.5px solid transparent;
  border-bottom: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: color var(--transition), background var(--transition);
  position: relative;
  bottom: -1.5px;
}

.tab-btn:hover {
  color: var(--text);
  background: #f8fafc;
}

.tab-btn.active {
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  color: var(--primary);
  font-weight: 700;
}

/* ── 24. Tab Panels ──────────────────────────────────────── */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── 25. Modal ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.50);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: fadeIn 150ms ease;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,.20), 0 4px 16px rgba(0,0,0,.10);
  animation: slideUp 200ms ease;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-box-lg {
  max-width: 760px;
}

.modal-box-xl {
  max-width: 960px;
}

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

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--muted);
  transition: background var(--transition), color var(--transition);
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── 26. Alerts ──────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-info {
  background: var(--info-light);
  border-color: #bae6fd;
  color: var(--primary-dark);
}

.alert-success {
  background: var(--success-light);
  border-color: #6ee7b7;
  color: var(--accent-dark);
}

.alert-warning {
  background: var(--warning-light);
  border-color: #fcd34d;
  color: #92400e;
}

.alert-error {
  background: var(--danger-light);
  border-color: #fca5a5;
  color: #991b1b;
}

/* ── 27. Avatar ──────────────────────────────────────────── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  user-select: none;
}

.avatar-sm {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 18px;
}

.avatar-xl {
  width: 64px;
  height: 64px;
  font-size: 24px;
}

.avatar-green  { background: var(--success); }
.avatar-red    { background: var(--danger); }
.avatar-yellow { background: var(--warning); }
.avatar-gray   { background: var(--muted); }

/* ── 28. Integration Status ──────────────────────────────── */
.integ-ok {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--success-light);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
}

.integ-ok::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.integ-alert {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--danger-light);
  color: #b91c1c;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
}

.integ-alert::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.integ-none {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
}

.integ-none::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  opacity: 0.5;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(1.3); }
}

/* ── 29. Login Page ──────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 40%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  padding: 40px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
  text-align: center;
}

.login-logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 8px 24px rgba(14,165,233,.35);
}

.login-logo-name {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.login-logo-sub {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.login-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ── 30. Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 10px;
  opacity: 0.7;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* ── Toast Notifications ─────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  min-width: 260px;
  max-width: 360px;
  box-shadow: var(--shadow-md);
  pointer-events: all;
  animation: toastIn 250ms ease;
  font-size: 13.5px;
  font-weight: 500;
}

.toast.removing {
  animation: toastOut 250ms ease forwards;
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.toast-msg {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.toast-close:hover {
  opacity: 1;
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-error .toast-icon {
  color: var(--danger);
}

.toast-warning {
  border-left: 4px solid var(--warning);
}

.toast-warning .toast-icon {
  color: var(--warning);
}

.toast-info {
  border-left: 4px solid var(--primary);
}

.toast-info .toast-icon {
  color: var(--primary);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); max-height: 100px; margin-bottom: 0; }
  to   { opacity: 0; transform: translateX(20px); max-height: 0; margin-bottom: -8px; }
}

/* ── Confirm Dialog ──────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.50);
  z-index: 99000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: fadeIn 150ms ease;
}

.confirm-box {
  background: var(--surface);
  border-radius: var(--radius-md);
  max-width: 380px;
  width: 100%;
  padding: 28px 28px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.20);
  animation: slideUp 200ms ease;
  text-align: center;
}

.confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--warning-light);
  color: var(--warning);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 22px;
}

.confirm-msg {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 20px;
  line-height: 1.55;
}

.confirm-footer {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── Sidebar Mobile Overlay ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.40);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
  display: block;
}

/* ── Misc Utilities ──────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.gap-4    { gap: 4px; }
.gap-6    { gap: 6px; }
.gap-8    { gap: 8px; }
.gap-12   { gap: 12px; }
.gap-16   { gap: 16px; }
.gap-20   { gap: 20px; }
.flex-1   { flex: 1; }
.w-full   { width: 100%; }
.min-w-0  { min-width: 0; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-muted   { color: var(--muted); }
.text-primary { color: var(--primary); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-sm   { font-size: 12px; }
.text-xs   { font-size: 11px; }
.font-bold { font-weight: 700; }
.font-600  { font-weight: 600; }
.mono      { font-family: var(--mono); }
.truncate  {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hidden { display: none !important; }
.mt-4  { margin-top:    4px; }
.mt-8  { margin-top:    8px; }
.mt-12 { margin-top:   12px; }
.mt-16 { margin-top:   16px; }
.mt-20 { margin-top:   20px; }
.mb-4  { margin-bottom:  4px; }
.mb-8  { margin-bottom:  8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.p-0   { padding: 0; }
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Progress bar */
.progress {
  height: 8px;
  background: var(--border);
  border-radius: 20px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 20px;
  transition: width 400ms ease;
}

.progress-bar.green  { background: var(--success); }
.progress-bar.red    { background: var(--danger); }
.progress-bar.yellow { background: var(--warning); }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  display: block;
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 31. Mobile Responsive ───────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 100;
    transition: transform 250ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  .main {
    margin-left: 0;
  }

  .topbar-menu-btn {
    display: flex;
  }

  .content {
    padding: 16px;
  }

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 16px;
  }

  .modal-box {
    max-width: 100%;
    margin: 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .topbar-title {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .tab-btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  .btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  .login-card {
    padding: 28px 20px;
  }
}
