:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --ink: #1c2430;
    --muted: #5d6b7b;
    --line: #e3e8ee;
    --field: #e8eef6;
    --black: #111111;
    --shadow: 0 10px 30px rgba(22, 32, 46, 0.08);
    --font: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
}

button, input { font: inherit; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    padding: 12px 24px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.logo { height: 42px; width: auto; display: block; }

.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }

.brand-title {
    color: var(--ink);
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
}

.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary { background: var(--black); color: #fff; }

.btn-primary:hover { background: #000; }

.btn-ghost {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
}

.btn-ghost:hover { background: #f7f9fb; }

.login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 16px 64px;
}

.login-screen h1 {
    margin: 8px 0 22px;
    font-size: 28px;
    font-weight: 600;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.login-card { width: min(420px, 100%); padding: 28px 28px 24px; }

.login-card h2 {
    margin: 0 0 18px;
    text-align: center;
    font-size: 22px;
}

label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }

input[type="text"], input[type="password"], input[readonly] {
    display: block;
    width: 100%;
    margin-top: 6px;
    border: 0;
    border-radius: 8px;
    background: var(--field);
    color: var(--ink);
    padding: 12px 14px;
}

input:focus { outline: 2px solid #b9c7d8; }

.login-card .btn-primary { width: 100%; margin-top: 8px; padding: 12px 14px; }

.app-shell { height: 100vh; display: flex; flex-direction: column; }

.thread {
    flex: 1;
    overflow: auto;
    padding: 28px 8vw 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.bubble { max-width: min(820px, 100%); padding: 14px 16px; border-radius: 14px; line-height: 1.45; }

.bubble-user { align-self: flex-end; background: var(--black); color: #fff; white-space: pre-wrap; }

.bubble-assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }

.bubble-assistant p { margin: 0 0 12px; }

.bubble-assistant h3 { margin: 8px 0; font-size: 16px; }

.extras-title { margin: 18px 0 4px; font-size: 14px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }

.muted { color: var(--muted); font-size: 13px; }

.answer-actions { display: flex; justify-content: flex-end; margin-top: 8px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }

th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }

th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

th { background: #f7f9fb; font-weight: 600; }

.composer {
    padding: 12px 8vw 18px;
    background: linear-gradient(#f4f6f8, #fff 30%);
    border-top: 1px solid var(--line);
}

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

.composer-row input { flex: 1; margin: 0; }

.profile { position: relative; }

.profile summary {
    list-style: none;
    cursor: pointer;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 600;
}

.profile summary::-webkit-details-marker { display: none; }

.profile summary::after { content: " ▾"; color: var(--muted); font-weight: 400; }

.profile-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 280px;
    padding: 16px;
    z-index: 5;
}

.profile-panel .btn { width: 100%; }

dialog {
    border: 0;
    border-radius: 16px;
    padding: 22px;
    width: min(440px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    box-shadow: var(--shadow);
}

dialog p { overflow-wrap: anywhere; }

dialog::backdrop { background: rgba(20, 28, 38, 0.45); }

dialog p { margin: 0 0 16px; font-size: 17px; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.waiting[hidden] { display: none; }

.waiting:not([hidden]) {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(244, 246, 248, 0.72);
    z-index: 20;
}

.waiting p {
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: var(--shadow);
    font-weight: 600;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 800px) {
    .brand-title { display: none; }
    .thread, .composer { padding-left: 16px; padding-right: 16px; }
    .topbar { align-items: flex-start; flex-direction: column; }
}
