:root {
    --bg: #f5f2ec;
    --surface: #ffffff;
    --ink: #1f2a29;
    --muted: #6a7471;
    --line: #dde0db;
    --accent: #1f7a5c;
    --accent-dark: #155d46;
    --warning: #ad6b14;
    --danger: #b33a32;
    --shadow: 0 18px 45px rgba(28, 38, 35, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

button,
textarea {
    font: inherit;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #243330 0%, #f5f2ec 100%);
}

.login-panel {
    width: min(420px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

.login-brand {
    color: var(--ink);
    margin-bottom: 24px;
}

.login-brand p {
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 14px;
}

.login-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    font-size: 16px;
}

.login-form button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.login-error {
    padding: 11px 12px;
    border-radius: 8px;
    background: #fff0ee;
    color: var(--danger);
    font-weight: 700;
}

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

.sidebar {
    background: #243330;
    color: #f7f5ef;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 8px;
    background: #d7b46a;
    color: #1f2a29;
    font-weight: 800;
}

.brand h1,
.topbar h2,
.status-panel h2,
.quick-panel h2,
.modal-panel h2 {
    margin: 0;
}

.brand h1 {
    font-size: 18px;
    line-height: 1.2;
}

.brand p,
.eyebrow {
    margin: 4px 0 0;
    color: rgba(247, 245, 239, 0.72);
}

.status-panel,
.quick-panel,
.tool-panel {
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 22px;
}

.status-panel h2,
.quick-panel h2,
.tool-panel h2 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(247, 245, 239, 0.7);
    margin-bottom: 14px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.status-row strong {
    color: #d7b46a;
}

.ghost-button,
.quick-action,
.danger-button,
.composer button {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease;
}

.ghost-button {
    width: 100%;
    margin-top: 16px;
    padding: 11px 14px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.quick-panel {
    display: grid;
    gap: 10px;
}

.quick-action {
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.quick-action.danger {
    color: #ffd7d4;
}

.tool-panel {
    display: grid;
    gap: 12px;
}

.side-form {
    display: grid;
    gap: 9px;
}

.side-form input {
    width: 100%;
    min-height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 9px 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.side-form input::placeholder {
    color: rgba(255, 255, 255, 0.58);
}

.side-form input[type="file"] {
    padding: 8px;
}

.side-form button {
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    background: #d7b46a;
    color: #1f2a29;
    font-weight: 800;
    cursor: pointer;
}

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

.workspace {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logout-link {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 11px;
    background: #fff;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
}

.topbar .eyebrow {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.topbar h2 {
    font-size: 28px;
    line-height: 1.15;
}

.pill {
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.pill.ok {
    background: #dff1e8;
    color: var(--accent-dark);
}

.pill.warn {
    background: #fff0d8;
    color: var(--warning);
}

.setup-banner {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid #efd6a8;
    border-radius: 8px;
    background: #fff8ea;
    color: #5f4214;
}

.chat-card {
    min-height: 0;
    flex: 1;
    display: grid;
    grid-template-rows: minmax(360px, 1fr) auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.messages {
    padding: 22px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.bubble {
    max-width: min(720px, 92%);
    border-radius: 8px;
    padding: 13px 15px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.assistant .bubble {
    background: #f2f5f1;
    border: 1px solid var(--line);
}

.user .bubble {
    background: var(--accent);
    color: #fff;
}

.composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 12px;
    border-top: 1px solid var(--line);
    padding: 16px;
    background: #fbfaf7;
}

.composer textarea {
    width: 100%;
    resize: vertical;
    min-height: 52px;
    max-height: 180px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    color: var(--ink);
}

.composer button {
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

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

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(19, 27, 25, 0.55);
}

.modal.hidden {
    display: none;
}

.modal-panel {
    width: min(560px, 100%);
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.modal-panel ul {
    margin: 14px 0 0;
    padding-left: 22px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.modal-actions .ghost-button {
    width: auto;
    margin-top: 0;
    background: #edf0ec;
    color: var(--ink);
}

.danger-button {
    padding: 11px 16px;
    background: var(--danger);
    color: #fff;
    font-weight: 700;
}

@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding: 20px;
    }

    .workspace {
        padding: 18px;
    }

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

    .top-actions {
        width: 100%;
        justify-content: space-between;
    }

    .composer {
        grid-template-columns: 1fr;
    }

    .composer button {
        min-height: 48px;
    }
}
