:root {
  --bg: #080e17;
  --panel: #101b2a;
  --panel2: #132135;
  --line: #213047;
  --text: #f0f4fa;
  --muted: #8e9db0;
  --gold: #e7bc69;
  --cyan: #58d7ce;
  --green: #69dda6;
  --red: #ff879b;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 1px solid #38516c;
  border-radius: 8px;
  padding: 10px 15px;
  background: #17344a;
  color: #eaf3fc;
  font-weight: 600;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

button:hover {
  background: #24516b;
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

button.primary {
  background: var(--gold);
  color: #111827;
  border-color: #d4a752;
  font-weight: 700;
}

button.primary:hover {
  background: #f2cb7c;
}

button.danger {
  background: #572936;
  border-color: #9a4d5d;
  color: #ffe8ec;
}

button.small-btn {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 6px;
}

button.active-mode {
  background: #193b38;
  border-color: var(--cyan);
  color: var(--cyan);
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  display: grid;
  grid-template-columns: 235px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  background: #0b1320;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 2px;
  font-size: 11px;
}

.brand b {
  display: block;
  font-size: 19px;
  letter-spacing: 3px;
  color: var(--gold);
  margin-top: 2px;
}

.brand-logo {
  width: 48px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(231, 188, 105, 0.25));
}

.workspace-label {
  color: #667790;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.6px;
  margin: 16px 0 8px;
  padding: 0 8px;
}

nav {
  display: grid;
  gap: 6px;
}

nav a {
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

nav a.selected, nav a:hover {
  background: #16283c;
  color: var(--cyan);
}

.nav-icon {
  width: 20px;
  text-align: center;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #c5cfdd;
}

.link-button {
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
}

main {
  max-width: 1600px;
  width: 100%;
  padding: 32px 36px;
  min-width: 0;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--gold);
  margin: 0 0 8px;
}

h1 {
  font-size: 26px;
  line-height: 1.28;
  letter-spacing: -0.5px;
  margin: 0;
  font-weight: 650;
}

h1 span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 400;
}

.header-right {
  text-align: right;
  font-size: 11px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.dot, .live-pill i {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--cyan);
  border-radius: 50%;
  margin-right: 6px;
  box-shadow: 0 0 8px var(--cyan);
}

.wave-banner {
  border: 1px solid #28534f;
  border-radius: 12px;
  background: radial-gradient(ellipse at 90% 0%, #214d4a 0%, transparent 60%), #112323;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 26px;
  margin-bottom: 20px;
  gap: 20px;
}

.live-pill {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
}

.wave-banner h2 {
  font-size: 20px;
  margin: 10px 0 6px;
  font-weight: 600;
}

.wave-banner p {
  margin: 0;
  color: #a8bebb;
  font-size: 12px;
  max-width: 760px;
  line-height: 1.55;
}

.wave-direction {
  text-align: right;
  padding-left: 16px;
}

.wave-direction > span {
  font-size: 34px;
  font-weight: 700;
  color: var(--gold);
}

.wave-direction small {
  display: block;
  color: #9eb6b1;
  font-size: 9px;
  letter-spacing: 1.3px;
  margin-top: 4px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metrics article, .panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
}

.metrics article {
  padding: 18px 20px;
}

.metrics p {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1px;
  margin: 0 0 10px;
}

.metrics strong {
  display: block;
  font-size: 28px;
  font-weight: 650;
}

.metrics small {
  display: block;
  font-size: 11px;
  color: #7d92ab;
  margin-top: 8px;
}

.up { color: var(--green) !important; }
.down { color: var(--red) !important; }

.two-columns {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 18px;
}

.panel {
  padding: 22px 24px;
  margin-bottom: 20px;
  min-width: 0;
}

.panel h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 10px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.badge {
  display: inline-block;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 10px;
  letter-spacing: 0.8px;
  color: var(--gold);
  background: #132235;
  white-space: nowrap;
}

.muted {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 14px;
}

.cockpit-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.config-inline-form {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.form-grid label {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.form-grid input, #webhook-url {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: #0c1624;
  color: var(--text);
  border: 1px solid #30425b;
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 12px;
}

#webhook-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--cyan);
}

.notice {
  font-size: 12px;
  line-height: 1.55;
  color: #d6e4f5;
  padding: 12px 16px;
  background: #172a3e;
  border: 1px solid #2f4d6d;
  border-radius: 8px;
  margin-bottom: 18px;
}

.notice.error {
  color: #ffb7bf;
  background: #371d27;
  border-color: #793647;
}

.notice.success {
  color: #b8f5d8;
  background: #13332a;
  border-color: #266b54;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  text-align: left;
  font-size: 12px;
}

th {
  color: #7890aa;
  font-size: 10px;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 13px 10px;
  border-bottom: 1px solid #182638;
  vertical-align: middle;
}

tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.empty {
  padding: 28px 12px;
  text-align: center;
  color: #788ca5;
  font-size: 12px;
}

.pill {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 5px;
  display: inline-block;
  background: #203248;
  color: #a9bbd2;
}

.pill.long, .pill.ok {
  background: #173c31;
  color: var(--green);
}

.pill.short, .pill.err {
  background: #402632;
  color: var(--red);
}

.pill.warn {
  background: #3d3319;
  color: var(--gold);
}

.tp-list {
  font-size: 11px;
  color: #bfd0e6;
  line-height: 1.4;
}

details {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 600;
}

details p {
  line-height: 1.65;
  margin: 8px 0 0;
}

footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 0;
  color: #63788e;
  font-size: 11px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}

/* Modal Cornix */
dialog#cornix-modal {
  width: min(560px, 92vw);
  border: 1px solid #38516c;
  border-radius: 12px;
  background: #0f1b2a;
  color: var(--text);
  padding: 20px;
}

dialog#cornix-modal::backdrop {
  background: rgba(5, 10, 18, 0.78);
}

dialog#cornix-modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

dialog#cornix-modal h3 {
  margin: 0;
  font-size: 16px;
  color: var(--gold);
}

dialog#cornix-modal pre {
  background: #08111c;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--cyan);
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Login Page */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 0%, #18333c, transparent 65%), var(--bg);
  padding: 24px;
}

.login-card {
  max-width: 420px;
  width: 100%;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #101a29;
  text-align: center;
}

.login-logo {
  width: 115px;
  height: 125px;
  object-fit: contain;
  margin: 0 auto 14px;
  display: block;
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.login-card form {
  margin-top: 22px;
  text-align: left;
}

.login-card label {
  display: block;
  font-size: 12px;
  color: #a9b7c9;
  margin-bottom: 14px;
}

.login-card input {
  display: block;
  width: 100%;
  font-size: 14px;
  padding: 11px 12px;
  margin-top: 6px;
  background: #0c1624;
  color: var(--text);
  border: 1px solid #30425b;
  border-radius: 6px;
}

.login-card .primary {
  width: 100%;
  padding: 13px 16px;
  margin-top: 8px;
  font-size: 13px;
}

.fine {
  font-size: 11px;
  color: #74879e;
  margin-top: 18px;
}

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .two-columns { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
