/* ===== GEMMAi — BellAI B4 Design System ===== */

:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --fg: rgb(29, 29, 31);
    --muted: rgb(110, 110, 115);
    --subtle: rgb(134, 134, 139);
    --royal: #0751A0;
    --sky: #33A9E0;
    --gold: #FCAF17;
    --ok: #059669;
    --danger: #dc2626;
    --warn: #b45309;
    --warn-soft: #fffbeb;
    --ok-soft: #ecfdf5;
    --danger-soft: #fef2f2;
    --accent-soft: rgba(7,81,160,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background: var(--bg);
    color: var(--fg);
    font-family: 'Inter', -apple-system, system-ui, 'SF Pro Text', 'Helvetica Neue', sans-serif;
    font-size: 17px;
    line-height: 1.47059;
    -webkit-font-smoothing: antialiased;
    height: 100%;
    overflow: hidden;
}

@supports (font-variation-settings: normal) {
    html, body { font-family: 'Inter var', -apple-system, system-ui, sans-serif; }
}

/* ===== Header ===== */
header.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--royal) 0%, #0a6bc4 50%, var(--sky) 100%);
    color: #fff;
}

header.top .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17.5px;
    letter-spacing: -0.022em;
    font-weight: 500;
}

header.top .brand small {
    font-weight: 400;
    color: rgba(255,255,255,0.5);
    font-size: 12px;
}

header.top nav {
    display: flex;
    align-items: center;
    gap: 0;
}

header.top nav a {
    color: rgba(255,255,255,0.72);
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 980px;
    font-weight: 400;
    text-decoration: none;
    letter-spacing: -0.01em;
    transition: all 150ms ease;
}

header.top nav a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

header.top nav a.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-weight: 500;
}

header.top .user {
    color: rgba(255,255,255,0.4);
    font-size: 12px;
    margin-left: 18px;
    padding-left: 18px;
    border-left: 1px solid rgba(255,255,255,0.1);
}

header.top .user a {
    color: rgba(255,255,255,0.55);
    text-decoration: none;
}

header.top .user a:hover {
    color: #fff;
}

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 44px;
    height: 52px;
    background: rgba(250, 250, 252, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 16px;
    border-radius: 980px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.016em;
    background: rgba(7,81,160,0.06);
    color: var(--royal);
}

.stat-pill .n {
    font-weight: 700;
    font-size: 15px;
}

.stat-pill.ok {
    background: rgba(5,150,105,0.06);
    color: var(--ok);
}

.toolbar-label {
    font-size: 14px;
    color: var(--subtle);
    margin-left: 2px;
    letter-spacing: -0.016em;
}

.toolbar-nav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.pill-btn {
    height: 36px;
    border-radius: 980px;
    border: none;
    background: rgba(0,0,0,0.04);
    cursor: pointer;
    font-size: 14px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 18px;
    font-family: inherit;
    font-weight: 400;
    letter-spacing: -0.016em;
    transition: all 200ms ease;
}

.pill-btn:hover {
    background: rgba(0,0,0,0.08);
    color: var(--fg);
}

.pill-btn.primary {
    background: var(--royal);
    color: #fff;
    padding: 0 24px;
    font-weight: 600;
}

.pill-btn.primary:hover {
    background: #064a91;
}

/* ===== Book / Two-Column Layout ===== */
.book {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: calc(100vh - 44px - 52px);
    gap: 24px;
    padding: 24px 44px 44px;
}

.book.no-toolbar {
    height: calc(100vh - 44px);
    padding-top: 24px;
}

.page {
    overflow-y: auto;
    padding: 40px 44px;
    background: var(--surface);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
}

/* ===== Chat Panel ===== */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.chat-title {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.022em;
    color: var(--fg);
}

.badge {
    display: inline-flex;
    padding: 4px 14px;
    border-radius: 980px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.01em;
    background: rgba(7,81,160,0.06);
    color: var(--royal);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.assistant { justify-content: flex-start; }

.chat-bubble {
    max-width: 85%;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.47059;
    letter-spacing: -0.022em;
    border-radius: 20px;
}

.chat-msg.user .chat-bubble {
    background: rgba(7,81,160,0.06);
    color: var(--fg);
    border-bottom-right-radius: 6px;
}

.chat-msg.assistant .chat-bubble {
    background: var(--bg);
    color: var(--fg);
    border-bottom-left-radius: 6px;
}

.chat-bubble p { margin-bottom: 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ul, .chat-bubble ol { margin-left: 18px; margin-bottom: 8px; }
.chat-bubble code { background: rgba(0,0,0,0.04); padding: 1px 5px; font-size: 13px; border-radius: 4px; }
.chat-bubble strong { font-weight: 600; }

.chat-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding-top: 16px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
    border: 1.5px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 400;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    background: var(--bg);
    color: var(--fg);
    letter-spacing: -0.022em;
}

.chat-input-area textarea:focus {
    border-color: var(--sky);
}

.chat-input-area button {
    background: linear-gradient(135deg, var(--royal), var(--sky));
    color: #fff;
    border: none;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border-radius: 980px;
    letter-spacing: -0.016em;
    transition: opacity 200ms ease;
}

.chat-input-area button:hover { opacity: 0.85; }
.chat-input-area button:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--subtle);
    margin-top: 8px;
    letter-spacing: -0.01em;
}

.chat-loading {
    display: inline-flex;
    gap: 4px;
    padding: 8px 18px;
}

.chat-loading span {
    width: 6px;
    height: 6px;
    background: var(--subtle);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.chat-loading span:nth-child(2) { animation-delay: 0.2s; }
.chat-loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ===== Data Panel (right page) ===== */
.data-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.data-title {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.022em;
    color: var(--fg);
}

.data-status {
    font-size: 12px;
    color: var(--subtle);
    letter-spacing: -0.01em;
}

/* ===== KPI Row — B4 capsule style ===== */
.kpi-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}

.kpi-capsule {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    cursor: default;
}

.kpi-capsule .kpi-cap-label {
    font-weight: 500;
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--sky);
}

.kpi-capsule .kpi-cap-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 22px;
    border-radius: 980px;
    border: 1.5px solid var(--sky);
    background: var(--surface);
    transition: all 200ms ease;
}

.kpi-capsule:hover .kpi-cap-pill {
    background: var(--bg);
}

.kpi-capsule .kpi-cap-value {
    font-weight: 700;
    font-size: 16px;
    color: var(--sky);
    letter-spacing: -0.016em;
}

.kpi-capsule .kpi-cap-sub {
    font-weight: 400;
    font-size: 10px;
    color: var(--sky);
    opacity: 0.6;
    margin-left: 5px;
}

/* ===== Collapsible Sections ===== */
.section + .section {
    margin-top: 28px;
}

.section-toggle {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 0 14px;
    cursor: pointer;
    user-select: none;
}

.section-toggle h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.section-toggle .chevron {
    font-size: 10px;
    color: var(--subtle);
    transition: transform 0.2s;
}

.section.collapsed .section-toggle .chevron {
    transform: rotate(-90deg);
}

.section-body {
    overflow: hidden;
    transition: max-height 0.25s ease;
    max-height: 1200px;
}

.section.collapsed .section-body {
    max-height: 0;
}

/* ===== Legacy KPI Grid (campaigns etc) ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.kpi-tile {
    background: var(--bg);
    border-radius: 14px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    transition: all 200ms ease;
}

.kpi-tile:hover { background: rgba(0,0,0,0.03); }

.kpi-tile.highlight {
    background: rgba(7,81,160,0.04);
    border: 1.5px solid rgba(7,81,160,0.12);
}

.kpi-tile.highlight .kpi-value { color: var(--royal); }

.kpi-label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--subtle);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.kpi-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--fg);
    line-height: 1.1;
    letter-spacing: -0.022em;
    white-space: nowrap;
}

.kpi-sub {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--subtle);
    margin-top: 5px;
    letter-spacing: -0.01em;
}

.kpi-card {
    flex: 1;
    padding: 0 16px 0 0;
    text-align: left;
}

.kpi-card.highlight .kpi-value { color: var(--sky); }

/* ===== ROAS ===== */
.roas-good { color: var(--ok); font-weight: 600; }
.roas-ok { color: var(--warn); font-weight: 600; }
.roas-bad { color: var(--danger); font-weight: 600; }

/* ===== Tables ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 0 12px 10px;
    font-weight: 500;
    color: var(--subtle);
    font-size: 12px;
    letter-spacing: -0.01em;
}

.data-table td {
    padding: 9px 12px;
    font-weight: 400;
    letter-spacing: -0.022em;
}

.data-table td strong { font-weight: 600; }

.data-table tbody tr {
    border-radius: 8px;
    transition: background 150ms ease;
}

.data-table tbody tr:hover { background: var(--bg); }

.mono {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
}

.empty-note {
    color: var(--subtle);
    font-size: 14px;
    font-style: italic;
    letter-spacing: -0.022em;
}

.status-enabled { color: var(--ok); font-weight: 600; font-size: 13px; }
.status-paused { color: var(--danger); font-weight: 600; font-size: 13px; }

.btn-sm {
    display: inline-block;
    padding: 5px 14px;
    font-size: 13px;
    border: none;
    border-radius: 980px;
    background: var(--bg);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-sm:hover { background: rgba(0,0,0,0.06); }
.btn-sm.btn-pause { color: var(--danger); }
.btn-sm.btn-enable { color: var(--ok); }

.action-badge {
    display: inline-block;
    padding: 3px 12px;
    font-size: 12px;
    border-radius: 980px;
    background: rgba(7,81,160,0.06);
    color: var(--royal);
    font-weight: 500;
}

.detail-cell {
    max-width: 400px;
    font-size: 14px;
}

/* ===== Actions Block ===== */
.actions-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.action-item {
    background: var(--bg);
    border-radius: 12px;
    overflow: hidden;
}

.action-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    border-radius: 12px;
}

.action-header:hover { background: rgba(0,0,0,0.03); }

.action-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.action-icon.suggested { background: var(--sky); }
.action-icon.agreed { background: var(--ok); }
.action-icon.rejected { background: var(--danger); }
.action-icon.pending { background: var(--warn); }

.action-title {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--fg);
    letter-spacing: -0.022em;
}

.action-status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 10px;
    border-radius: 980px;
}

.action-status.suggested { background: rgba(7,81,160,0.06); color: var(--royal); }
.action-status.agreed { background: var(--ok-soft); color: var(--ok); }
.action-status.pending { background: var(--warn-soft); color: var(--warn); }

.action-chevron {
    font-size: 10px;
    color: var(--subtle);
    transition: transform 0.2s;
}

.action-item.collapsed .action-chevron { transform: rotate(-90deg); }

.action-detail {
    overflow: hidden;
    max-height: 400px;
    transition: max-height 0.25s ease;
}

.action-item.collapsed .action-detail { max-height: 0; }

.action-detail-inner {
    padding: 0 14px 14px 32px;
    font-size: 14px;
    font-weight: 400;
    color: var(--muted);
    line-height: 1.47059;
    letter-spacing: -0.022em;
}

.action-meta {
    margin-top: 6px;
    font-size: 12px;
    color: var(--subtle);
}

.action-btns {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.action-btns button {
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    border: none;
    border-radius: 980px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    color: var(--fg);
    background: var(--bg);
}

.action-btns button:hover { opacity: 0.8; }
.action-btns .btn-agree { background: var(--ok-soft); color: var(--ok); }
.action-btns .btn-reject { background: var(--danger-soft); color: var(--danger); }

/* ===== Chart ===== */
canvas { border-radius: 14px; }

/* ===== Single page (audit) ===== */
.page-single {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 44px;
}

.page-single h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.022em;
    margin-bottom: 4px;
}

.page-desc {
    color: var(--muted);
    margin-bottom: 20px;
    font-size: 15px;
    letter-spacing: -0.022em;
}

.audit-wrap {
    background: var(--surface);
    border-radius: 18px;
    padding: 32px 36px;
    overflow-x: auto;
}

.empty-row {
    color: var(--subtle);
    font-style: italic;
    padding: 20px 12px !important;
}

/* ===== Login ===== */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--royal) 0%, #0a6bc4 50%, var(--sky) 100%);
    overflow: auto;
}

.login-card {
    background: var(--surface);
    padding: 48px 44px;
    width: 380px;
    text-align: center;
    border-radius: 18px;
}

.login-brand {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.022em;
    background: linear-gradient(135deg, var(--royal), var(--sky));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.login-sub {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 28px;
    letter-spacing: -0.022em;
}

.login-error {
    background: var(--danger-soft);
    color: var(--danger);
    padding: 10px 16px;
    font-size: 14px;
    margin-bottom: 18px;
    border-radius: 12px;
    font-weight: 500;
}

.login-card input {
    display: block;
    width: 100%;
    padding: 12px 18px;
    border: 1.5px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    font-size: 15px;
    font-family: inherit;
    margin-bottom: 14px;
    outline: none;
    background: var(--bg);
    color: var(--fg);
    letter-spacing: -0.022em;
    transition: border-color 0.2s;
}

.login-card input:focus { border-color: var(--sky); }

.login-card button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--royal), var(--sky));
    color: #fff;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border-radius: 980px;
    letter-spacing: -0.016em;
    transition: opacity 200ms ease;
}

.login-card button:hover { opacity: 0.85; }

/* ===== Campaigns split panel ===== */
.split-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: calc(100vh - 44px);
    gap: 24px;
    padding: 24px 44px 44px;
}

.panel {
    overflow-y: auto;
    padding: 40px 44px;
    background: var(--surface);
    border-radius: 18px;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.panel-header h2 {
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.022em;
}

.mode-badge {
    display: inline-flex;
    padding: 4px 14px;
    border-radius: 980px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.01em;
    background: rgba(7,81,160,0.06);
    color: var(--royal);
}

.table-container {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 24px;
}

.chart-container {
    padding-top: 20px;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.chart-container h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--subtle);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 14px;
}

/* ===== Scrollbar ===== */
.page::-webkit-scrollbar,
.panel::-webkit-scrollbar,
.panel-data::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.table-container::-webkit-scrollbar { width: 6px; }

.page::-webkit-scrollbar-track,
.panel::-webkit-scrollbar-track,
.panel-data::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.table-container::-webkit-scrollbar-track { background: transparent; }

.page::-webkit-scrollbar-thumb,
.panel::-webkit-scrollbar-thumb,
.panel-data::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); border-radius: 3px; }

.page::-webkit-scrollbar-thumb:hover,
.panel::-webkit-scrollbar-thumb:hover,
.panel-data::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.16); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .book, .split-panel { grid-template-columns: 1fr; }
    .page:first-child, .panel-chat { max-height: 50vh; }
    .kpi-row { gap: 8px; }
    .kpi-capsule { font-size: 13px; padding: 6px 14px; }
    header.top { padding: 0 20px; }
    .toolbar { padding: 0 20px; }
    .book { padding: 16px 20px 24px; }
    .split-panel { padding: 16px 20px 24px; }
    .page, .panel { padding: 28px 24px; }
}
