/* ===================== Exvisit Control Center ===================== */
:root {
  --bg: #0a0e14;
  --bg-2: #0f1520;
  --panel: #121a27;
  --panel-2: #16202f;
  --border: #223145;
  --border-soft: #1a2636;
  --text: #e6edf5;
  --text-dim: #8ea0b7;
  --muted: #5f7288;
  --accent: #4f8cff;
  --accent-2: #6ea8ff;
  --green: #3fb980;
  --amber: #e0a53b;
  --red: #e5484d;
  --purple: #a06bff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--accent-2); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: .15s ease; color: var(--text); background: var(--panel-2);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff; box-shadow: 0 4px 14px rgba(79,140,255,.35); }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(79,140,255,.45); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-danger { background: transparent; border-color: rgba(229,72,77,.4); color: #ff8b8f; }
.btn-danger:hover { background: rgba(229,72,77,.12); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; }
.icon-btn:hover { color: var(--text); }

input, select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px;
  font-size: 13px; font-family: inherit; outline: none; transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }
.input-sm { width: 220px; padding: 7px 11px; font-size: 12px; }
label { display: block; font-size: 12px; color: var(--text-dim); font-weight: 600; margin: 14px 0 6px; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-2), var(--purple));
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 18px;
  box-shadow: 0 4px 14px rgba(110,168,255,.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: var(--muted); }

/* ---------- login ---------- */
.login-screen { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #182236 0%, var(--bg) 60%); }
.login-card { width: 360px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px 28px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.login-err { color: #ff8b8f; font-size: 12.5px; min-height: 16px; margin: 12px 0 0; text-align: center; }
#login-btn { margin-top: 20px; }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 4px 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: none;
  background: none; color: var(--text-dim); font-size: 13.5px; font-weight: 600;
  border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; text-align: left; transition: .12s;
}
.nav-item .ni { font-size: 14px; width: 18px; text-align: center; opacity: .8; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(79,140,255,.16), rgba(79,140,255,.04)); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { border-top: 1px solid var(--border-soft); padding-top: 14px; display: flex; align-items: center; justify-content: space-between; }
.who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }
.who .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }

.main { flex: 1; padding: 26px 30px; max-width: 1220px; width: 100%; margin: 0 auto; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.view-head h1 { font-size: 22px; margin: 0 0 3px; letter-spacing: -.3px; }
.view-head p { margin: 0; color: var(--muted); font-size: 13px; }
.head-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.card + .card, .grid-2 + .card { margin-top: 18px; }
.card-head { padding: 15px 18px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 700; }
.card-body { padding: 16px 18px; }
.card-body.p0 { padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 820px) { .kpi-row { grid-template-columns: repeat(2,1fr); } }
.kpi { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px 18px; }
.kpi .k-val { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.kpi .k-lbl { font-size: 12px; color: var(--muted); margin-top: 3px; text-transform: uppercase; letter-spacing: .4px; }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .k-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 15px; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.list-row:last-child { border-bottom: none; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-main b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .lr-sub { color: var(--muted); font-size: 12px; }
.list-row .lr-time { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.empty { padding: 26px 18px; text-align: center; color: var(--muted); font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  font-weight: 700; font-size: 12px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--purple)); }

/* ---------- alerts ---------- */
.alert-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.alert-item:last-child { border-bottom: none; }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.a-amber { background: var(--amber); } .a-red { background: var(--red); } .a-blue { background: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th { text-align: left; padding: 12px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); border-bottom: 1px solid var(--border); font-weight: 700; white-space: nowrap; }
.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl tbody tr.clickable { cursor: pointer; }
.u-cell { display: flex; align-items: center; gap: 10px; }
.u-cell .u-meta b { display: block; font-weight: 600; }
.u-cell .u-meta span { color: var(--muted); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.key-chip { display: inline-flex; align-items: center; gap: 6px; }
.copy-btn { cursor: pointer; color: var(--muted); font-size: 12px; border: none; background: none; }
.copy-btn:hover { color: var(--accent-2); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .2px; }
.badge-green { background: rgba(63,185,128,.14); color: #57d39b; }
.badge-red { background: rgba(229,72,77,.14); color: #ff8b8f; }
.badge-gray { background: rgba(143,160,183,.12); color: var(--text-dim); }
.badge-blue { background: rgba(79,140,255,.14); color: var(--accent-2); }
.badge-amber { background: rgba(224,165,59,.14); color: var(--amber); }
.pill-yes { color: #57d39b; } .pill-no { color: var(--muted); }

/* ---------- provider cards ---------- */
.prov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.prov { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 18px; transition: border-color .15s; }
.prov.on { border-color: rgba(63,185,128,.35); }
.prov-top { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.prov-logo { width: 38px; height: 38px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--border); display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.prov-name { font-weight: 700; font-size: 15px; }
.prov-auth { font-size: 11.5px; color: var(--muted); }
.prov-meta { display: flex; gap: 16px; margin: 12px 0; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.prov-meta b { color: var(--text); }
.prov-url { font-family: var(--mono); font-size: 11.5px; color: var(--muted); word-break: break-all; }
.prov-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.prov-config { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--border); border-radius: 20px; transition: .2s; cursor: pointer; }
.switch .track:before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track:before { transform: translateX(18px); }

/* ---------- subtabs ---------- */
.subtabs { display: flex; gap: 4px; background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 4px; width: fit-content; margin-bottom: 18px; }
.subtab { border: none; background: none; color: var(--text-dim); padding: 7px 16px; border-radius: 6px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-family: inherit; }
.subtab.active { background: var(--panel-2); color: var(--text); }
.cards-col { display: flex; flex-direction: column; gap: 12px; }
.dcard { background: var(--panel); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px 18px; }
.dcard-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.dcard-head b { font-size: 13.5px; }
.dcard-body { font-size: 13px; color: var(--text-dim); white-space: pre-wrap; word-break: break-word; }
.dcard pre { background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 11.5px; color: var(--text-dim); margin: 8px 0 0; max-height: 220px; }

/* ---------- drawer ---------- */
.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; background: rgba(4,7,12,.6); backdrop-filter: blur(2px); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; width: 440px; max-width: 92vw; height: 100vh; background: var(--panel); border-left: 1px solid var(--border); z-index: 50; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.drawer-head, .modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.drawer-head h3, .modal-head h3 { margin: 0; font-size: 16px; }
.drawer-body { padding: 20px; overflow-y: auto; }
.field-block { background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 14px; }
.field-block h4 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent-2); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 13px; }
.kv span { color: var(--muted); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .tr-t { font-size: 13px; font-weight: 600; }
.toggle-row .tr-d { font-size: 11.5px; color: var(--muted); }

/* ---------- modal ---------- */
.modal-backdrop { display: grid; place-items: center; }
.modal { width: 440px; max-width: 94vw; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.modal-body { padding: 8px 22px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border-soft); }
.hint { font-size: 12px; color: var(--muted); margin: 14px 0 0; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 12px 20px;
  border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); z-index: 100; transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(229,72,77,.5); color: #ff8b8f; }

.spinner { text-align: center; color: var(--muted); padding: 30px; font-size: 13px; }

/* ---------- Plans editor ---------- */
.plan-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.plan-fields label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.plan-fields input { width: 100%; }
.plan-models-head { margin-top: 14px; font-size: 12px; font-weight: 600; color: var(--muted); }
.plan-models { margin-top: 8px; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.plan-model { display: flex; align-items: center; gap: 8px; font-size: 12px; cursor: pointer; }
.plan-model em { color: var(--muted); font-style: normal; font-size: 11px; margin-left: 4px; }

/* ---------- Routing editor ---------- */
.routes { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.route-row { display: flex; align-items: center; gap: 8px; }
.route-pri { font-size: 10px; color: var(--muted); min-width: 64px; text-transform: uppercase; letter-spacing: .04em; }
.route-row select { flex: 1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
