/* ==========================================================================
   Emrican Admin — Control Center
   Dark enterprise theme, Emrican brand palette:
   navy #0e1018/#12141f/#171a28 · orange #d95d28 · coral #ff9d7a · ivory #f3f1ea
   ========================================================================== */

:root {
  --bg: #0e1018;
  --bg-soft: #12141f;
  --panel: #171a28;
  --panel-2: #1e2233;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .13);
  --text: #f3f1ea;
  --muted: #9ca3af;
  --faint: #6b7280;
  --orange: #d95d28;
  --orange-deep: #c2410c;
  --coral: #ff9d7a;
  --green: #34d399;
  --blue: #7db4f5;
  --red: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --side-w: 248px;
  --top-h: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
a { color: var(--coral); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
svg { display: block; }

::selection { background: rgba(217, 93, 40, .45); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2f45; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 6px; }

/* ---------- brand ---------- */
.brand-mark {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
}
.brand-mark .dot { color: var(--orange); }
.brand-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  vertical-align: 2px;
}

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
}
.login-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(700px 420px at 75% -8%, rgba(217, 93, 40, .16), transparent 60%),
    radial-gradient(600px 480px at -5% 105%, rgba(255, 157, 122, .08), transparent 55%),
    radial-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: auto, auto, 26px 26px;
}
.login-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 34px 32px 26px;
  animation: rise .4s cubic-bezier(.2, .8, .25, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.login-brand { margin-bottom: 26px; }
.login-brand .brand-mark { font-size: 26px; }
.login-card h1 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.01em; }
.login-sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }
.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.token-field { position: relative; }
.token-field input {
  width: 100%;
  padding: 12px 44px 12px 14px;
  background: var(--bg-soft);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.token-field input::placeholder { color: var(--faint); font-family: var(--font); }
.token-field input:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(217, 93, 40, .14); }
.remember {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 14px 2px 20px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.remember input { accent-color: var(--orange); width: 15px; height: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s, color .15s;
}
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, var(--orange), var(--orange-deep));
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(217, 93, 40, .35);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.ghost:hover { background: rgba(255, 255, 255, .05); }
.btn.danger { background: rgba(248, 113, 113, .12); color: var(--red); border-color: rgba(248, 113, 113, .3); }
.btn.danger:hover { background: rgba(248, 113, 113, .2); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, .07); }
.icon-btn.ghost { border-color: var(--line); background: var(--panel-2); }
.icon-btn.ghost:hover { border-color: var(--line-strong); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.sm svg { width: 14px; height: 14px; }
.icon-btn.danger:hover { color: var(--red); background: rgba(248, 113, 113, .12); }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .3);
  color: var(--red);
  font-size: 13px;
  animation: shake .3s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.login-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  color: var(--faint);
  font-size: 12px;
}

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 20px 14px 16px;
  z-index: 40;
  transition: transform .25s ease;
}
.side-head { padding: 0 10px 18px; border-bottom: 1px solid var(--line); }
.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; flex: 1; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.side-nav a svg { width: 17px; height: 17px; }
.side-nav a:hover { color: var(--text); background: rgba(255, 255, 255, .05); text-decoration: none; }
.side-nav a.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(217, 93, 40, .22), rgba(217, 93, 40, .06));
  box-shadow: inset 2.5px 0 0 var(--orange);
}
.nav-badge {
  margin-left: auto;
  min-width: 22px;
  text-align: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.side-foot { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 12px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.side-link svg { width: 15px; height: 15px; }
.side-link:hover { color: var(--text); background: rgba(255, 255, 255, .05); text-decoration: none; }
.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}
.avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--coral));
  color: #fff;
  font-weight: 800;
  font-size: 13px;
}

.main-col { flex: 1; margin-left: var(--side-w); min-width: 0; display: flex; flex-direction: column; }
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
  z-index: 35;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--top-h);
  padding: 0 26px;
  background: rgba(14, 16, 24, .8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.topbar-titles { flex: 1; min-width: 0; }
.topbar-titles h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.topbar-titles p { margin: 0; color: var(--muted); font-size: 12px; }
.env-pill {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--coral);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

/* ---------- views ---------- */
.view { padding: 24px 26px 60px; animation: fadeup .25s ease both; }
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } }

/* ==========================================================================
   DASHBOARD
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 17px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, transform .15s;
}
.stat-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.stat-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  flex: none;
}
.stat-icon svg { width: 19px; height: 19px; }
.stat-icon.orange { background: rgba(217, 93, 40, .14); color: var(--coral); }
.stat-icon.coral { background: rgba(255, 157, 122, .12); color: var(--coral); }
.stat-icon.blue { background: rgba(125, 180, 245, .12); color: var(--blue); }
.stat-icon.green { background: rgba(52, 211, 153, .12); color: var(--green); }
.stat-label { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.stat-value { margin: 3px 0 2px; font-family: var(--mono); font-size: 25px; font-weight: 600; letter-spacing: -.02em; }
.stat-sub { margin: 0; color: var(--faint); font-size: 12px; }

.panel-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px 12px;
}
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-sub { margin: 1px 0 0; color: var(--faint); font-size: 12px; }
.panel-chip {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--coral);
  background: rgba(255, 157, 122, .1);
  border: 1px solid rgba(255, 157, 122, .22);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.link { font-size: 12.5px; font-weight: 600; }

/* chart */
.chart-wrap { padding: 6px 18px 16px; }
.chart-wrap svg { width: 100%; height: 220px; display: block; }
.bar { fill: url(#bar-grad); transition: fill .15s; cursor: default; }
.bar:hover { fill: var(--coral); }
.grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.axis-label { fill: var(--faint); font-size: 10px; font-family: var(--mono); }
.bar-value { fill: var(--muted); font-size: 10px; font-family: var(--mono); }

/* recent list */
.recent-list { list-style: none; margin: 0; padding: 0 6px 8px; }
.recent-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
}
.recent-list li:hover { background: rgba(255, 255, 255, .045); }
.recent-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(217, 93, 40, .16);
  color: var(--coral);
  font-weight: 700;
  font-size: 12px;
  flex: none;
}
.recent-main { flex: 1; min-width: 0; }
.recent-name { margin: 0; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-msg { margin: 0; color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-time { color: var(--faint); font-family: var(--mono); font-size: 10.5px; flex: none; }

/* ==========================================================================
   TOOLBAR / CHIPS / TABLES
   ========================================================================== */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 440px; }
.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--faint);
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(217, 93, 40, .12); }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.active { color: #fff; background: var(--orange); border-color: var(--orange); }
.chip .n { opacity: .75; font-family: var(--mono); font-size: 11px; margin-left: 4px; }

.table-wrap { position: relative; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.data-table th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 11px 16px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr { cursor: pointer; transition: background .12s; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, .035); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.td-name { font-weight: 600; white-space: nowrap; }
.td-email { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.td-company { color: var(--muted); }
.td-msg { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.td-date { color: var(--faint); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.td-key { font-family: var(--mono); font-size: 12px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-num { font-family: var(--mono); font-size: 12px; }
.td-actions { text-align: right; white-space: nowrap; width: 100px; }
.td-actions .icon-btn { opacity: .65; }
.td-actions .icon-btn:hover { opacity: 1; }
.row-actions { display: inline-flex; gap: 4px; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-new { color: var(--coral); background: rgba(255, 157, 122, .1); border: 1px solid rgba(255, 157, 122, .25); }
.status-read { color: var(--blue); background: rgba(125, 180, 245, .1); border: 1px solid rgba(125, 180, 245, .25); }
.status-replied { color: var(--green); background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .25); }
.status-archived { color: var(--muted); background: rgba(156, 163, 175, .1); border: 1px solid rgba(156, 163, 175, .25); }

.file-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  margin-right: 10px;
  vertical-align: middle;
}
.file-icon svg { width: 15px; height: 15px; }
.file-icon img { max-width: 30px; max-height: 30px; border-radius: 6px; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
}
.table-foot > span { color: var(--faint); font-family: var(--mono); font-size: 11.5px; }
.pager { display: flex; align-items: center; gap: 8px; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.pager button:disabled { opacity: .35; cursor: not-allowed; }

/* empty + skeleton */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 52px 20px;
  color: var(--faint);
  text-align: center;
}
.empty svg { width: 42px; height: 42px; opacity: .55; }
.empty p { margin: 0; max-width: 340px; font-size: 13px; }
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--panel-2);
  border-radius: 8px;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.chart-skeleton { height: 200px; margin: 12px 0 16px; }
.list-skeleton { height: 46px; margin: 6px 6px; }
.row-skeleton { height: 40px; margin: 10px 16px; }
.skeleton-wrap { padding: 6px 0; }

/* ==========================================================================
   DROPZONE + UPLOADS
   ========================================================================== */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 28px 20px;
  margin-bottom: 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s, transform .12s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--orange); }
.dropzone.drag {
  border-color: var(--orange);
  background: rgba(217, 93, 40, .08);
  transform: scale(1.005);
}
.dz-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(217, 93, 40, .14);
  color: var(--coral);
  margin-bottom: 6px;
}
.dz-icon svg { width: 22px; height: 22px; }
.dz-title { margin: 0; font-weight: 600; font-size: 14px; }
.dz-browse { color: var(--coral); text-decoration: underline; text-underline-offset: 3px; }
.dz-hint { margin: 0; color: var(--faint); font-size: 12px; }

.upload-queue { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.upload-row .fname { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .fstatus { color: var(--muted); font-family: var(--mono); font-size: 11.5px; min-width: 38px; text-align: right; }
.upload-row .fstatus.ok { color: var(--green); font-weight: 700; }
.upload-row .fstatus.err { color: var(--red); font-weight: 700; }
.fbar { width: 120px; height: 5px; background: var(--panel-2); border-radius: 999px; overflow: hidden; flex: none; }
.fbar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--orange), var(--coral)); border-radius: 999px; transition: width .2s; }

/* ==========================================================================
   DRAWER
   ========================================================================== */
.drawer-root { position: fixed; inset: 0; z-index: 60; }
.drawer-root .backdrop { z-index: 1; }
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(500px, 94vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 60px rgba(0, 0, 0, .45);
  z-index: 2;
  animation: slidein .28s cubic-bezier(.2, .8, .25, 1) both;
}
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h3 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.drawer-head p { margin: 2px 0 0; font-family: var(--mono); font-size: 11.5px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.drawer-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
}
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin-bottom: 18px; }
.meta-item .k {
  margin: 0 0 3px;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.meta-item .v { margin: 0; font-size: 13.5px; word-break: break-word; }
.message-box {
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.status-select {
  padding: 8px 12px;
  background: var(--panel-2);
  border: 1.5px solid var(--line-strong);
  border-radius: 9px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.status-select:focus { border-color: var(--orange); }

/* ==========================================================================
   MODAL + TOASTS
   ========================================================================== */
.modal-root { position: fixed; inset: 0; z-index: 70; }
.modal-root .backdrop { z-index: 1; }
.modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
  z-index: 2;
  animation: rise .25s cubic-bezier(.2, .8, .25, 1) both;
}
.modal h3 { margin: 0 0 8px; font-size: 16px; }
.modal p { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; line-height: 1.6; word-break: break-word; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--green);
  border-radius: 11px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  font-weight: 500;
  animation: toastin .3s cubic-bezier(.2, .8, .25, 1) both;
}
.toast.error { border-left-color: var(--red); }
.toast svg { width: 16px; height: 16px; flex: none; }
.toast .t-ok { color: var(--green); }
.toast .t-err { color: var(--red); }
.toast.out { animation: toastout .25s ease both; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px) scale(.97); } }
@keyframes toastout { to { opacity: 0; transform: translateY(6px); } }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 24px 0 60px rgba(0, 0, 0, .45); }
  .main-col { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .view { padding: 18px 14px 50px; }
  .topbar { padding: 0 14px; }
  .env-pill { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .meta-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions { margin-left: 0; justify-content: flex-end; }
  .search { max-width: none; }
}
