:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --sidebar: #141b24;
  --header: #121820;
  --line: #2a3544;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3d9cf0;
  --accent-dim: #2a6fad;
  --ok: #3ecf8e;
  --err: #f07178;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --header-h: 56px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 0% 0%, #1c3a5a 0%, transparent 50%),
    var(--bg);
}

[hidden] { display: none !important; }

.brand {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand span { color: var(--accent); font-weight: 500; }

/* ---- Sign-in gate ---- */
.gate-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.panel.signin {
  width: min(100%, 400px);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.35rem 1.25rem 1.4rem;
}
.panel.signin .brand { font-size: 1.45rem; margin-bottom: 0.35rem; }

/* ---- App shell: header + sidebar ---- */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem 0 0.85rem;
  background: color-mix(in srgb, var(--header) 96%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
}
.user-chip {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 1rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.nav-label {
  margin: 0 0.55rem 0.4rem;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.nav-item {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
}
.nav-item:hover {
  color: var(--text);
  background: #1a2430;
}
.nav-item.active {
  color: var(--text);
  background: #1e2a38;
  border-color: var(--line);
}

.content {
  flex: 1;
  min-width: 0;
  padding: 1.25rem 1.5rem 2.5rem;
  overflow: auto;
}

.view { display: none; max-width: 820px; }
.view.active { display: block; }

.panel {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.15rem 1.2rem 1.3rem;
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.75rem; }
label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.55rem 0 0.25rem;
}
input, textarea, button { font: inherit; }
input, textarea {
  width: 100%;
  background: #121820;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
input:focus, textarea:focus {
  outline: 1px solid var(--accent-dim);
  border-color: var(--accent-dim);
}
.row { display: flex; gap: 0.5rem; align-items: center; }
.row.between { justify-content: space-between; align-items: center; }
button {
  background: #243041;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { border-color: var(--accent-dim); }
button.primary {
  margin-top: 0.85rem;
  background: var(--accent-dim);
  border-color: var(--accent);
}
.status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: #121820;
  border: 1px solid var(--line);
  font-family: var(--mono);
  white-space: pre-wrap;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.status.muted { color: var(--muted); }
.out {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  background: #121820;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  min-height: 2.5rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.table-wrap { overflow-x: auto; margin-top: 0.5rem; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
th, td {
  text-align: left;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 500; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 0.18s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.35);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 1rem; }
  .user-chip { max-width: 140px; }
}
