:root {
    --bg: #0c1718;
    --bg-soft: #122225;
    --panel: rgba(12, 28, 30, 0.74);
    --panel-strong: rgba(16, 35, 37, 0.92);
    --line: rgba(207, 230, 223, 0.14);
    --line-strong: rgba(207, 230, 223, 0.24);
    --text: #edf4ef;
    --muted: #a6b8b1;
    --accent: #3dd9b5;
    --accent-strong: #16a085;
    --amber: #ffb34d;
    --red: #ff7367;
    --shadow: 0 32px 80px rgba(0, 0, 0, 0.34);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --mono: "IBM Plex Mono", monospace;
    --display: "Space Grotesk", sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    position: relative;
    overflow-x: hidden;
    font-family: var(--display);
    color: var(--text);
    background:
        radial-gradient(circle at 0% 0%, rgba(61, 217, 181, 0.14), transparent 34%),
        radial-gradient(circle at 100% 0%, rgba(255, 179, 77, 0.16), transparent 26%),
        radial-gradient(circle at 50% 100%, rgba(36, 99, 235, 0.12), transparent 26%),
        linear-gradient(180deg, #081011 0%, #101a1c 100%);
}

.ambient {
    position: fixed;
    border-radius: 999px;
    filter: blur(60px);
    pointer-events: none;
    opacity: 0.58;
}

.ambient-a {
    top: 80px;
    left: -100px;
    width: 320px;
    height: 320px;
    background: rgba(31, 160, 140, 0.2);
}

.ambient-b {
    top: 180px;
    right: -60px;
    width: 280px;
    height: 280px;
    background: rgba(255, 179, 77, 0.2);
}

.ambient-c {
    bottom: 20px;
    left: 42%;
    width: 240px;
    height: 240px;
    background: rgba(84, 126, 255, 0.14);
}

.app-shell {
    position: relative;
    z-index: 1;
    max-width: 1520px;
    margin: 0 auto;
    padding: 32px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 420px);
    gap: 24px;
    margin-bottom: 24px;
}

.hero-copy,
.status-panel,
.panel {
    border: 1px solid var(--line);
    background: var(--panel);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    border-radius: var(--radius-xl);
}

.hero-copy {
    padding: 34px 34px 30px;
}

.eyebrow,
.panel-kicker,
.metric-label,
.mini-label,
.field-label,
.insight-label {
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
    color: var(--muted);
    font-weight: 700;
}

.hero h1 {
    margin: 10px 0 0;
    font-size: clamp(42px, 8vw, 84px);
    line-height: 0.92;
    letter-spacing: -0.04em;
}

.lead {
    max-width: 760px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.7;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line-strong);
    color: #d7ebe3;
    font-size: 13px;
}

.status-panel {
    padding: 26px;
}

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

.status-label {
    margin: 0 0 8px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
}

.status-head h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
}

.status-dot {
    width: 16px;
    height: 16px;
    margin-top: 8px;
    border-radius: 50%;
    background: #5f7172;
    box-shadow: 0 0 0 0 rgba(61, 217, 181, 0.45);
}

.status-dot.ok {
    background: var(--accent);
    box-shadow: 0 0 0 8px rgba(61, 217, 181, 0.12);
}

.status-dot.bad {
    background: var(--red);
    box-shadow: 0 0 0 8px rgba(255, 115, 103, 0.12);
}

.status-grid,
.field-grid,
.metrics-row,
.insight-grid,
.preset-grid {
    display: grid;
    gap: 14px;
}

.status-grid,
.field-grid,
.metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-stat,
.field,
.metric-card,
.insight-card,
.preset-card,
.toggle,
.summary-banner,
.stream-banner {
    border: 1px solid var(--line);
    background: var(--panel-strong);
    border-radius: var(--radius-lg);
}

.mini-stat,
.field {
    padding: 14px;
}

input,
textarea,
button {
    font: inherit;
}

input,
textarea {
    width: 100%;
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    padding: 14px 15px;
    color: var(--text);
    background: rgba(5, 14, 15, 0.5);
    font-family: var(--display);
}

input:focus,
textarea:focus {
    outline: 2px solid rgba(61, 217, 181, 0.2);
    border-color: rgba(61, 217, 181, 0.45);
}

textarea {
    resize: vertical;
    min-height: 150px;
    line-height: 1.6;
}

.hero-actions,
.control-strip,
.action-grid {
    margin-top: 16px;
}

.control-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: stretch;
}

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
}

.toggle input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.polling-field {
    min-width: 150px;
}

.panel {
    padding: 24px;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 1.08fr) minmax(320px, 0.84fr);
    gap: 24px;
}

.panel-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-top h2 {
    margin: 6px 0 0;
    font-size: 28px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

button {
    border: none;
    cursor: pointer;
    border-radius: 999px;
    padding: 13px 18px;
    font-weight: 700;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    color: #04211f;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border: 1px solid var(--line);
}

.danger-btn {
    background: rgba(255, 115, 103, 0.12);
    color: #ffb6ae;
    border: 1px solid rgba(255, 115, 103, 0.18);
}

.ghost-btn {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
}

.preset-section {
    margin-top: 22px;
}

.preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 12px;
}

.preset-card {
    padding: 18px;
    text-align: left;
    background: linear-gradient(180deg, rgba(19, 39, 42, 0.98), rgba(11, 24, 25, 0.95));
}

.preset-title {
    display: block;
    font-weight: 700;
    color: var(--text);
}

.preset-copy {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.summary-banner,
.stream-banner {
    padding: 18px 20px;
    margin-bottom: 16px;
    color: var(--text);
    line-height: 1.6;
}

.metrics-row {
    margin-bottom: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
    padding: 16px;
}

.metric-card strong {
    display: block;
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.45;
    font-family: var(--mono);
    color: #e9fff4;
    word-break: break-word;
}

.insight-grid {
    grid-template-columns: minmax(0, 1fr);
}

.insight-card {
    padding: 16px;
}

.insight-head {
    margin-bottom: 12px;
}

.text-output,
.json-output,
.stream-event pre {
    margin: 0;
    font-family: var(--mono);
    white-space: pre-wrap;
    word-break: break-word;
}

.text-output,
.json-output {
    min-height: 140px;
    max-height: 340px;
    overflow: auto;
    padding: 14px;
    border-radius: var(--radius-md);
    background: #071011;
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #cef8eb;
}

.structured-view {
    display: grid;
    gap: 12px;
    min-height: 140px;
}

.structured-section {
    padding: 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
}

.structured-title {
    margin-bottom: 10px;
    color: #d7ebe3;
    font-size: 14px;
    font-weight: 700;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(61, 217, 181, 0.08);
    border: 1px solid rgba(61, 217, 181, 0.16);
    color: #d9fff6;
    font-size: 13px;
}

.kv-list {
    display: grid;
    gap: 8px;
}

.kv-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    font-size: 14px;
}

.kv-item span:first-child {
    color: var(--muted);
}

.json-panel {
    margin-top: 16px;
}

.json-panel summary {
    cursor: pointer;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 10px;
}

.stream-events {
    display: grid;
    gap: 12px;
    max-height: 720px;
    overflow: auto;
}

.stream-placeholder {
    padding: 18px;
    border-radius: var(--radius-lg);
    border: 1px dashed var(--line);
    color: var(--muted);
    background: rgba(255, 255, 255, 0.02);
}

.stream-event {
    padding: 14px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
}

.stream-event .meta {
    margin-bottom: 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--amber);
}

@media (max-width: 1280px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .insight-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .hero,
    .status-grid,
    .field-grid,
    .preset-grid,
    .metrics-row,
    .insight-grid,
    .action-grid {
        grid-template-columns: 1fr;
    }

    .app-shell {
        padding: 18px;
    }

    .hero-copy,
    .status-panel,
    .panel {
        border-radius: 24px;
    }
}
