/* WA-WAR admin console — dark ops-console design system.
   Fonts (loaded per page): Archivo (display), IBM Plex Sans (UI), IBM Plex Mono (data). */

:root {
  --bg: #0a0c11;
  --panel: #111621;
  --panel-2: #161c2a;
  --panel-3: #1d2434;
  --line: rgba(148, 163, 184, 0.12);
  --line-2: rgba(148, 163, 184, 0.22);
  --ink: #e9ecf3;
  --ink-dim: #aeb6c9;
  --muted: #6b7488;

  --accent: #3ddc84;
  --accent-2: #2bb96c;
  --accent-ink: #04160c;
  --accent-glow: rgba(61, 220, 132, 0.28);

  --amber: #f6b73c;
  --sky: #58c4ff;
  --rose: #fb6b7e;
  --slate: #7c869c;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --shadow-sm: 0 8px 24px -12px rgba(0, 0, 0, 0.6);

  --f-display: 'Archivo', -apple-system, sans-serif;
  --f-ui: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--f-ui);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  position: relative;
}
/* atmospheric glow + faint dot grid + grain */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(61, 220, 132, 0.10), transparent 60%),
    radial-gradient(700px 500px at 100% 0%, rgba(88, 196, 255, 0.06), transparent 55%),
    radial-gradient(circle at center, rgba(148,163,184,.5) 0.5px, transparent 0.6px);
  background-size: auto, auto, 22px 22px;
  opacity: 1;
}
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- shell ---------- */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.015), transparent);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: radial-gradient(120% 120% at 30% 20%, var(--accent), var(--accent-2));
  display: grid; place-items: center; box-shadow: 0 0 0 1px rgba(61,220,132,.4), 0 8px 20px -6px var(--accent-glow);
  position: relative;
}
.brand .mark::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-ink);
  box-shadow: 0 0 0 3px rgba(4,22,12,.25);
}
.brand .name { font-family: var(--f-display); font-weight: 800; font-size: 17px; letter-spacing: .12em; }
.brand .name b { color: var(--accent); }
.brand .sub { display:block; font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .28em; color: var(--muted); margin-top: 2px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label { font-family: var(--f-mono); font-size: 10px; letter-spacing: .22em; color: var(--muted); text-transform: uppercase; padding: 0 10px 8px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 11px; border-radius: var(--r-sm);
  color: var(--ink-dim); text-decoration: none; font-size: 14px; font-weight: 500;
  position: relative; transition: background .15s, color .15s;
}
.nav a svg { width: 17px; height: 17px; opacity: .8; }
.nav a:hover { background: var(--panel-2); color: var(--ink); }
.nav a.active { background: var(--panel-2); color: var(--ink); }
.nav a.active::before {
  content: ''; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent-glow);
}
.nav a.active svg { opacity: 1; color: var(--accent); }

.side-foot { margin-top: auto; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.side-foot .row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-dim); }
.side-foot .row + .row { margin-top: 8px; }
.side-foot .k { color: var(--muted); font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .05em; }

/* ---------- main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 4;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 20px 30px; border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 17, 0.72); backdrop-filter: blur(14px);
}
.topbar h1 { font-family: var(--f-display); font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.topbar .crumb { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.content { padding: 28px 30px 60px; }

/* live indicator */
.live { display: inline-flex; align-items: center; gap: 8px; font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; color: var(--ink-dim); padding: 7px 12px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel); }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent-glow); animation: pulse 2s infinite; }
.live.down .dot { background: var(--amber); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-glow); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card.pad { padding: 22px; }
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-family: var(--f-display); font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .01em; }
.card-head .hint { font-size: 12px; color: var(--muted); }

/* stat row */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; position: relative; overflow: hidden; }
.stat .n { font-family: var(--f-display); font-size: 30px; font-weight: 700; line-height: 1; }
.stat .l { font-family: var(--f-mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.stat .spark { position: absolute; right: 14px; top: 14px; width: 8px; height: 8px; border-radius: 50%; }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 13px 18px; font-family: var(--f-mono); font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 14px 18px; font-size: 13.5px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--panel-2); }
.mono { font-family: var(--f-mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.dim { color: var(--ink-dim); }

/* status pill */
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; padding: 5px 11px 5px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.p-open   { color: #7ff0b0; background: rgba(61,220,132,.10); border-color: rgba(61,220,132,.22); }
.p-open::before   { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.p-await  { color: #ffcf7a; background: rgba(246,183,60,.10); border-color: rgba(246,183,60,.22); }
.p-await::before  { background: var(--amber); }
.p-conn   { color: #9fddff; background: rgba(88,196,255,.10); border-color: rgba(88,196,255,.22); }
.p-conn::before   { background: var(--sky); animation: pulse 1.6s infinite; }
.p-out    { color: #ffa2ae; background: rgba(251,107,126,.10); border-color: rgba(251,107,126,.22); }
.p-out::before    { background: var(--rose); }
.p-idle   { color: var(--ink-dim); background: rgba(124,134,156,.10); border-color: rgba(124,134,156,.22); }
.p-idle::before   { background: var(--slate); }

.tag { font-family: var(--f-mono); font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--panel-3); color: var(--ink-dim); border: 1px solid var(--line); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- buttons ---------- */
.btn { font-family: var(--f-ui); font-size: 13.5px; font-weight: 600; border: 1px solid transparent; border-radius: var(--r-sm); padding: 9px 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; text-decoration: none; transition: background .15s, border-color .15s, color .15s, transform .05s, box-shadow .15s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px -8px var(--accent-glow); }
.btn-primary:hover { background: #4ee995; box-shadow: 0 8px 26px -8px var(--accent-glow); }
.btn-ghost { background: transparent; color: var(--ink-dim); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--panel-2); color: var(--ink); }
.btn-danger { background: rgba(251,107,126,.08); color: #ff98a5; border-color: rgba(251,107,126,.28); }
.btn-danger:hover { background: rgba(251,107,126,.16); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- form ---------- */
.field { margin-bottom: 14px; }
.label { display: block; font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px; }
.input, .select {
  width: 100%; padding: 11px 13px; font-size: 14px; font-family: var(--f-ui);
  color: var(--ink); background: #0c0f16; border: 1px solid var(--line-2); border-radius: var(--r-sm); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input.mono, input.mono { font-family: var(--f-mono); font-size: 13px; }
.input::placeholder { color: #545c70; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.select { appearance: none; -webkit-appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%236b7488' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }
.field-row { display: flex; gap: 10px; } .field-row > * { flex: 1; }
.help { font-size: 12px; color: var(--muted); margin-top: 7px; line-height: 1.5; }

/* input-group (prefix) */
.igroup { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; background: #0c0f16; transition: border-color .15s, box-shadow .15s; }
.igroup:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.igroup .pfx { display: flex; align-items: center; padding: 0 12px; font-family: var(--f-mono); font-size: 13px; color: var(--ink-dim); background: var(--panel-2); border-right: 1px solid var(--line-2); }
.igroup input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; color: var(--ink); padding: 11px 13px; font-size: 14px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(6, 8, 12, 0.66); backdrop-filter: blur(6px); display: none; align-items: flex-start; justify-content: center; padding: 7vh 16px; }
.overlay.show { display: flex; animation: fade .18s ease; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow); max-width: 440px; width: 100%; padding: 24px; animation: pop .2s cubic-bezier(.2,.8,.2,1); }
.modal.wide { max-width: 560px; }
.modal h2 { font-family: var(--f-display); font-size: 18px; margin: 0 0 16px; font-weight: 600; }
.modal .x { float: right; background: none; border: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 2px; transition: color .15s; }
.modal .x:hover { color: var(--ink); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* tabs / picker (send modal) */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; background: #0c0f16; padding: 4px; border-radius: var(--r-sm); border: 1px solid var(--line); }
.tab { flex: 1; padding: 8px; font-size: 13px; font-weight: 600; border-radius: 6px; cursor: pointer; text-align: center; color: var(--ink-dim); transition: background .15s, color .15s; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--accent); color: var(--accent-ink); }
.picklist { max-height: 230px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: 12px; background: #0c0f16; }
.pick { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 13px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line); transition: background .12s; }
.pick:last-child { border-bottom: none; }
.pick:hover { background: var(--panel-2); }
.pick.sel { background: rgba(61,220,132,.10); box-shadow: inset 2px 0 0 var(--accent); }
.pick .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .sub { color: var(--muted); font-family: var(--f-mono); font-size: 11px; white-space: nowrap; }
.picklist .hint { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; }
.selbar { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.selbar b { color: var(--ink); }
.msg { font-size: 13px; margin-top: 10px; font-family: var(--f-mono); }
.ok { color: var(--accent); } .err { color: var(--rose); }

/* empty */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-family: var(--f-display); font-size: 17px; color: var(--ink-dim); margin-bottom: 6px; }

/* staggered load */
.rise { opacity: 0; animation: rise .5s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* responsive */
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 14px; overflow-x: auto; }
  .sidebar .nav { flex-direction: row; }
  .nav-label, .side-foot { display: none; }
  .nav a.active::before { display: none; }
  .content { padding: 20px 16px 48px; } .topbar { padding: 16px; }
}
