/* Nexus Atlas — application shell styles.
   Renderer families: Compact / Standard / Explorer (data-renderer on <body>).
   Spatial is a separate renderer entry and is not styled here. */

:root {
  --bg: #05080d;
  --bg-2: #070c12;
  --panel: #0c131b;
  --panel-2: #101a25;
  --line: #26394b;
  --line-2: #1b2b3a;
  --fg: #eef6ff;
  --muted: #8ca0b5;
  --accent: #59c8ff;
  --accent-2: #7ef0c0;
  --warn: #ffcf6b;
  --danger: #ff7a86;
  --ok: #7ef0c0;
  --radius: 14px;
  --gap: 16px;
  --sidebar-w: 280px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 70% -10%, #0b1a28 0%, var(--bg) 55%) fixed;
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100; background: var(--accent);
  color: #04121c; padding: 8px 12px; border-radius: 0 0 8px 0; font-weight: 700;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.atlas-header {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: rgba(7,12,18,.92);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 26px; color: var(--accent); line-height: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text small { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.global-search { margin-left: auto; display: flex; gap: 6px; flex: 1 1 380px; max-width: 520px; }
.global-search input {
  flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--fg);
  padding: 8px 12px; border-radius: 10px;
}
.header-meta { display: flex; align-items: center; gap: 12px; }
.status-chip {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 20px; padding: 5px 10px; white-space: nowrap;
}
.status-chip[data-state="ok"] { color: var(--ok); border-color: #26614c; }
.status-chip[data-state="warn"] { color: var(--warn); border-color: #6b5620; }
.icon-btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 16px; line-height: 1;
}
.btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg);
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #10344a; border-color: #2f7fa8; }
.btn-danger { border-color: #6b2a33; color: var(--danger); }

/* ---------- Root nav ---------- */
.root-nav {
  display: flex; gap: 6px; padding: 8px 16px; overflow-x: auto;
  background: var(--bg-2); border-bottom: 1px solid var(--line-2);
  position: sticky; top: 57px; z-index: 20;
}
.root-nav a {
  color: var(--fg); padding: 7px 12px; border-radius: 10px; white-space: nowrap;
  border: 1px solid transparent; font-size: 14px;
}
.root-nav a:hover { background: var(--panel-2); text-decoration: none; }
.root-nav a[aria-current="page"] { background: #10344a; border-color: #2f7fa8; }

/* ---------- Layout ---------- */
.atlas-body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; align-items: start; }
body[data-sidebar="collapsed"] .atlas-body { grid-template-columns: 0 1fr; }
body[data-sidebar="collapsed"] .sidebar { display: none; }
.sidebar {
  padding: 14px; border-right: 1px solid var(--line-2);
  position: sticky; top: 104px; max-height: calc(100vh - 104px); overflow: auto;
}
.sidebar h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 4px 6px 8px; }
.sidebar .root-block { margin-bottom: 14px; }
.sidebar .root-link { display: block; font-weight: 600; padding: 6px 8px; border-radius: 8px; color: var(--fg); }
.sidebar .root-link:hover { background: var(--panel-2); text-decoration: none; }
.sidebar ul { list-style: none; margin: 2px 0 0; padding: 0 0 0 10px; }
.sidebar li a { display: block; padding: 5px 8px; border-radius: 8px; color: var(--muted); font-size: 13.5px; }
.sidebar li a:hover { background: var(--panel-2); color: var(--fg); text-decoration: none; }
.sidebar li a[aria-current="page"] { color: var(--fg); background: #10344a; }
.sidebar .locked { opacity: .45; cursor: not-allowed; }

.main { padding: 20px 24px 60px; min-width: 0; }
.page-head { margin-bottom: 14px; }
.breadcrumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.breadcrumbs a { color: var(--muted); }
.page-head-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head-row h1 { font-size: 22px; margin: 0; }
.page-badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Badges / chips ---------- */
.badge {
  font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; color: var(--muted);
}
.badge[data-kind="readonly"] { color: var(--accent-2); border-color: #26614c; }
.badge[data-kind="pending"] { color: var(--warn); border-color: #6b5620; }
.badge[data-kind="integrated"] { color: var(--ok); border-color: #26614c; }
.badge[data-kind="blocked"], .badge[data-kind="danger"] { color: var(--danger); border-color: #6b2a33; }
.badge[data-kind="neutral"] { color: var(--muted); }

/* ---------- Panels / cards ---------- */
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 16px; margin-bottom: var(--gap); }
.panel h2, .panel h3 { margin-top: 0; }
.muted { color: var(--muted); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card {
  display: block; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2); padding: 14px; color: var(--fg); min-height: 96px;
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 700; }

/* ---------- Home radial ---------- */
.home-map { position: relative; min-height: 460px; border: 1px solid var(--line); border-radius: var(--radius); background: #0a1119; overflow: hidden; }
.home-orbit { position: absolute; width: min(420px, 70vw); height: min(420px, 70vw); border: 1px solid var(--line-2); border-radius: 50%; left: 50%; top: 50%; transform: translate(-50%,-50%); }
.home-core { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 120px; height: 120px; border: 1px solid var(--accent); border-radius: 50%; display: grid; place-items: center; text-align: center; background: #0a1520; z-index: 2; }
.home-node { position: absolute; transform: translate(-50%,-50%); width: 148px; border: 1px solid var(--line); border-radius: 12px; background: #10202d; color: var(--fg); padding: 8px; z-index: 3; text-align: center; }
.home-node:hover { border-color: var(--accent); text-decoration: none; }
.home-node small { color: var(--muted); display: block; font-size: 11px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line-2); padding: 9px 12px; text-align: left; font-size: 13.5px; vertical-align: top; }
th { color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; position: sticky; top: 0; background: var(--panel); }
tbody tr:hover { background: #0e1720; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg);
  padding: 7px 10px; border-radius: 9px;
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button {
  background: transparent; border: 1px solid transparent; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 7px 12px; cursor: pointer; border-radius: 8px 8px 0 0;
}
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }

/* ---------- States ---------- */
.state { border: 1px dashed var(--line); border-radius: var(--radius); padding: 22px; background: var(--panel); }
.state h2 { margin-top: 0; }
.state[data-kind="error"] { border-color: #6b2a33; }
.state[data-kind="error"] h2 { color: var(--danger); }
.state[data-kind="forbidden"] { border-color: #6b5620; }
.state[data-kind="forbidden"] h2 { color: var(--warn); }
.state[data-kind="pending"] { border-color: #6b5620; }
.state[data-kind="pending"] h2 { color: var(--warn); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-fields { margin: 10px 0; } .error-fields dt { color: var(--muted); font-size: 11px; text-transform: uppercase; } .error-fields dd { margin: 0 0 6px; }

/* ---------- Account ---------- */
.account { position: relative; }
.account > button { display: flex; align-items: center; gap: 6px; }
.account-menu { position: absolute; right: 0; top: 110%; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; z-index: 40; }
.account-menu[hidden] { display: none; }
.account-menu .who { font-weight: 600; }
.account-menu .role { color: var(--muted); font-size: 12px; margin-bottom: 8px; }

.atlas-footer { color: var(--muted); font-size: 12px; padding: 16px 24px; border-top: 1px solid var(--line-2); }

/* ---------- Compact / Standard / Explorer ---------- */
body[data-renderer="compact"] { font-size: 14px; }
body[data-renderer="compact"] .atlas-body { grid-template-columns: 1fr; }
body[data-renderer="compact"] .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: min(86vw, 320px); background: var(--bg-2); z-index: 50; max-height: 100vh; }
body[data-renderer="compact"][data-sidebar="collapsed"] .sidebar { display: none; }
body[data-renderer="compact"] .global-search { display: none; }
body[data-renderer="compact"] .home-node { width: 110px; font-size: 12px; }
body[data-renderer="compact"] .main { padding: 14px; }

body[data-renderer="explorer"] .main { padding: 24px 32px 60px; }

@media (max-width: 1100px) {
  .atlas-body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  body[data-sidebar="open"] .sidebar { display: block; position: fixed; top: 0; left: 0; bottom: 0; width: min(86vw, 320px); background: var(--bg-2); z-index: 50; }
}
@media (max-width: 640px) { .global-search { display: none; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .spinner { animation: none; border-top-color: var(--accent); }
}

@media (prefers-contrast: more) {
  :root { --line: #4a6a86; --muted: #b9c9d8; }
}
