/* ── IMM — app.css ───────────────────────────────────────────────────────
   Primary: Purple #8b5cf6  |  Font: Outfit
   Pattern B: Desktop CSS only. Mobile uses mobile/css/mobile.css
   ─────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ── IMM primary — purple ── */
  --primary:     #8b5cf6;
  --primary-dk:  #7c3aed;
  --primary-dim: rgba(139,92,246,.12);
  --primary-pale:rgba(139,92,246,.06);

  /* ── Semantic colours ── */
  --green:   #10b981;  --green-dim:  rgba(16,185,129,.12);
  --amber:   #f59e0b;  --amber-dim:  rgba(245,158,11,.12);
  --yellow:  #eab308;  --yellow-dim: rgba(234,179,8,.12);
  --red:     #ef4444;  --red-dim:    rgba(239,68,68,.12);
  --blue:    #3b82f6;  --blue-dim:   rgba(59,130,246,.12);

  /* ── Greys ── */
  --bg:      #f4f3ff;
  --bg2:     #ffffff;
  --bg3:     #faf9ff;
  --bg4:     #ede9fe;
  --text:    #1e1b4b;
  --text2:   #4c4885;
  --muted:   #9691c4;
  --border:  #e5e1fc;
  --border2: #c9c5f0;
  --shadow:  0 1px 4px rgba(88,74,160,.10);
  --shadow2: 0 4px 20px rgba(88,74,160,.12);

  /* ── Layout ── */
  --sb-w:     248px;
  --topbar-h: 60px;
  --radius:   12px;
  --radius-sm:8px;

  /* ── Font ── */
  --font: 'Outfit', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

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

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sb-w);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  transition: transform .25s ease;
}

.sb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid var(--border);
}

.sb-logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.sb-name {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.sb-sub {
  display: block;
  font-size: .7rem;
  color: var(--muted);
  line-height: 1.2;
}

.sb-nav {
  list-style: none;
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .875rem;
  font-weight: 400;
  transition: background .15s, color .15s;
  text-decoration: none;
}

.sb-link:hover { background: var(--primary-pale); color: var(--primary); text-decoration: none; }
.sb-link.active { background: var(--primary-dim); color: var(--primary); font-weight: 500; }
.sb-link svg { flex-shrink: 0; opacity: .7; }
.sb-link.active svg, .sb-link:hover svg { opacity: 1; }

.sb-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-dim);
  color: var(--primary);
  font-weight: 600;
  font-size: .82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sb-uinfo { flex: 1; min-width: 0; }
.sb-uname { display: block; font-size: .8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-urole { display: block; font-size: .7rem; color: var(--muted); }

.sb-logout {
  color: var(--muted);
  padding: 4px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.sb-logout:hover { color: var(--red); background: var(--red-dim); text-decoration: none; }

/* ── Main wrap ────────────────────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sb-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  padding: 4px;
  border-radius: 6px;
}

.page-title {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

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

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

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

/* ── Stat cards ───────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.stat-value { font-size: 2rem; font-weight: 600; color: var(--text); line-height: 1; }
.stat-meta  { font-size: .75rem; color: var(--muted); margin-top: 4px; }

.stat-card.stat-purple { border-left: 3px solid var(--primary); }
.stat-card.stat-green  { border-left: 3px solid var(--green); }
.stat-card.stat-amber  { border-left: 3px solid var(--amber); }
.stat-card.stat-red    { border-left: 3px solid var(--red); }
.stat-card.stat-blue   { border-left: 3px solid var(--blue); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  background: var(--bg3);
  color: var(--text2);
  font-weight: 500;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--primary-pale); }

tbody td {
  padding: 12px 14px;
  color: var(--text);
  vertical-align: middle;
}

.td-id { font-family: var(--mono); font-size: .78rem; color: var(--primary); font-weight: 500; }
.td-muted { color: var(--muted); font-size: .82rem; }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-green  { background: var(--green-dim);  color: #065f46; }
.badge-amber  { background: var(--amber-dim);  color: #92400e; }
.badge-yellow { background: var(--yellow-dim); color: #713f12; }
.badge-red    { background: var(--red-dim);    color: #991b1b; }
.badge-blue   { background: var(--blue-dim);   color: #1e40af; }
.badge-purple { background: var(--primary-dim);color: #5b21b6; }
.badge-gray   { background: #f1f5f9;           color: #64748b; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s, box-shadow .15s;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-outline   { background: transparent; border-color: var(--border2); color: var(--text2); }
.btn-outline:hover { background: var(--primary-pale); border-color: var(--primary); color: var(--primary); }
.btn-ghost     { background: transparent; color: var(--text2); border-color: transparent; }
.btn-ghost:hover { background: var(--primary-pale); color: var(--primary); }
.btn-sm        { padding: 5px 11px; font-size: .8rem; }
.btn-xs        { padding: 3px 8px; font-size: .75rem; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.form-group   { margin-bottom: 16px; }
.form-label   { display: block; font-size: .82rem; font-weight: 500; color: var(--text2); margin-bottom: 5px; }
.form-label .req { color: var(--red); }

.form-control {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .875rem;
  color: var(--text);
  background: var(--bg2);
  transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-grid   { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.form-hint { font-size: .75rem; color: var(--muted); margin-top: 3px; }

/* ── Filters bar ──────────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}

.search-input {
  padding: 7px 12px 7px 34px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .875rem;
  width: 240px;
  background: var(--bg2);
  color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239691c4' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  transition: border-color .15s;
}

.search-input:focus { outline: none; border-color: var(--primary); }

.filter-select {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .82rem;
  color: var(--text2);
  background: var(--bg2);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239691c4' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

/* ── Pagination ───────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: .82rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  border-radius: 6px;
  padding: 0 6px;
  color: var(--text2);
  text-decoration: none;
  transition: background .12s;
}

.pagination a:hover { background: var(--primary-pale); color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; font-weight: 500; }
.pagination .dots   { cursor: default; }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(30,27,74,.45);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}

.modal {
  background: var(--bg2);
  border-radius: var(--radius);
  box-shadow: var(--shadow2);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { color: var(--text); background: var(--bg4); }
.modal-body  { padding: 22px; }
.modal-foot  { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Alerts ───────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 20px;
}

.alert-success { background: var(--green-dim);  color: #065f46; border: 1px solid #6ee7b7; }
.alert-error   { background: var(--red-dim);    color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: var(--amber-dim);  color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: var(--blue-dim);   color: #1e40af; border: 1px solid #93c5fd; }
.alert-close   { background: none; border: none; cursor: pointer; font-size: 1.1rem; opacity: .6; padding: 0 4px; }
.alert-close:hover { opacity: 1; }

/* ── Section header ───────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.section-sub   { font-size: .82rem; color: var(--muted); margin-top: 2px; }

/* ── Detail page ──────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.detail-group { margin-bottom: 14px; }
.detail-label { font-size: .75rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.detail-value { font-size: .9rem; color: var(--text); font-weight: 400; }
.detail-value.mono { font-family: var(--mono); font-size: .82rem; color: var(--primary); }

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-link {
  padding: 10px 18px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  text-decoration: none;
}
.tab-link:hover { color: var(--primary); text-decoration: none; }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Login page ───────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ede9fe 0%, #f4f3ff 60%, #ddd6fe 100%);
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(88,74,160,.15);
  padding: 40px 44px;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-logo-mark {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .05em;
}

.login-logo-text { font-size: 1rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.login-logo-sub  { font-size: .78rem; color: var(--muted); }
.login-heading   { font-size: 1.3rem; font-weight: 600; margin-bottom: 6px; }
.login-sub       { font-size: .85rem; color: var(--muted); margin-bottom: 24px; }

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state svg { opacity: .35; margin-bottom: 12px; }
.empty-state p   { font-size: .9rem; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sb-w)));
  }
  .sidebar.open {
    transform: none;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .main-wrap { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .form-grid-2, .form-grid-3, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page-body { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
