/* ── MEA Console · app.css ── */

:root {
  --bg:          #090C10;
  --bg-2:        #0D1117;
  --surface:     #111720;
  --surface-2:   #161D28;
  --border:      rgba(255,255,255,0.06);
  --border-2:    rgba(255,255,255,0.10);
  --accent:      #00D4FF;
  --accent-dim:  rgba(0,212,255,0.08);
  --accent-glow: rgba(0,212,255,0.20);
  --text:        #F0F4F8;
  --text-2:      #8B99A8;
  --text-3:      #4A5568;
  --green:       #22C55E;
  --green-dim:   rgba(34,197,94,0.10);
  --yellow:      #F59E0B;
  --yellow-dim:  rgba(245,158,11,0.10);
  --red:         #EF4444;
  --red-dim:     rgba(239,68,68,0.10);
  --blue:        #60A5FA;
  --blue-dim:    rgba(96,165,250,0.10);

  --font-body:    'DM Sans', sans-serif;
  --font-display: 'Bebas Neue', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  --r:    8px;
  --r-lg: 14px;
  --t:    0.15s ease;

  --sidebar-w: 220px;
  --navbar-h:  54px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; }
input, textarea, select { font-family: var(--font-body); }

/* ── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }

/* ── LOADING ───────────────────────────────────────────────── */
#loadingScreen {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  transition: opacity 0.25s ease;
}
#loadingScreen.out { opacity: 0; pointer-events: none; }

.ld-logo {
  font-family: var(--font-display);
  font-size: 28px; letter-spacing: .12em;
  color: var(--accent);
}
.ld-bar {
  width: 120px; height: 2px;
  background: var(--surface-2);
  border-radius: 2px; overflow: hidden;
}
.ld-bar::after {
  content: '';
  display: block; height: 100%;
  width: 40%; background: var(--accent);
  animation: ldSlide 1s ease-in-out infinite;
}
@keyframes ldSlide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.ld-text { font-size: 12px; color: var(--text-3); letter-spacing: .05em; }

/* ── NAVBAR ────────────────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: rgba(9,12,16,0.85);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px; gap: 12px; z-index: 200;
}

.nav-brand {
  display: flex; align-items: center; gap: 9px;
  flex-shrink: 0;
}
.nav-logo { height: 22px; width: auto; }
.nav-title {
  font-family: var(--font-display);
  font-size: 15px; letter-spacing: .1em;
  color: var(--text);
}
.nav-badge {
  font-size: 9px; font-weight: 700; letter-spacing: .08em;
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid rgba(0,212,255,0.25);
  border-radius: 4px; padding: 2px 6px;
  text-transform: uppercase;
}

.nav-spacer { flex: 1; }

.nav-btn {
  width: 34px; height: 34px; border-radius: var(--r);
  background: transparent; border: none;
  color: var(--text-2); display: flex; align-items: center; justify-content: center;
  transition: background var(--t), color var(--t);
}
.nav-btn:hover { background: var(--surface); color: var(--text); }

.nav-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: 1.5px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent);
  cursor: pointer; overflow: hidden;
  transition: border-color var(--t);
}
.nav-avatar:hover { border-color: var(--accent); }
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── LAYOUT ────────────────────────────────────────────────── */
#appRoot { display: none; }
#appRoot.ready { display: flex; }

.app-wrap {
  display: flex;
  padding-top: var(--navbar-h);
  min-height: 100dvh;
  width: 100%;
}

/* ── SIDEBAR ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: var(--navbar-h); bottom: 0; left: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 10px 24px;
  display: flex; flex-direction: column; gap: 4px;
  z-index: 100;
}

.sb-section { margin-bottom: 4px; }
.sb-label {
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
  padding: 8px 8px 4px;
}

.sb-item {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r);
  background: transparent; border: none;
  color: var(--text-2); font-size: 13px; font-weight: 500;
  text-align: left; transition: background var(--t), color var(--t);
  position: relative;
}
.sb-item:hover { background: var(--surface); color: var(--text); }
.sb-item.active {
  background: var(--accent-dim); color: var(--accent);
}
.sb-item.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 2px; border-radius: 2px;
  background: var(--accent);
}
.sb-item svg { flex-shrink: 0; opacity: .7; }
.sb-item.active svg { opacity: 1; }

.sb-soon {
  opacity: .4; cursor: not-allowed;
}
.sb-soon:hover { background: transparent; color: var(--text-2); }

.sb-badge {
  margin-left: auto; font-size: 10px; font-weight: 700;
  background: var(--accent-dim); color: var(--accent);
  border-radius: 4px; padding: 1px 5px;
}

.sb-divider {
  height: 1px; background: var(--border);
  margin: 8px 0;
}

.sb-footer {
  margin-top: auto; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.sb-version {
  font-size: 10px; color: var(--text-3);
  padding: 4px 10px; font-family: var(--font-mono);
}

/* ── MAIN ──────────────────────────────────────────────────── */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 28px 60px;
  max-width: 100%;
  min-width: 0;
}

/* ── SECTION ───────────────────────────────────────────────── */
.section { display: none; }
.section.active { display: block; }

.section-head {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-family: var(--font-display);
  font-size: 22px; letter-spacing: .08em;
  color: var(--text); margin-bottom: 3px;
}
.section-sub { font-size: 13px; color: var(--text-3); }

/* ── STAT CARDS (overview only — minimal) ──────────────────── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 28px;
}
.stat-cell {
  background: var(--bg-2);
  padding: 18px 20px;
}
.stat-label { font-size: 11px; color: var(--text-3); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }
.stat-val   { font-family: var(--font-display); font-size: 28px; letter-spacing: .04em; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.stat-val.green  { color: var(--green); }
.stat-val.accent { color: var(--accent); }
.stat-val.yellow { color: var(--yellow); }

/* ── TABLE ─────────────────────────────────────────────────── */
.tbl-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.tbl-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tbl-search {
  flex: 1; min-width: 160px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r); padding: 7px 12px;
  color: var(--text-2);
}
.tbl-search input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 13px;
}
.tbl-search input::placeholder { color: var(--text-3); }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface); }
tbody td {
  padding: 12px 16px; font-size: 13px; color: var(--text-2);
  vertical-align: middle;
}
.td-name { font-weight: 600; color: var(--text); }
.td-mono { font-family: var(--font-mono); font-size: 12px; }

/* ── BADGE ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 4px;
}
.badge-green  { background: var(--green-dim);  color: var(--green);  }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-red    { background: var(--red-dim);    color: var(--red);    }
.badge-blue   { background: var(--blue-dim);   color: var(--blue);   }
.badge-accent { background: var(--accent-dim); color: var(--accent); }

/* ── BUTTONS ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r);
  font-size: 13px; font-weight: 600; border: none;
  transition: opacity var(--t), background var(--t), box-shadow var(--t);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn:active { opacity: .7; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { opacity: 1; box-shadow: 0 0 12px var(--accent-glow); }
.btn-ghost {
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); opacity: 1; }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--red); color: #fff; opacity: 1; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ── FORM FIELDS ───────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field-label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 6px;
}
.field-input, .field-select, .field-textarea {
  width: 100%; background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--r);
  padding: 9px 12px; font-size: 13px; color: var(--text);
  outline: none; transition: border-color var(--t), box-shadow var(--t);
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.field-textarea { resize: vertical; min-height: 80px; }
.field-select { appearance: none; cursor: pointer; }
.field-hint { font-size: 11px; color: var(--text-3); margin-top: 5px; }

/* ── DIVIDER ───────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ── EMPTY STATE ───────────────────────────────────────────── */
.empty {
  padding: 48px 20px; text-align: center;
  color: var(--text-3); font-size: 13px;
}
.empty svg { opacity: .3; margin-bottom: 12px; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); z-index: 500;
  align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 24px; width: 100%; max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.modal-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}
.modal-sub { font-size: 12px; color: var(--text-3); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* ── TOAST ─────────────────────────────────────────────────── */
#toastWrap {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9000; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r); padding: 11px 14px;
  font-size: 13px; color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: auto; min-width: 220px; max-width: 320px;
  animation: toastIn .2s ease;
}
.toast.out { animation: toastOut .2s ease forwards; }
.toast-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.toast.success .toast-dot { background: var(--green); }
.toast.error   .toast-dot { background: var(--red); }
.toast.info    .toast-dot { background: var(--accent); }
.toast.warning .toast-dot { background: var(--yellow); }
@keyframes toastIn  { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: none; } }
@keyframes toastOut { to   { opacity:0; transform: translateY(8px); } }

/* ── DROPDOWN (avatar) ─────────────────────────────────────── */
.dropdown {
  position: fixed; top: calc(var(--navbar-h) + 6px); right: 12px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); padding: 6px;
  min-width: 200px; z-index: 300;
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  display: none;
}
.dropdown.open { display: block; }
.av-user {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.av-name  { font-size: 13px; font-weight: 700; color: var(--text); }
.av-email { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.av-role  { font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--accent); margin-top: 3px; }
.av-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px; border-radius: var(--r);
  background: none; border: none; color: var(--text-2);
  font-size: 13px; text-align: left;
  transition: background var(--t), color var(--t);
}
.av-item:hover { background: var(--surface-2); color: var(--text); }
.av-item.danger:hover { background: var(--red-dim); color: var(--red); }

/* ── PRODUCT ROW (products section) ───────────────────────── */
.product-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.product-row:last-child { border-bottom: none; }
.product-icon {
  width: 36px; height: 36px; border-radius: var(--r);
  background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-name { font-size: 13px; font-weight: 700; color: var(--text); }
.product-url  { font-size: 11px; color: var(--text-3); margin-top: 1px; font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-ver  { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }

/* ── ANNOUNCEMENT ITEM ─────────────────────────────────────── */
.ann-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.ann-item:last-child { border-bottom: none; }
.ann-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 5px; flex-shrink: 0;
}
.ann-dot.info        { background: var(--accent); }
.ann-dot.warning     { background: var(--yellow); }
.ann-dot.maintenance { background: var(--blue); }
.ann-dot.critical    { background: var(--red); }
.ann-title  { font-size: 13px; font-weight: 600; color: var(--text); }
.ann-meta   { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.ann-msg    { font-size: 12px; color: var(--text-2); margin-top: 4px; line-height: 1.5; }

/* ── AUDIT LOG ─────────────────────────────────────────────── */
.log-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.log-item:last-child { border-bottom: none; }
.log-icon {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); flex-shrink: 0; margin-top: 1px;
}
.log-action { font-size: 13px; color: var(--text-2); }
.log-action strong { color: var(--text); }
.log-time   { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── PLACEHOLDER SECTION ───────────────────────────────────── */
.placeholder-wrap {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 80px 20px; text-align: center;
  gap: 12px;
}
.placeholder-icon {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); margin-bottom: 4px;
}
.placeholder-title { font-size: 15px; font-weight: 700; color: var(--text-2); }
.placeholder-desc  { font-size: 13px; color: var(--text-3); max-width: 280px; line-height: 1.6; }

/* ── MOBILE ────────────────────────────────────────────────── */
.mob-menu-btn { display: none; }

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 240px;
    z-index: 150;
  }
  .sidebar.open { transform: translateX(0); }

  .mob-menu-btn { display: flex; }
  .mob-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 140;
  }
  .mob-overlay.open { display: block; }

  .app-main { margin-left: 0; padding: 20px 16px 60px; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  thead th:nth-child(n+4) { display: none; }
  tbody td:nth-child(n+4) { display: none; }
}
