:root {
  --bg: #0b0e11;
  --panel: #151a21;
  --panel-soft: #1e2329;
  --panel-elevated: #242a32;
  --line: rgba(240, 185, 11, 0.12);
  --line-strong: rgba(240, 185, 11, 0.3);
  --text: #f5f5f5;
  --text-soft: #b7bdc6;
  --text-dim: #848e9c;
  --accent: #f0b90b;
  --accent-strong: #f8d12f;
  --success: #02c076;
  --error: #f6465d;
  --warning: #f0b90b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(240, 185, 11, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(240, 185, 11, 0.08), transparent 20%),
    linear-gradient(180deg, #0b0e11 0%, #101419 48%, #0c1015 100%);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(240, 185, 11, 0.9);
  background: rgba(255, 255, 255, 0.05);
}
select option { color: #111; }

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-soft);
  font-size: 14px;
}
label > span { color: var(--text-soft); font-weight: 600; }

.primary-button,
.ghost-button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 12px 18px;
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.primary-button {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #1b1f24;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(240, 185, 11, 0.24);
}
.primary-button:hover { transform: translateY(-1px); }
.ghost-button,
.link-button {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.small-button { padding: 9px 14px; font-size: 13px; }
.full-width { width: 100%; }

.alert-banner {
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  font-weight: 600;
}
.alert-banner.success {
  background: rgba(2, 192, 118, 0.12);
  border-color: rgba(2, 192, 118, 0.4);
  color: #b4f1d0;
}
.alert-banner.error {
  background: rgba(246, 70, 93, 0.12);
  border-color: rgba(246, 70, 93, 0.4);
  color: #ffd0d6;
}

.app-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.app-sidebar {
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(18, 22, 28, 0.98), rgba(11, 14, 17, 0.98));
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}
.brand-mark { display: flex; gap: 14px; align-items: center; }
.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--accent), #ffde6a);
  color: #161a1f;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
}
.brand-title { font-size: 18px; font-weight: 700; }
.brand-subtitle { color: var(--text-dim); font-size: 12px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 8px; }
.sidebar-link {
  display: block;
  padding: 14px 16px;
  border-radius: 14px;
  color: var(--text-soft);
  font-weight: 600;
}
.sidebar-link:hover, .sidebar-link.active {
  background: linear-gradient(135deg, rgba(240, 185, 11, 0.16), rgba(240, 185, 11, 0.05));
  color: var(--text);
}
.sidebar-footnote {
  margin-top: auto;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  line-height: 1.6;
  font-size: 13px;
}

.app-main { padding: 30px 36px 40px; }
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 26px;
}
.header-kicker, .panel-kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 8px;
}
.header-title {
  margin: 0;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.1;
}
.header-actions { display: flex; align-items: center; gap: 12px; }
.page-body { display: flex; flex-direction: column; gap: 22px; }

.hero-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.compact-hero { margin-bottom: 0; }
.stat-card, .panel, .help-card, .symbol-guide-card {
  background: linear-gradient(180deg, rgba(29, 33, 40, 0.96), rgba(20, 24, 31, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.stat-card { padding: 22px; }
.accent-card {
  background: linear-gradient(135deg, rgba(240, 185, 11, 0.2), rgba(31, 35, 41, 0.98));
  border-color: rgba(240, 185, 11, 0.22);
}
.stat-label { color: var(--text-soft); font-size: 14px; margin-bottom: 10px; }
.stat-value { font-size: clamp(24px, 3vw, 38px); font-weight: 700; line-height: 1.1; }
.small-value { font-size: 18px; }
.stat-meta { margin-top: 10px; color: var(--text-dim); line-height: 1.6; }

.panel { padding: 24px; }
.panel-spacious { padding: 28px; }
.inset-panel { margin-top: 22px; background: rgba(255,255,255,0.02); box-shadow: none; }
.panel-header, .subsection-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.panel-header h2, .subsection-header h3 { margin: 0; font-size: 28px; }
.section-caption, .footnote-block p, .cell-note, .rule-definition p, .symbol-guide-card p, .help-card p {
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0;
}
.compact-note p { max-width: 360px; }
.footnote-block { display: flex; flex-direction: column; gap: 6px; }

.form-grid { display: grid; gap: 18px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack-form { display: flex; flex-direction: column; gap: 22px; }
.compact-form { gap: 18px; }
.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
}
.slim-footer { margin-top: 20px; }
.inline-form-grid {
  display: grid;
  gap: 12px;
  align-items: center;
}
.webhook-grid { grid-template-columns: 1.1fr 2fr 0.7fr 0.7fr 1.2fr auto; }
.password-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
.create-grid { margin-top: 18px; }
.inline-actions { display: flex; gap: 8px; }

.table-shell {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
  background: rgba(255, 255, 255, 0.01);
}
.data-table thead {
  background: rgba(255,255,255,0.02);
}
.data-table th, .data-table td {
  padding: 16px 14px;
  vertical-align: top;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  text-align: left;
}
.data-table th {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.empty-cell, .nested-form-cell { color: var(--text-dim); }
.nested-form-cell { padding: 14px !important; }
.action-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-link { color: var(--accent-strong); font-weight: 600; }

.status-chip, .pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}
.status-chip.success { background: rgba(2, 192, 118, 0.18); color: #93efc1; }
.status-chip.error { background: rgba(246, 70, 93, 0.18); color: #ffbcc5; }
.status-chip.pending { background: rgba(255,255,255,0.08); color: var(--text-soft); }
.pill-dark { background: rgba(255,255,255,0.08); color: var(--text); }

.rule-editor-table input,
.rule-editor-table select { min-width: 120px; }
.rule-row .rule-definition { min-width: 260px; }
.rule-row .rule-definition strong { display: block; margin-bottom: 6px; }
.rule-field-help-grid, .symbol-guide-grid, .health-grid {
  display: grid;
  gap: 14px;
}
.rule-field-help-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.symbol-guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.help-card, .symbol-guide-card { padding: 16px; }
.help-card h4, .symbol-guide-card h4 { margin: 0 0 8px; }
.code-block {
  padding: 18px;
  background: #0a0d12;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.06);
  color: #dce2ea;
  overflow: auto;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.login-layout {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 28px;
  align-items: stretch;
}
.login-aside, .login-card {
  border-radius: 28px;
  padding: 34px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow);
}
.login-aside {
  background:
    linear-gradient(135deg, rgba(240, 185, 11, 0.14), rgba(17, 21, 28, 0.96)),
    linear-gradient(180deg, rgba(29, 33, 40, 0.96), rgba(20, 24, 31, 0.98));
}
.login-brand { color: var(--accent); text-transform: uppercase; letter-spacing: 0.18em; font-size: 12px; margin-bottom: 10px; }
.login-aside h1 { margin: 0 0 14px; font-size: clamp(34px, 4vw, 54px); line-height: 1.02; }
.login-aside p { color: var(--text-soft); line-height: 1.7; }
.feature-list { margin: 24px 0 0; padding-left: 18px; color: var(--text-soft); display: grid; gap: 10px; }
.login-card { background: rgba(18, 23, 29, 0.98); align-self: center; }
.login-card h2 { margin: 0 0 18px; font-size: 30px; }

@media (max-width: 1200px) {
  .rule-field-help-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar { border-right: 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
}

@media (max-width: 860px) {
  .app-main { padding: 24px 18px 32px; }
  .two-columns, .symbol-guide-grid, .health-grid, .password-grid, .webhook-grid, .create-grid, .login-layout {
    grid-template-columns: 1fr;
  }
  .form-footer, .panel-header, .subsection-header, .app-header {
    flex-direction: column;
    align-items: stretch;
  }
  .data-table { min-width: 760px; }
}
