/* =========================================================
   MCH LEGACY — v3.1 ENTERPRISE DESIGN (complete)
   ========================================================= */

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

:root {
  --bg:          #f7f8fa;
  --surface:     #ffffff;
  --surface-2:   #fafbfc;
  --border:      #e6e8ec;
  --border-2:    #eef0f3;
  --text:        #0c111f;
  --text-2:      #4b5565;
  --text-3:      #7b8594;
  --text-4:      #a8afba;
  --text-muted:  #7b8594;

  --brand:       #4a1f9e;
  --brand-2:     #3b0e83;
  --brand-soft:  #f3efff;
  --accent:      #16a34a;
  --accent-soft: #e9f7ef;
  --gold:        #d4a017;
  --gold-soft:   #fdf6e0;
  --danger:      #dc2626;
  --danger-soft: #fef2f2;
  --warn:        #ea8a0b;
  --warn-soft:   #fff7ed;
  --info:        #0ea5e9;
  --info-soft:   #e0f2fe;

  --side:        #1a1330;
  --side-text:   #c4bcd6;
  --side-text-2: #8c82a8;
  --side-accent: #b69aff;

  --sh-sm: 0 1px 2px rgba(12,17,31,0.04);
  --sh-md: 0 4px 12px -2px rgba(12,17,31,0.08), 0 2px 4px -1px rgba(12,17,31,0.04);
  --sh-lg: 0 24px 48px -12px rgba(12,17,31,0.18);

  --radius:    6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --side-w: 248px;
  --topbar-h: 52px;
  --mono:      'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { overflow-x: hidden; min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; color: var(--text); }
input::placeholder { color: var(--text-4); }
::selection { background: var(--brand-soft); color: var(--brand); }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, h5 { font-weight: 600; letter-spacing: -0.015em; color: var(--text); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-4); }

.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }

/* Mobile bar */
.mobile-bar {
  display: none;
  position: sticky; top: 0;
  background: var(--side); color: #fff;
  padding: 10px 14px;
  align-items: center; gap: 12px;
  z-index: 50;
  border-bottom: 1px solid rgba(0,0,0,0.2);
}
.mobile-bar .menu-btn, .mobile-bar .mb-right {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); color: #fff; border-radius: 6px;
  text-decoration: none;
}
.mobile-bar .menu-btn svg, .mobile-bar .mb-right svg { width: 16px; height: 16px; }
.mobile-bar .mb-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
}
.mobile-bar .mb-brand img { width: 24px; height: 24px; border-radius: 5px; background: #fff; padding: 2px; }
.mobile-bar .mb-right { margin-left: auto; }

.side-backdrop { display: none; position: fixed; inset: 0; background: rgba(12,17,31,0.55); z-index: 60; backdrop-filter: blur(2px); }
.side-backdrop.open { display: block; }

/* Sidebar */
.sidebar {
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid rgba(0,0,0,0.2);
  z-index: 70;
}
.side-head {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-decoration: none;
  transition: background 120ms;
}
.side-head:hover { background: rgba(255,255,255,0.03); color: inherit; }
.side-head img { width: 32px; height: 32px; border-radius: 6px; background: #fff; padding: 2px; flex-shrink: 0; }
.side-head-text { flex: 1; min-width: 0; }
.side-head-name {
  color: #fff; font-weight: 600; font-size: 14px; letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 6px;
}
.side-head-name::after {
  content: ''; width: 8px; height: 8px; background: #3dd68c; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--side);
}
.side-head-sub { color: var(--side-text-2); font-size: 11.5px; }

.side-new {
  margin: 12px 14px 4px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--brand); color: #fff;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  transition: background 120ms;
}
.side-new:hover { background: var(--brand-2); color: #fff; }
.side-new svg { width: 14px; height: 14px; }

.side-search {
  margin: 8px 14px 12px;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius);
  font-size: 13px; color: var(--side-text-2);
  text-decoration: none;
  transition: all 120ms;
}
.side-search:hover { background: rgba(255,255,255,0.1); color: var(--side-text-2); }
.side-search svg { width: 13px; height: 13px; }
.side-search kbd {
  margin-left: auto;
  font-family: var(--mono); font-size: 10px;
  padding: 1px 5px; background: rgba(0,0,0,0.3); border-radius: 3px;
  color: var(--side-text-2);
}

.nav { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }

.nav-section {
  padding: 14px 10px 4px;
  font-size: 11px; font-weight: 600;
  color: var(--side-text-2);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.nav-section:first-child { padding-top: 8px; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; margin: 1px 0;
  border-radius: var(--radius);
  color: var(--side-text);
  font-size: 13.5px; font-weight: 450;
  text-decoration: none;
  transition: all 100ms;
}
.nav-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-link.active { background: var(--side-accent); color: #18102e; font-weight: 600; }
.nav-link.active:hover { background: var(--side-accent); color: #18102e; }
.nav-link svg { width: 15px; height: 15px; opacity: 0.75; flex-shrink: 0; }
.nav-link.active svg { opacity: 1; }
.nav-link .count {
  margin-left: auto;
  font-size: 11px; padding: 1px 7px;
  background: rgba(255,255,255,0.08); border-radius: 10px;
  color: var(--side-text-2);
  font-variant-numeric: tabular-nums; font-weight: 500;
}
.nav-link.active .count { background: rgba(0,0,0,0.1); color: #18102e; }
.nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 15px; flex-shrink: 0; }

.side-foot {
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 28px; height: 28px; border-radius: var(--radius);
  background: linear-gradient(135deg, #b69aff 0%, #4a1f9e 100%); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.side-foot-meta { flex: 1; min-width: 0; }
.side-foot-name { color: #fff; font-size: 13px; font-weight: 500; }
.side-foot-role { color: var(--side-text-2); font-size: 11px; }
.side-foot-logout {
  padding: 4px 8px; color: var(--side-text-2);
  border-radius: 4px; font-size: 11px;
  text-decoration: none; transition: background 120ms;
}
.side-foot-logout:hover { background: rgba(255,255,255,0.05); color: #fff; }

.side-amr {
  padding: 10px 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; background: rgba(0,0,0,0.15);
}
.side-amr-text { font-size: 10.5px; color: var(--side-text-2); letter-spacing: 0.02em; }
.side-amr-text strong { color: var(--side-text); font-weight: 500; }
.side-amr-logo { height: 14px; width: auto; opacity: 0.55; filter: invert(1); transition: opacity 150ms; }
.side-amr:hover .side-amr-logo { opacity: 0.9; }

/* Main */
.main { background: var(--bg); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.92);
  min-height: var(--topbar-h);
  gap: 16px;
}
.topbar-left {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-2);
  min-width: 0; flex: 1;
}
.crumb { color: var(--text-3); white-space: nowrap; text-decoration: none; }
.crumb:hover { color: var(--text); }
.topbar-left svg { width: 12px; height: 12px; color: var(--text-4); flex-shrink: 0; }
.current { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.topbar-right input[type="search"] {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  min-width: 180px;
  transition: all 150ms;
}
.topbar-right input[type="search"]:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.page-title { font-size: 18px; font-weight: 700; margin: 0; }

/* Buttons */
.btn, .tbtn {
  background: transparent;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 12.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 100ms;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  line-height: 1.4;
}
.btn:hover, .tbtn:hover { background: var(--bg); color: var(--text); border-color: var(--text-4); }
.btn svg, .tbtn svg { width: 13px; height: 13px; }
.btn-primary, .tbtn-primary {
  background: var(--text); color: #fff; border-color: var(--text);
}
.btn-primary:hover, .tbtn-primary:hover { background: #000; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-2); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 11.5px; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b01c1c; color: #fff; }
.actions { display: inline-flex; gap: 6px; align-items: center; }

/* Footer */
.main-foot {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 18px 28px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--text-3);
  background: var(--surface);
  gap: 16px; flex-wrap: wrap;
}
.main-foot-left { display: flex; align-items: center; gap: 12px; }
.main-foot-left img.mch { width: 20px; height: 20px; border-radius: 4px; }
.main-foot-right { display: flex; align-items: center; gap: 10px; }
.main-foot-right img.amr { height: 18px; width: auto; opacity: 0.75; transition: opacity 150ms; }
.main-foot-right:hover img.amr { opacity: 1; }
.main-foot a { color: var(--text-2); text-decoration: none; }
.main-foot a:hover { color: var(--brand); }

.content { flex: 1; padding: 20px 28px 40px; min-width: 0; }

/* =========== HOMEPAGE HERO =========== */
.home-hero {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 70px 32px 40px;
  position: relative;
}
.home-hero::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 50% 10%, rgba(74,31,158,0.05), transparent),
    radial-gradient(ellipse 500px 300px at 80% 60%, rgba(22,163,74,0.04), transparent);
  pointer-events: none;
}
.home-hero > * { position: relative; z-index: 1; width: 100%; max-width: 720px; }
.hero-brand {
  display: flex; align-items: center; gap: 14px;
  margin: 0 auto 28px;
  padding: 6px 14px 6px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  box-shadow: var(--sh-sm);
  width: fit-content; max-width: 100%;
}
.hero-brand img { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; }
.hero-brand-text { font-size: 12px; color: var(--text-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-brand-text strong { color: var(--text); font-weight: 600; }
.hero-pill {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 6px; padding: 2px 8px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 10px; font-size: 10px; font-weight: 600;
}
.hero-pill::before { content: ''; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.hero-title {
  font-size: clamp(26px, 4.5vw, 40px);
  font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;
  text-align: center; color: var(--text);
  margin-bottom: 12px;
}
.hero-title .grad {
  background: linear-gradient(135deg, #4a1f9e 0%, #16a34a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub {
  font-size: clamp(13px, 1.4vw, 15px); color: var(--text-2);
  text-align: center; margin-bottom: 32px; max-width: 560px;
  margin-left: auto; margin-right: auto;
}

.search-hero-box {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  box-shadow: var(--sh-md);
  display: flex; align-items: center; gap: 4px;
  transition: all 180ms;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-hero-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft), var(--sh-md); }
.search-hero-box .search-cat {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px; font-weight: 500; color: var(--text-2);
  flex-shrink: 0;
}
.search-hero-box .search-cat svg { width: 12px; height: 12px; color: var(--text-3); }
.search-hero-box input {
  flex: 1; min-width: 180px;
  border: none; outline: none; background: transparent;
  padding: 0 14px;
  font-size: clamp(14px, 1.6vw, 15.5px);
  color: var(--text); font-weight: 450;
}
.search-hero-box .search-submit {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  background: var(--text); color: #fff;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  transition: background 100ms;
  flex-shrink: 0; border: none; cursor: pointer;
}
.search-hero-box .search-submit:hover { background: #000; }
.search-hero-box .search-submit svg { width: 12px; height: 12px; }
.search-hero-box .search-submit kbd {
  margin-left: 6px;
  font-family: var(--mono); font-size: 10px;
  padding: 1px 5px; background: rgba(255,255,255,0.15); border-radius: 3px;
}
.hero-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 40px; }
.sugg-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px; color: var(--text-2);
  text-decoration: none;
  transition: all 120ms;
}
.sugg-chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.sugg-chip svg { width: 12px; height: 12px; opacity: 0.7; }
.sugg-chip code {
  font-family: var(--mono); font-size: 11px;
  color: var(--text); background: var(--bg);
  padding: 0 4px; border-radius: 3px; border: none;
}
.home-activity {
  width: 100%; max-width: 960px;
  margin: 40px auto 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}
.home-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.home-card-head {
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); gap: 8px;
}
.home-card-title { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.home-card-title svg { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.home-card-link { font-size: 11.5px; color: var(--text-3); font-weight: 500; white-space: nowrap; text-decoration: none; }
.home-card-body { padding: 4px 6px; }
.recent-item {
  padding: 10px;
  border-radius: var(--radius);
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit;
  transition: background 100ms;
}
.recent-item:hover { background: var(--bg); color: inherit; }
.recent-ic {
  width: 32px; height: 32px; border-radius: var(--radius);
  background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.recent-ic svg { width: 14px; height: 14px; }
.recent-body { flex: 1; min-width: 0; }
.recent-title { font-size: 13px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-sub {
  font-size: 11.5px; color: var(--text-3); margin-top: 1px;
  display: flex; gap: 8px; align-items: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recent-sub .dot { width: 2px; height: 2px; background: var(--text-4); border-radius: 50%; flex-shrink: 0; }

/* =========== UNIVERSAL SEARCH PAGE =========== */
.content > .search-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  margin-bottom: 20px;
  display: block;
  box-shadow: none;
  width: auto;
  max-width: none;
  flex-wrap: initial;
}
.content > .search-hero h2 {
  font-size: 20px; font-weight: 700; letter-spacing: -0.02em;
  margin: 0 0 6px; color: var(--text);
}
.content > .search-hero .hint { color: var(--text-3); font-size: 13px; margin-bottom: 16px; }
.content > .search-hero form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.content > .search-hero form input[type="search"] {
  flex: 1; min-width: 260px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  background: var(--surface);
  transition: all 150ms;
}
.content > .search-hero form input[type="search"]:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.content > .search-hero form button {
  padding: 10px 20px;
  background: var(--text); color: #fff;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--text); cursor: pointer;
}
.content > .search-hero form button:hover { background: #000; }
.hint { color: var(--text-3); font-size: 13px; }

/* =========== FILTER BAR =========== */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-end;
}
.filter-bar .form-field { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.filter-bar .form-field.wide { flex: 1 1 260px; min-width: 200px; }
.filter-bar .form-field label {
  font-size: 10.5px; color: var(--text-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.filter-bar .form-field input,
.filter-bar .form-field select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  color: var(--text);
  transition: all 150ms;
  width: 100%;
  max-width: 100%;
}
.filter-bar .form-field input:focus,
.filter-bar .form-field select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.filter-bar .actions { display: flex; gap: 6px; margin-left: auto; align-items: flex-end; }

/* =========== RESULT SUMMARY =========== */
.result-summary {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 13px; color: var(--text-2);
  flex-wrap: wrap; gap: 10px;
}
.result-summary strong { color: var(--text); font-weight: 700; }

/* =========== TABLE =========== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
}
table.data { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 680px; }
table.data thead { background: var(--surface-2); border-bottom: 1px solid var(--border); }
table.data thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
  border-right: 1px solid var(--border-2);
  white-space: nowrap;
}
table.data thead th:last-child { border-right: none; }
table.data thead th.num { text-align: right; }
table.data thead th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
table.data thead th a:hover { color: var(--text); }
table.data tbody tr { border-bottom: 1px solid var(--border-2); transition: background 80ms; }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg); }
table.data tbody td {
  padding: 10px 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
table.data td.mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap; }
table.data td strong { font-weight: 600; color: var(--text); }
table.data td.num { text-align: right; }
table.data .empty { text-align: center; color: var(--text-3); padding: 40px 20px; }
.empty {
  text-align: center;
  color: var(--text-3);
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-icon {
  font-size: 36px;
  line-height: 1;
  opacity: 0.35;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px; height: 64px;
  background: var(--bg);
  border-radius: 50%;
  margin-bottom: 4px;
}

/* Tags / badges */
.tag, .badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px 2px 7px;
  font-size: 10.5px; font-weight: 600;
  border-radius: 4px; line-height: 1.4;
  white-space: nowrap;
}
.tag::before, .badge::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.9;
}
.tag-perm, .badge-success { background: var(--accent-soft); color: var(--accent); }
.tag-prov, .badge-info    { background: var(--brand-soft); color: var(--brand); }
.tag-aq, .badge-warning   { background: var(--gold-soft); color: #a37c0c; }
.tag-oms, .badge-muted    { background: var(--bg); color: var(--text-2); }
.tag-pending              { background: var(--warn-soft); color: var(--warn); }
.badge-danger             { background: var(--danger-soft); color: var(--danger); }

/* Icon buttons */
.icon-btn, .btn-src {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  padding: 0;
  text-decoration: none;
  flex-shrink: 0;
  transition: all 100ms; cursor: pointer;
  font-size: 12px;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-4); }
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn.src, .btn-src { color: var(--brand); border-color: #e0d6f7; background: var(--brand-soft); }
.icon-btn.src:hover, .btn-src:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Pagination */
.pagination {
  padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; color: var(--text-3);
  flex-wrap: wrap; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.pagination .pg-info strong { color: var(--text); }
.pagination .pg-nav, .pagination .pg-nums { display: flex; gap: 4px; }
.pagination a, .pagination span.pg-current, .pg-btn {
  min-width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px; font-variant-numeric: tabular-nums;
  border-radius: 5px;
  padding: 0 8px;
  text-decoration: none;
  transition: all 100ms;
}
.pagination a:hover, .pg-btn:hover { background: var(--bg); color: var(--text); }
.pagination span.pg-current, .pg-btn.active { background: var(--text); color: #fff; border-color: var(--text); font-weight: 600; }
.pg-gap { color: var(--text-4); padding: 0 4px; }

/* =========== PANELS / CARDS =========== */
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
}
.panel-header, .card-head {
  padding: 12px 18px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border-2);
  gap: 12px;
  background: var(--surface-2);
}
.panel-header h2, .card-title {
  font-size: 11.5px;
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  margin: 0;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.panel-body, .card-body { padding: 18px; }
.panel-body.no-pad, .card-body.no-pad { padding: 0; }

/* =========== PROFILE PAGE =========== */
.profile-head {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}
.profile-head::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent) 100%);
}
.profile-head > div:first-child { gap: 16px !important; align-items: center !important; }
.profile-head > div:first-child > div:last-child {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  flex-shrink: 0;
}
.profile-head > div:first-child > div:last-child .btn-src {
  width: auto; padding: 4px 10px; font-size: 11.5px; gap: 4px;
}

.profile-name {
  font-size: 28px; font-weight: 700;
  letter-spacing: -0.025em; margin: 0;
  color: var(--text); line-height: 1.15;
}
.profile-alt-name { font-size: 13px; color: var(--text-3); margin-top: 4px; font-style: italic; }

.profile-ids {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-2);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px 24px;
}
.profile-ids > div { display: flex; flex-direction: column; gap: 3px; }
.profile-ids label {
  font-size: 10.5px; color: var(--text-3); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.profile-ids .val {
  font-size: 14px; font-weight: 600; color: var(--text);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.profile-ids .val:empty::before { content: '—'; color: var(--text-4); }

/* Tabs */
.tabs {
  display: flex; gap: 2px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  border: none; background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 120ms;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; flex-shrink: 0;
}
.tab:hover { background: var(--bg); color: var(--text); }
.tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tab svg { width: 14px; height: 14px; opacity: 0.8; }
.tab .tab-count, .tab .count {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  background: rgba(0,0,0,0.05);
  border-radius: 10px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.tab.active .tab-count, .tab.active .count { background: rgba(74,31,158,0.15); color: var(--brand); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Info grid — KEY FIX: proper 2-column key/value layout */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px 28px;
}
.info-item {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-2);
}
.info-item:last-child { border-bottom: none; }
.info-item label {
  font-size: 10.5px; color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  line-height: 1.2;
}
.info-val {
  font-size: 14px; font-weight: 500;
  color: var(--text);
  word-break: break-word;
  line-height: 1.4;
}
.info-val.mono, .info-val .mono {
  font-family: var(--mono); font-weight: 500;
  color: var(--text); font-size: 13px;
}
.info-val a { color: var(--brand); }
.info-val a:hover { color: var(--brand-2); text-decoration: underline; }
.info-val:empty::before { content: '—'; color: var(--text-4); font-weight: 400; }

/* Color-coded profile panels: left-border accent */
.tab-content > .panel {
  border-left: 3px solid var(--border);
  transition: border-color 150ms;
}
.tab-content > .panel:nth-of-type(1) { border-left-color: var(--brand); }
.tab-content > .panel:nth-of-type(2) { border-left-color: var(--accent); }
.tab-content > .panel:nth-of-type(3) { border-left-color: var(--info); }
.tab-content > .panel:nth-of-type(4) { border-left-color: var(--gold); }
.tab-content > .panel:nth-of-type(5) { border-left-color: #ec4899; }
.tab-content > .panel:nth-of-type(6) { border-left-color: #14b8a6; }
.tab-content > .panel .panel-header {
  background: var(--surface);
  border-bottom-color: var(--border-2);
}
.tab-content > .panel .panel-header h2 {
  font-size: 14px;
  text-transform: none;
  letter-spacing: -0.005em;
  font-weight: 700;
  color: var(--text);
}

/* =========== LOGIN =========== */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 700px 500px at 50% 0%, rgba(74,31,158,0.06), transparent),
    radial-gradient(ellipse 500px 400px at 80% 100%, rgba(22,163,74,0.04), transparent);
}
.login-card, .login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh-lg);
  padding: 40px;
  width: 100%; max-width: 420px;
}
.login-brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.login-brand img { width: 48px; height: 48px; border-radius: 10px; }
.login-brand-text h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.015em; margin: 0; }
.login-brand-text div { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.login-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 4px; }
.login-sub { font-size: 13.5px; color: var(--text-2); margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .form-field label, .login-box .form-field label {
  font-size: 12px; color: var(--text-2);
  font-weight: 500; text-transform: none;
  letter-spacing: normal; margin-bottom: 4px;
  display: block;
}
.login-form .form-field input, .login-box .form-field input {
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 150ms;
  width: 100%;
}
.login-form .form-field input:focus, .login-box .form-field input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.login-form button, .login-box .btn {
  padding: 10px 18px;
  background: var(--text); color: #fff;
  border: none; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background 100ms;
  margin-top: 6px;
  width: 100%;
}
.login-form button:hover, .login-box .btn:hover { background: #000; }
.login-error, .login-notice {
  padding: 10px 12px;
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 14px;
}
.login-notice { background: var(--warn-soft); color: var(--warn); }
.login-foot {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-3);
  display: flex; align-items: center; justify-content: space-between;
}
.login-foot img.amr { height: 16px; opacity: 0.7; }
.login-box .login-logo { display: flex; justify-content: center; margin-bottom: 16px; }
.login-box .mark {
  width: 48px; height: 48px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
}

/* =========== STAT CARDS (legacy dashboard) =========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all 150ms;
}
.stat-card:hover { border-color: var(--text-4); box-shadow: var(--sh-sm); }
.stat-card.accent { border-top: 3px solid var(--brand); }
.stat-card.success { border-top: 3px solid var(--accent); }
.stat-card.warning { border-top: 3px solid var(--warn); }
.stat-card.danger { border-top: 3px solid var(--danger); }
.stat-label {
  font-size: 11px; color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 26px; font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em; line-height: 1.1;
}
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.stat-sub a { color: var(--brand); text-decoration: none; font-weight: 500; }

/* =========== MODAL =========== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(12,17,31,0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal, .modal-backdrop > .modal {
  background: var(--surface);
  border-radius: 12px;
  max-width: 860px; width: 100%;
  max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: var(--sh-lg);
  overflow: hidden;
}
.modal-head, .src-modal-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-2);
  gap: 12px;
}
.modal-head h2, .src-modal-head h2 {
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  margin: 0; color: var(--text);
  text-transform: none; letter-spacing: -0.005em;
}
.modal-close, .src-modal-close {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  background: transparent;
  flex-shrink: 0;
  transition: all 100ms;
  cursor: pointer; font-size: 20px; line-height: 1;
}
.modal-close:hover, .src-modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body, .src-modal-content { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--surface-2);
}
.src-modal-body { padding: 0; }
.src-title { font-size: 16px; font-weight: 700; color: var(--text); margin: 0 0 4px; letter-spacing: -0.01em; }
.src-subtitle { font-size: 12.5px; color: var(--text-3); margin-bottom: 14px; }
.src-file-section {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.src-file-name {
  font-family: var(--mono);
  font-size: 12px; font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  padding: 8px 12px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}
.src-row { border-bottom: 1px solid var(--border-2); }
.src-row:last-child { border-bottom: none; }
.src-row-header {
  padding: 6px 12px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 11px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border-2);
}
.src-row-num {
  font-family: var(--mono); font-weight: 600;
  padding: 1px 5px;
  background: rgba(74,31,158,0.1); border-radius: 3px;
}
.src-row-placeholder { padding: 12px; color: var(--text-3); font-size: 12.5px; text-align: center; }
table.src-row-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.src-row-table tr { border-bottom: 1px solid var(--border-2); }
table.src-row-table tr:last-child { border-bottom: none; }
table.src-row-table tr:hover { background: var(--surface-2); }
table.src-row-table th {
  padding: 7px 12px;
  background: var(--surface-2);
  border-right: 1px solid var(--border-2);
  font-family: var(--mono); font-size: 11.5px;
  color: var(--text-2); font-weight: 500;
  text-align: left; width: 35%;
  word-break: break-word;
}
table.src-row-table td { padding: 7px 12px; color: var(--text); word-break: break-word; }
.src-err, .src-empty { padding: 40px; text-align: center; color: var(--text-3); font-size: 13px; }

.col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 14px;
  margin: 10px 0;
}
.col-grid label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; cursor: pointer;
}

/* Legacy brand */
.brand { padding: 14px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.brand-logo { width: 32px; height: 32px; border-radius: 6px; background: #fff; display: flex; align-items: center; justify-content: center; color: var(--brand); font-size: 18px; font-weight: 700; }
.brand-text { flex: 1; min-width: 0; }
.brand-name { color: #fff; font-weight: 600; font-size: 14px; }
.brand-sub { color: var(--side-text-2); font-size: 11.5px; }

.quicksearch { display: flex; align-items: center; gap: 8px; }
.quicksearch input {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; background: var(--surface); min-width: 220px;
  transition: all 150ms;
}
.quicksearch input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.quicksearch button { padding: 6px 12px; background: var(--text); color: #fff; border-radius: var(--radius); font-size: 12.5px; font-weight: 500; border: 1px solid var(--text); }
.quicksearch button:hover { background: #000; }

.sidebar-footer { padding: 10px 14px; border-top: 1px solid rgba(255,255,255,0.06); }
.user-info { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--side-text-2); gap: 10px; }
.user-info .logout { color: var(--side-text-2); font-size: 11px; text-decoration: none; padding: 3px 6px; border-radius: 4px; }
.user-info .logout:hover { background: rgba(255,255,255,0.05); color: #fff; }

/* Val helper */
.val { color: var(--text); font-weight: 500; }
.val:empty::before { content: '—'; color: var(--text-4); }
code {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px;
  color: var(--text);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  :root { --side-w: 220px; }
  .content { padding: 16px 20px 40px; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 220ms ease-out;
    z-index: 70;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 20px 50px rgba(0,0,0,0.4); z-index: 110; }
  .side-backdrop { z-index: 105; }
  .mobile-bar { display: flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .main-foot { padding: 16px; }
  .home-hero { padding: 48px 16px 32px; }
  .home-activity { grid-template-columns: 1fr; gap: 16px; }
  .filter-bar { padding: 12px; }
  .profile-head { padding: 20px; }
  .profile-name { font-size: 22px; }
  .info-grid { grid-template-columns: 1fr 1fr; gap: 14px 16px; }
}

@media (max-width: 640px) {
  .home-hero { padding: 32px 14px 24px; }
  .hero-brand-text { white-space: normal; font-size: 11px; }
  .search-hero-box { border-radius: 12px; padding: 6px; gap: 4px; }
  .search-hero-box .search-cat { display: none; }
  .search-hero-box input { padding: 8px 10px; min-width: 100px; }
  .search-hero-box .search-submit kbd { display: none; }
  .profile-head { padding: 16px; }
  .profile-name { font-size: 20px; }
  .profile-ids { grid-template-columns: 1fr 1fr; gap: 12px 16px; }
  .info-grid { grid-template-columns: 1fr; }
  .filter-bar .form-field { min-width: 100%; flex: 1 1 100%; }
  .filter-bar .actions { margin-left: 0; width: 100%; }
  table.src-row-table th { width: auto; display: block; border-right: none; border-bottom: 1px solid var(--border-2); padding-bottom: 3px; }
  table.src-row-table td { display: block; padding-top: 3px; }
  table.src-row-table tr { display: block; padding: 6px 0; }
  .main-foot { flex-direction: column; align-items: flex-start; gap: 10px; }
  .login-card, .login-box { padding: 28px 20px; }
  .content > .search-hero form input[type="search"] { min-width: 100%; }
  .topbar-right input[type="search"] { min-width: 120px; }
}
