:root {
    --bg-1: #06131a;
    --bg-2: #0f2630;
    --panel: rgba(9, 27, 35, 0.88);
    --panel-strong: rgba(10, 36, 47, 0.96);
    --panel-soft: rgba(19, 53, 64, 0.62);
    --line: rgba(128, 182, 189, 0.18);
    --text: #ecf8f6;
    --muted: #96b8bb;
    --accent: #44d2bc;
    --accent-strong: #0f9c87;
    --accent-soft: rgba(68, 210, 188, 0.12);
    --warn: #f4b860;
    --error: #ff7b7b;
    --success: #7cf5b7;
    --shadow: 0 24px 80px rgba(1, 10, 16, 0.42);
    --radius: 24px;
    --radius-sm: 16px;
    --font-sans: "Segoe UI Variable", "IBM Plex Sans", "Trebuchet MS", sans-serif;
    --font-mono: "Cascadia Code", "JetBrains Mono", "Consolas", monospace;
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-sans);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(68, 210, 188, 0.18), transparent 28%),
        radial-gradient(circle at bottom right, rgba(244, 184, 96, 0.12), transparent 24%),
        linear-gradient(145deg, var(--bg-1), var(--bg-2));
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code,
pre,
textarea {
    font-family: var(--font-mono);
}

.flash-stack {
    position: fixed;
    top: 20px;
    left: 50%;
    z-index: 3000;
    width: min(92vw, 760px);
    transform: translateX(-50%);
    display: grid;
    gap: 10px;
}

.flash {
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow);
}

.flash--success {
    background: rgba(18, 58, 42, 0.95);
    color: var(--success);
}

.flash--error {
    background: rgba(88, 27, 27, 0.95);
    color: #ffd4d4;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
}

.auth-card {
    width: min(100%, 520px);
    display: grid;
    gap: 24px;
    padding: 36px;
    border-radius: 32px;
    background: linear-gradient(180deg, rgba(7, 24, 31, 0.92), rgba(10, 33, 43, 0.9));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.auth-card--wide {
    width: min(1120px, 100%);
}

.auth-card__brand {
    display: grid;
    gap: 10px;
}

.auth-card__brand h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1;
}

.auth-card__eyebrow,
.topbar__badge {
    display: inline-flex;
    width: fit-content;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.stack-form {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    color: var(--muted);
    font-size: 0.92rem;
}

.field input,
.field textarea,
.compact-field select {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(3, 20, 26, 0.72);
    color: var(--text);
    border-radius: 16px;
    padding: 14px 16px;
    outline: none;
}

.field textarea,
.file-editor,
#chat-input {
    resize: vertical;
}

.field input:focus,
.field textarea:focus,
.compact-field select:focus,
.file-editor:focus,
#chat-input:focus {
    border-color: rgba(68, 210, 188, 0.52);
    box-shadow: 0 0 0 4px rgba(68, 210, 188, 0.12);
}

.button {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 14px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

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

.button--primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #03241e;
}

.button--secondary {
    background: rgba(68, 210, 188, 0.14);
    color: var(--text);
    border-color: rgba(68, 210, 188, 0.24);
}

.button--ghost {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    border-color: var(--line);
}

.button--small {
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 0.88rem;
}

.button--full {
    width: 100%;
}

.auth-links,
.auth-note {
    display: grid;
    gap: 8px;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--line);
    color: var(--muted);
}

.auth-note--warning {
    color: #ffe4b0;
    background: rgba(126, 81, 19, 0.25);
}

.installer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.installer-panel,
.panel {
    display: grid;
    gap: 16px;
    padding: 22px;
    border-radius: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.panel--glow {
    background:
        radial-gradient(circle at top right, rgba(68, 210, 188, 0.13), transparent 45%),
        var(--panel);
}

.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.checklist__item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
}

.checklist__item.is-ok .checklist__status {
    color: var(--success);
}

.checklist__item.is-fail .checklist__status {
    color: var(--error);
}

.checklist__status {
    font-weight: 700;
}

.portal-app {
    min-height: 100vh;
    padding: 18px;
    display: grid;
    gap: 18px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    background: rgba(5, 19, 25, 0.84);
    border: 1px solid var(--line);
    border-radius: 28px;
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.topbar__brand,
.topbar__controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.topbar__brand h1 {
    margin: 0;
    font-size: 1.5rem;
}

.topbar__brand p {
    margin: 2px 0 0;
    color: var(--muted);
}

.compact-field {
    display: grid;
    gap: 6px;
    min-width: 210px;
}

.compact-field span {
    font-size: 0.8rem;
    color: var(--muted);
}

.workspace {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.sidebar,
.chat-panel {
    min-height: calc(100vh - 180px);
}

.sidebar {
    display: grid;
    gap: 18px;
    align-content: start;
}

.panel__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.panel__header h2,
.panel__header h3 {
    margin: 0 0 6px;
}

.panel__header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-bar {
    padding: 14px 18px;
    border-radius: 18px;
    background: rgba(68, 210, 188, 0.09);
    border: 1px solid rgba(68, 210, 188, 0.16);
    color: var(--muted);
}

.status-bar[data-tone="warning"] {
    background: rgba(244, 184, 96, 0.12);
    border-color: rgba(244, 184, 96, 0.22);
    color: #ffe0b1;
}

.status-bar[data-tone="error"] {
    background: rgba(255, 123, 123, 0.12);
    border-color: rgba(255, 123, 123, 0.2);
    color: #ffd6d6;
}

.chat-panel {
    display: grid;
    gap: 18px;
    padding: 22px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(6, 20, 26, 0.94), rgba(8, 28, 36, 0.92));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.chat-messages {
    display: grid;
    gap: 14px;
    align-content: start;
    max-height: calc(100vh - 380px);
    overflow: auto;
    padding-right: 4px;
}

.empty-chat,
.empty-state {
    padding: 20px;
    border-radius: 20px;
    border: 1px dashed var(--line);
    color: var(--muted);
    background: rgba(255, 255, 255, 0.03);
}

.message {
    display: grid;
    gap: 12px;
    padding: 18px;
    border-radius: 22px;
    border: 1px solid var(--line);
    max-width: 92%;
}

.message header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 0.85rem;
}

.message--user {
    justify-self: end;
    background: rgba(68, 210, 188, 0.1);
}

.message--assistant {
    background: rgba(255, 255, 255, 0.04);
}

.message__content {
    line-height: 1.66;
    overflow-wrap: anywhere;
}

.message__content code {
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
}

.code-block {
    display: grid;
    gap: 8px;
    margin: 16px 0;
    padding: 14px;
    border-radius: 18px;
    background: rgba(2, 12, 15, 0.92);
    border: 1px solid rgba(68, 210, 188, 0.18);
    overflow: auto;
}

.code-block code {
    padding: 0;
    background: transparent;
    white-space: pre;
}

.code-block__lang {
    color: var(--accent);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.chat-form {
    display: grid;
    gap: 12px;
}

#chat-input,
.file-editor {
    width: 100%;
    min-height: 160px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(2, 15, 20, 0.84);
    color: var(--text);
    padding: 18px;
    outline: none;
}

.chat-form__actions {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    color: var(--muted);
}

.chat-form__meta {
    display: grid;
    gap: 8px;
}

.toggle-inline {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    cursor: pointer;
}

.toggle-inline input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.toggle-inline input:disabled + span,
.toggle-inline input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.prompt-list,
.chat-list,
.file-list,
.admin-table {
    display: grid;
    gap: 12px;
}

.prompt-chip,
.chat-card,
.file-card,
.row-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
}

.prompt-chip,
.file-card {
    text-align: left;
    cursor: pointer;
}

.prompt-chip span,
.chat-card span,
.chat-card small,
.file-card span,
.row-card span {
    color: var(--muted);
    display: block;
    font-size: 0.86rem;
}

.chat-card.is-active,
.file-card.is-active {
    border-color: rgba(68, 210, 188, 0.4);
    background: rgba(68, 210, 188, 0.12);
}

.panel--editor {
    min-height: 420px;
}

.file-editor {
    min-height: 380px;
}

.admin-panel {
    position: fixed;
    inset: 0;
    z-index: 2200;
    padding: 22px;
    background: rgba(2, 10, 14, 0.72);
    backdrop-filter: blur(16px);
    display: none;
}

.admin-panel.is-open {
    display: block;
}

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

.admin-grid {
    max-height: calc(100vh - 100px);
    overflow: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.pill {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(68, 210, 188, 0.14);
    color: var(--accent);
    font-size: 0.82rem;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 2400;
    display: none;
}

.modal.is-open {
    display: block;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 10, 14, 0.72);
}

.modal__dialog {
    position: relative;
    width: min(92vw, 720px);
    margin: 8vh auto 0;
    padding: 24px;
    border-radius: 26px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.modal__header,
.modal__actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.modal__actions {
    margin-top: 8px;
}

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

    .sidebar,
    .chat-panel {
        min-height: auto;
    }

    .chat-messages {
        max-height: 46vh;
    }

    .admin-grid,
    .installer-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 780px) {
    .portal-app {
        padding: 12px;
    }

    .topbar,
    .chat-panel,
    .panel,
    .installer-panel,
    .auth-card {
        padding: 16px;
        border-radius: 22px;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar__controls {
        width: 100%;
    }

    .compact-field {
        min-width: 100%;
    }

    .chat-form__actions,
    .panel__header,
    .row-card,
    .message header {
        flex-direction: column;
        align-items: flex-start;
    }

    .message {
        max-width: 100%;
    }

    .admin-panel {
        padding: 14px;
    }
}
