:root {
    --ink: #16241c;
    --muted: #5d6e64;
    --line: #e1ebe5;
    --bg: #f3f6f4;
    --card: #fff;
    --accent: #e10600;
    --accent-dark: #9d0400;
    --danger: #a3261b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font: 16px/1.5 "Segoe UI", sans-serif;
}

h1, h2, p { margin-top: 0; }

h1 {
    font-size: 30px;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

h2 { font-size: 18px; margin-bottom: 8px; }

a { color: var(--accent-dark); }

.lead, .help, .meta, .who { color: var(--muted); }

.help, .meta, .who { font-size: 13px; }

.help code { font-family: Consolas, "Courier New", monospace; font-size: 12px; }

.shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.side {
    background: #13241c;
    color: #e7f2ec;
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
}

.brand, .side nav a, .side button {
    color: inherit;
    text-decoration: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    padding: 0 8px 18px;
}

.mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #2f9a68;
    color: white;
    font-size: 13px;
    font-weight: 800;
}

.side nav { display: flex; flex-direction: column; gap: 4px; }

.side nav a, .side button {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    border-radius: 8px;
    padding: 10px 12px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.side nav a[aria-current="page"], .side nav a:hover, .side button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.side-foot { margin-top: auto; padding-top: 18px; }

.who { margin: 0 8px 6px; color: #b7c9c0; }

.main { padding: 28px 32px 72px; max-width: 880px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 14px;
}

.card.empty { color: var(--muted); }

a.card.conv {
    display: block;
    color: inherit;
    text-decoration: none;
}

a.card.conv:hover { border-color: #b7d7c8; }

.conv-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.ip-panel { position: sticky; top: 16px; }

.ip-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 70vh;
    overflow: auto;
}

.ip-menu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: inherit;
    text-decoration: none;
    border-radius: 8px;
    padding: 8px 10px;
    font-weight: 600;
}

.ip-menu a[aria-current="page"], .ip-menu a:hover { background: #f3f6f4; }

.ip-addr {
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

.conv-filter { margin-bottom: 10px; }

.item-top, .actions, .row-actions, .try-row, .auth-card .brand-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-top { justify-content: space-between; }

.actions, .row-actions { margin-top: 14px; flex-wrap: wrap; }

.row-actions form { margin: 0; }

label { display: block; font-weight: 650; font-weight: 600; margin: 14px 0 6px; }

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

input[type="text"], input[type="password"], input:not([type]), textarea, input[type="color"] {
    width: 100%;
    border: 1px solid #d5e3db;
    background: white;
    color: var(--ink);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
}

input[type="checkbox"] { width: auto; margin: 0; }

input[type="color"] {
    width: 72px;
    height: 42px;
    padding: 4px;
}

textarea { resize: vertical; min-height: 88px; }

#embed-code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    min-height: 0;
}

button, a.ghost {
    font: inherit;
    font-weight: 700;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--accent);
    color: white;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
}

button.ghost, a.ghost {
    background: white;
    color: var(--ink);
    border-color: var(--line);
}

button.danger {
    background: white;
    color: var(--danger);
    border-color: #f0d0cc;
}

button:hover, a.ghost:hover { filter: brightness(0.98); }

.flash, .banner, .hint {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.flash.ok { background: #e7f6ee; color: #08643a; }

.flash.err { background: #fdecea; color: #8d1d14; }

.banner, .hint { background: #fff6e8; color: #7a4b00; }

.badge {
    font-size: 12px;
    font-weight: 700;
    border-radius: 999px;
    padding: 4px 8px;
    white-space: nowrap;
}

.badge.on { background: #e5f6ec; color: #0d6b40; }

.badge.off { background: #eef1ef; color: #667069; }

.knowledge-body, .try-answer, .bubble-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.try-answer strong, .bubble-text strong { font-weight: 700; }

.chat-btn {
    display: inline-flex;
    align-items: center;
    margin: 6px 8px 2px 0;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--accent);
    color: white !important;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.chat-btn.is-wa { background: #25D366; color: #073018 !important; }

.base-view {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: 0;
    max-height: 70vh;
    overflow: auto;
    padding: 14px;
    border-radius: 10px;
    background: #f7faf8;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
}

.knowledge-body {
    max-height: 9.5em;
    overflow: auto;
    background: #f7faf8;
    border-radius: 10px;
    padding: 10px 12px;
    margin: 8px 0 0;
}

.try-row input { flex: 1; }

.try-answer {
    background: #f4f7f5;
    border-radius: 10px;
    padding: 12px;
    margin: 12px 0 0;
}

.transcript { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 16px; }

.bubble {
    max-width: 82%;
    padding: 10px 12px;
    border-radius: 12px;
}

.bubble .who-line { display: block; font-size: 11px; opacity: 0.75; margin-bottom: 4px; }

.bubble.user { margin-left: auto; background: var(--accent); color: white; }

.bubble.assistant { background: #f4f7f5; }

body.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(440px, 100%);
    background: white;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 16px 40px rgba(20, 34, 28, 0.06);
}

.brand-line { font-weight: 800; margin-bottom: 18px; }

.auth-card .mark { display: inline-grid; margin-right: 8px; vertical-align: -10px; }

:focus-visible { outline: 2px solid #8dcfb0; outline-offset: 2px; }

@media (max-width: 860px) {
    .shell { display: block; }
    .side {
        position: sticky;
        top: 0;
        z-index: 5;
        min-height: 0;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        overflow: auto;
        padding: 10px 12px;
    }
    .brand { padding: 0 8px 0 0; }
    .side nav { flex-direction: row; }
    .side nav a, .side button { width: auto; white-space: nowrap; }
    .side-foot { margin-top: 0; padding-top: 0; display: flex; align-items: center; }
    .who { display: none; }
    .main { padding: 20px 16px 48px; }
    .conv-layout { grid-template-columns: 1fr; }
    .ip-panel { position: static; }
    .ip-menu { max-height: 240px; }
}
