:root {
  --bg: #0d1211;
  --surface: rgba(24, 31, 29, .92);
  --surface-2: #202927;
  --line: rgba(255, 255, 255, .09);
  --text: #f3f6f1;
  --muted: #98a49f;
  --lime: #c7ff63;
  --lime-dark: #18220c;
  --orange: #ffb35c;
  --red: #ff6f71;
  --blue: #72b7ff;
  --radius: 22px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ambient { position: fixed; width: 430px; height: 430px; border-radius: 50%; filter: blur(120px); opacity: .12; pointer-events: none; }
.ambient-one { background: var(--lime); top: -180px; right: -100px; }
.ambient-two { background: #3d75ff; bottom: -220px; left: 20%; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(480px, 100%); padding: 42px; border: 1px solid var(--line); background: rgba(20, 27, 25, .9); border-radius: 30px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.login-card h1 { font-size: 40px; line-height: 1; margin: 10px 0 14px; letter-spacing: -.04em; }
.login-card form { margin-top: 30px; }
.password-row { display: flex; gap: 10px; margin-top: 8px; }
.password-row input { flex: 1; min-width: 0; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; color: #11170e; background: var(--lime); font-size: 28px; font-weight: 900; transform: rotate(-4deg); box-shadow: 0 12px 34px rgba(199, 255, 99, .15); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 21px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; padding: 28px 18px; border-right: 1px solid var(--line); background: rgba(11, 16, 15, .82); backdrop-filter: blur(22px); display: flex; flex-direction: column; z-index: 5; }
.brand { display: flex; align-items: center; gap: 13px; padding: 0 9px 34px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 18px; letter-spacing: -.02em; }
.brand span { color: var(--muted); font-size: 12px; }
nav { display: grid; gap: 6px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; color: var(--muted); background: transparent; border: 0; border-radius: 13px; padding: 12px 14px; text-align: left; transition: .18s ease; }
.nav-item span { width: 20px; text-align: center; font-size: 17px; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-item.active { color: var(--lime); background: rgba(199, 255, 99, .09); }
.sidebar-bottom { margin-top: auto; }

.main { grid-column: 2; width: min(1480px, 100%); padding: 0 36px 50px; }
.topbar { min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; background: linear-gradient(var(--bg) 74%, transparent); z-index: 4; }
.topbar h2 { margin: 2px 0 0; font-size: 27px; letter-spacing: -.03em; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.eyebrow { margin: 0; color: var(--lime); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .16em; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 12px; }
.view { display: none; animation: appear .22s ease; }
.view.active { display: block; }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } }

.button { border: 1px solid var(--line); border-radius: 12px; padding: 10px 15px; color: var(--text); background: var(--surface-2); font-weight: 700; transition: .18s ease; }
.button:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.18); }
.button.primary { background: var(--lime); color: #151b11; border-color: var(--lime); }
.button.ghost { background: transparent; }
.button.small { padding: 7px 10px; font-size: 12px; }
.button.wide { width: 100%; }
.badge { padding: 7px 11px; border-radius: 999px; font-size: 11px; font-weight: 800; background: rgba(199,255,99,.1); color: var(--lime); border: 1px solid rgba(199,255,99,.18); }
.badge.live { color: var(--orange); border-color: rgba(255,179,92,.22); background: rgba(255,179,92,.1); }
.badge.warning { color: var(--orange); border-color: rgba(255,179,92,.22); background: rgba(255,179,92,.1); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.stat-card { min-height: 144px; padding: 22px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.stat-card .value { margin: 12px 0 2px; font-size: 34px; line-height: 1; font-weight: 850; letter-spacing: -.05em; }
.stat-card small { color: var(--muted); }
.content-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 20px; }
.panel h3, .section-intro h3 { margin: 3px 0 0; font-size: 21px; letter-spacing: -.025em; }
.groups-list { display: grid; gap: 9px; }
.group-row { padding: 15px; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 15px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.group-name { display: flex; gap: 12px; align-items: center; min-width: 0; }
.group-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(114,183,255,.1); color: var(--blue); }
.group-name strong, .group-name small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.group-name small { color: var(--muted); }
.group-actions { display: flex; gap: 8px; align-items: center; }
.check-list { display: grid; gap: 20px; }
.check-list > div { display: flex; gap: 12px; }
.check { width: 27px; height: 27px; flex: 0 0 27px; border-radius: 9px; display: grid; place-items: center; background: rgba(199,255,99,.11); color: var(--lime); }
.check-list p { margin: 0; }
.check-list small { display: block; color: var(--muted); }

.section-intro { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 8px 0 18px; }
.section-intro > p { max-width: 580px; text-align: right; }
.trigger-list { display: grid; gap: 10px; }
.trigger-card { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; padding: 17px 18px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); transition: .18s ease; }
.trigger-card:hover { border-color: rgba(199,255,99,.2); transform: translateY(-1px); }
.priority { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.045); color: var(--muted); font-weight: 850; }
.trigger-info { min-width: 0; }
.trigger-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trigger-info small { color: var(--muted); }
.trigger-tools { display: flex; align-items: center; gap: 7px; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: transparent; font-size: 18px; }
.icon-button:hover { color: var(--text); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #59615e; }
.status-dot.on { background: var(--lime); box-shadow: 0 0 0 5px rgba(199,255,99,.08); }

.switch { position: relative; display: inline-flex; }
.switch input { position: absolute; opacity: 0; }
.switch span { width: 42px; height: 24px; border-radius: 999px; background: #39413e; position: relative; transition: .2s ease; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: #eef2ed; transition: .2s ease; }
.switch input:checked + span { background: var(--lime); }
.switch input:checked + span::after { transform: translateX(18px); background: #17200d; }
.toggle-row { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 10px 0; border-bottom: 1px solid var(--line); }

.simulator-grid { display: grid; grid-template-columns: minmax(360px, .85fr) 1.15fr; gap: 14px; }
.stack-form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: #dfe5e1; font-size: 13px; font-weight: 650; }
input, textarea, select { width: 100%; color: var(--text); background: #111816; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; outline: none; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: rgba(199,255,99,.45); box-shadow: 0 0 0 3px rgba(199,255,99,.06); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.result-panel { min-height: 520px; }
.result-panel.empty { display: grid; place-items: center; }
.empty-state { color: var(--muted); text-align: center; max-width: 340px; }
.empty-state h3 { color: var(--text); }
.radar { width: 82px; height: 82px; margin: 0 auto 20px; border: 1px solid rgba(199,255,99,.2); border-radius: 50%; display: grid; place-items: center; color: var(--lime); font-size: 34px; box-shadow: inset 0 0 40px rgba(199,255,99,.05); }
.result-match { border-left: 3px solid var(--lime); padding-left: 17px; margin-bottom: 20px; }
.result-match h3 { margin: 4px 0; }
.action-result { padding: 13px 15px; margin-top: 8px; border-radius: 13px; background: rgba(255,255,255,.035); border: 1px solid var(--line); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }
td { font-size: 13px; }
.event-status { font-weight: 800; color: var(--lime); }
.event-status.failed { color: var(--red); }
.versions-list { display: grid; gap: 9px; }
.version-row { display: flex; justify-content: space-between; gap: 15px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 14px; }
.version-row small { color: var(--muted); display: block; }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; justify-items: end; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(5px); }
.modal-sheet { position: relative; width: min(760px, 100%); height: 100%; overflow-y: auto; padding: 28px; background: #141b19; border-left: 1px solid var(--line); box-shadow: -30px 0 80px rgba(0,0,0,.35); animation: slide .23s ease; }
@keyframes slide { from { transform: translateX(28px); opacity: 0; } }
.modal-head, .actions-heading, .modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.modal-head { margin-bottom: 26px; }
.modal-head h3 { margin: 3px 0 0; font-size: 24px; }
.editor-form { display: grid; gap: 18px; }
.option-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.option-grid .toggle-row { border: 1px solid var(--line); border-radius: 13px; padding: 10px 12px; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
legend { color: var(--muted); padding: 0 7px; font-size: 12px; }
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox-grid label { display: flex; align-items: center; gap: 8px; }
.checkbox-grid input { width: auto; }
.actions-heading h4 { margin: 2px 0 0; }
.actions-editor { display: grid; gap: 10px; }
.action-editor { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); display: grid; gap: 12px; }
.action-editor-head { display: flex; gap: 10px; align-items: center; }
.action-editor-head select { flex: 1; }
.modal-actions { position: sticky; bottom: -28px; margin: 10px -28px -28px; padding: 18px 28px; background: rgba(20,27,25,.95); border-top: 1px solid var(--line); backdrop-filter: blur(16px); justify-content: flex-end; }
.form-error { min-height: 20px; color: var(--red); }
.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; max-width: 380px; padding: 13px 17px; border-radius: 13px; background: #edf5e9; color: #15200f; font-weight: 750; box-shadow: var(--shadow); animation: toast-in .22s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1050px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid, .simulator-grid { grid-template-columns: 1fr; }
  .result-panel { min-height: 340px; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { inset: auto 0 0; width: auto; height: 70px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--line); flex-direction: row; }
  .brand, .sidebar-bottom { display: none; }
  nav { width: 100%; grid-template-columns: repeat(5, 1fr); gap: 2px; }
  .nav-item { padding: 6px 2px; display: grid; justify-items: center; gap: 0; font-size: 10px; text-align: center; }
  .nav-item span { font-size: 18px; }
  .main { padding: 0 14px 96px; }
  .topbar { min-height: 98px; align-items: flex-start; padding-top: 17px; }
  .topbar .eyebrow, #refresh { display: none; }
  .topbar h2 { font-size: 22px; }
  .top-actions { max-width: 68%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 120px; padding: 17px; }
  .stat-card .value { font-size: 28px; }
  .panel { padding: 18px; }
  .section-intro { display: block; }
  .section-intro > p { text-align: left; }
  .trigger-card { grid-template-columns: 37px 1fr; }
  .trigger-tools { grid-column: 1 / -1; justify-content: flex-end; }
  .form-grid, .option-grid, .checkbox-grid { grid-template-columns: 1fr; }
  .group-row { align-items: flex-start; }
  .group-actions { flex-direction: column; align-items: flex-end; }
  .modal-sheet { padding: 20px; }
  .modal-actions { bottom: -20px; margin: 8px -20px -20px; padding: 14px 20px; }
  .password-row { display: grid; }
  .login-card { padding: 30px 24px; }
}
