/* Orbit Cockpit — internal super-admin console.
   Dark ops-console aesthetic. All local, no CDN, no web fonts. */

:root {
  --bg:        #1e2124;
  --bg-2:      #191c1e;
  --panel:     #24282b;
  --panel-2:   #282d30;
  --raised:    #2f3438;
  --border:    #333a3e;
  --border-2:  #414a4f;
  --text:      #e6edf3;
  --text-2:    #aeb8c7;
  --muted:     #737f92;
  --accent:    #4a90d9;
  --accent-2:  #6ba3e0;
  --accent-dim:#22344f;
  --ok:        #46c08a;
  --ok-dim:    #1c4d38;
  --warn:      #e0a23c;
  --warn-dim:  #3a2c0c;
  --danger:    #d9534f;
  --danger-dim:#3d1a1a;
  --info:      #4fb6c9;
  --shadow:    0 10px 40px rgba(0,0,0,.55);
  --radius:    9px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
code, .mono { font-family: var(--mono); font-size: .86em; }
::selection { background: var(--accent-dim); }

/* scrollbars */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #26303f; border-radius: 6px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #33404f; background-clip: padding-box; border: 3px solid transparent; }

/* ---------------- Sign in ---------------- */
.signin-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(79,125,245,.10), transparent 60%),
    radial-gradient(700px 500px at 100% 110%, rgba(79,125,245,.06), transparent 55%),
    var(--bg);
}
.signin-card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 30px 30px 26px;
}
.signin-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 4px; }
.signin-brand .logo { width: 30px; height: 30px; }
.signin-brand .tt { font-size: 16px; font-weight: 650; letter-spacing: -.02em; }
.signin-brand .sub { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .13em; }
.signin-card h1 { font-size: 20px; margin: 18px 0 4px; }
.signin-card .lede { color: var(--text-2); font-size: 13px; margin-bottom: 20px; }
.signin-warn {
  margin-top: 18px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border);
  padding-top: 14px; line-height: 1.5;
}
.signin-warn b { color: var(--warn); font-weight: 600; }
.field.remember { margin-top: 2px; }
.chk { display: flex; flex-direction: row; align-items: center; gap: 8px; cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-2); font-size: 13px; }
.chk input { width: auto; margin: 0; accent-color: var(--accent); }

/* ---------------- App shell ---------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 17px 18px 15px; border-bottom: 1px solid var(--border); }
.sidebar .brand .logo { width: 26px; height: 26px; }
.sidebar .brand .name { font-weight: 650; font-size: 14.5px; letter-spacing: -.02em; line-height: 1.1; }
.sidebar .brand .env { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.nav { padding: 10px 10px; flex: 1; overflow-y: auto; }
.nav .group-label { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); padding: 12px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500; margin: 1px 0; text-decoration: none;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-dim); color: #dbe6ff; }
.nav a.active .ico { color: var(--accent-2); }
.nav a .ico { width: 17px; height: 17px; flex: none; color: var(--muted); }
.nav a .cnt { margin-left: auto; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.sidebar .foot { border-top: 1px solid var(--border); padding: 12px 14px; font-size: 12px; }
.sidebar .foot .who { color: var(--text-2); word-break: break-all; margin-bottom: 8px; }
.sidebar .foot .who .dot { display:inline-block; width:7px; height:7px; border-radius:50%; background: var(--ok); margin-right:6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 26px;
  border-bottom: 1px solid var(--border); background: rgba(13,17,23,.85); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 17px; }
.topbar .crumb { color: var(--muted); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.topbar .env-pill {
  font-family: var(--mono); font-size: 11px; color: var(--text-2); background: var(--panel);
  border: 1px solid var(--border); padding: 4px 9px; border-radius: 6px; max-width: 300px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.view { padding: 22px 26px 60px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 13px; font-weight: 550;
  padding: 7px 13px; border-radius: 7px; border: 1px solid var(--border-2); background: var(--raised);
  color: var(--text); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: #222a3a; border-color: #3a475c; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { background: var(--danger-dim); border-color: #5a2626; color: #ffb4ae; }
.btn.danger:hover { background: #4a1f1f; border-color: #7a3232; }
.btn.warn { background: var(--warn-dim); border-color: #5a4712; color: #f2cd6a; }
.btn.warn:hover { background: #473710; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn.ghost:hover { background: var(--panel); color: var(--text); }
.btn .ico { width: 15px; height: 15px; }

/* ---------------- Inputs ---------------- */
.field { display: block; margin-bottom: 15px; }
.field > label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 6px; font-weight: 550; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number],
select, textarea {
  width: 100%; font: inherit; font-size: 13px; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--border-2); border-radius: 7px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,125,245,.16); }
textarea { resize: vertical; min-height: 78px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23737f92' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; }

.searchbar { position: relative; max-width: 360px; flex: 1; }
.searchbar input { padding-left: 32px; }
.searchbar .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }

/* ---------------- Panels / cards ---------------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.panel-h h3 { font-size: 13.5px; }
.panel-h .sub { color: var(--muted); font-size: 12px; }
.panel-h .spacer { flex: 1; }
.panel-b { padding: 16px; }

.grid { display: grid; gap: 16px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; }
.tile .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 7px; }
.tile .k .ico { width: 15px; height: 15px; }
.tile .v { font-size: 30px; font-weight: 650; letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.tile .v small { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.tile.accent { border-color: var(--accent-dim); background: linear-gradient(180deg, rgba(79,125,245,.07), transparent 70%), var(--panel); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 10px 14px; background: var(--bg-2); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; white-space: nowrap;
}
table.data tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--panel-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }
table.data td.mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
table.data .primary-cell { font-weight: 600; color: var(--text); }
table.data .sub-cell { color: var(--muted); font-size: 11.5px; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px; text-transform: capitalize; letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok, .badge.active { color: #7ee2a0; background: var(--ok-dim); border-color: #1c5030; }
.badge.warn, .badge.suspended, .badge.unknown { color: #f2cd6a; background: var(--warn-dim); border-color: #5a4712; }
.badge.danger, .badge.down, .badge.closed, .badge.revoked { color: #ffb4ae; background: var(--danger-dim); border-color: #5a2626; }
.badge.neutral { color: var(--text-2); background: var(--raised); border-color: var(--border-2); }
.badge.plan { color: #bcd0ff; background: var(--accent-dim); border-color: #2f4470; text-transform: none; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 3px 9px; border-radius: 6px; background: var(--raised); border: 1px solid var(--border-2); color: var(--text-2); font-family: var(--mono); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------------- Empty / loading / error ---------------- */
.state { text-align: center; color: var(--muted); padding: 46px 20px; font-size: 13px; }
.state .ico { width: 30px; height: 30px; margin: 0 auto 12px; display: block; opacity: .6; }
.skeleton { background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.errbox { background: var(--danger-dim); border: 1px solid #5a2626; color: #ffc9c4; padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.okbox { background: var(--ok-dim); border: 1px solid #1c5030; color: #a6ecbf; padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* ---------------- Charts (hand-rolled SVG) ---------------- */
.chart svg { display: block; width: 100%; height: auto; }
.chart .bar-row { display: grid; grid-template-columns: 130px 1fr 56px; align-items: center; gap: 12px; margin: 9px 0; font-size: 12.5px; }
.chart .bar-row .label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart .bar-track { height: 9px; background: var(--bg-2); border-radius: 5px; overflow: hidden; }
.chart .bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 5px; }
.chart .bar-val { text-align: right; font-family: var(--mono); font-size: 12px; color: var(--text); }

/* ---------------- Toggle switch ---------------- */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--raised); border: 1px solid var(--border-2); border-radius: 22px; transition: .16s; cursor: pointer; }
.switch .track::before { content: ""; position: absolute; left: 3px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: .16s; }
.switch input:checked + .track { background: var(--accent-dim); border-color: var(--accent); }
.switch input:checked + .track::before { transform: translateX(18px); background: var(--accent-2); }
.switch input:disabled + .track { opacity: .5; cursor: not-allowed; }

/* ---------------- Drawer ---------------- */
.overlay { position: fixed; inset: 0; background: rgba(4,6,10,.6); backdrop-filter: blur(2px); z-index: 40; opacity: 0; animation: fade .15s forwards; }
@keyframes fade { to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(760px, 94vw); background: var(--bg-2);
  border-left: 1px solid var(--border); box-shadow: var(--shadow); z-index: 41; display: flex; flex-direction: column;
  transform: translateX(100%); animation: slidein .2s forwards;
}
@keyframes slidein { to { transform: translateX(0); } }
.drawer-h { display: flex; align-items: flex-start; gap: 14px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-h .close { margin-left: auto; }
.drawer-b { overflow-y: auto; padding: 20px 22px 50px; flex: 1; }
.drawer-title { font-size: 19px; letter-spacing: -.02em; }
.drawer-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 11px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); font-family: var(--mono); font-size: 12.5px; }

/* ---------------- Modal ---------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(4,6,10,.62); z-index: 60; display: grid; place-items: center; padding: 20px; opacity: 0; animation: fade .12s forwards; }
.modal { width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.modal-h { padding: 18px 20px 4px; }
.modal-h h3 { font-size: 16px; }
.modal-b { padding: 8px 20px 18px; color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.modal-b strong { color: var(--text); }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; background: var(--bg-2); border-top: 1px solid var(--border); }

/* ---------------- Toast ---------------- */
#toast-root { position: fixed; top: 16px; right: 16px; z-index: 80; display: flex; flex-direction: column; gap: 9px; }
.toast { display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 14px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 13px; animation: toastin .18s; }
@keyframes toastin { from { transform: translateX(20px); opacity: 0; } }
.toast.ok { border-color: #1c5030; } .toast.ok .ico { color: var(--ok); }
.toast.err { border-color: #5a2626; } .toast.err .ico { color: var(--danger); }
.toast.info .ico { color: var(--info); }
.toast .ico { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.toast .msg { flex: 1; color: var(--text); word-break: break-word; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 260px; }
.between { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mt16 { margin-top: 16px; }
.mb16 { margin-bottom: 16px; }

@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar .brand { border-bottom: none; border-right: 1px solid var(--border); }
  .nav { display: flex; padding: 6px; }
  .nav .group-label { display: none; }
  .sidebar .foot { display: none; }
  .view { padding: 16px; }
}
