/* ── AbstractBuddy Design System v2 ── */
/* Palette: Forest Green + Warm Gold + Glassy Whites */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --ab-dark:      #145A32;
    --ab-green:     #1B7A3E;
    --ab-vivid:     #22A050;
    --ab-light:     #5DCC80;
    --ab-mint:      #7EEEA0;
    --ab-gold:      #FFD34E;
    --ab-gold-deep: #E6A817;
    --ab-gold-btn:  linear-gradient(135deg, #FFD34E, #E6A817);
    --ab-sidebar:   linear-gradient(160deg, #145A32 0%, #1B7A3E 60%, #1E8A45 100%);
    --ab-btn-green: linear-gradient(135deg, #22A050, #145A32);
    --ab-bg:        #F2FBF4;
    --ab-surface:   #FFFFFF;
    --ab-border:    rgba(27, 122, 62, 0.12);
    --ab-border-md: rgba(27, 122, 62, 0.22);
    --ab-text:      #0D2818;
    --ab-muted:     #5A8A6A;
    --ab-muted-lt:  #8AB89A;
    --green-ok:     #059669;
    --red-err:      #DC2626;
    --amber-warn:   #D97706;
    --radius-sm:    6px;
    --radius-md:    10px;
    --radius-lg:    14px;
    --radius-xl:    20px;
    --shadow-sm:    0 1px 4px rgba(0,0,0,0.06);
    --shadow-md:    0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg:    0 8px 40px rgba(0,0,0,0.12);
    --sidebar-w:    210px;
    --topbar-h:     60px;
}

/* ── Base ── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--ab-bg);
    color: var(--ab-text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .page-title, .card-title, .brand-name {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
}

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }
.main-content { margin-left: var(--sidebar-w); flex: 1; padding-top: var(--topbar-h); }
.main-inner { padding: 28px 32px; max-width: 1200px; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--ab-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 18px 16px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-decoration: none;
}

.brand-coin {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name {
    color: var(--ab-mint);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.2;
}
.brand-tagline {
    color: rgba(255,255,255,0.35);
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 1px;
}

.sidebar-nav { padding: 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(126,238,160,0.1); color: rgba(255,255,255,0.85); }
.nav-item--active { background: rgba(126,238,160,0.16); color: var(--ab-mint); }
.nav-item--logout { color: rgba(255,255,255,0.3); font-size: 12px; margin-top: 4px; }
.nav-item--logout:hover { color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.05); }
.nav-item--logout-btn {
    width: 100%;
    background: transparent;
    border: 0;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
}
.nav-icon { font-size: 15px; flex-shrink: 0; }

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(126,238,160,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    color: var(--ab-mint);
    flex-shrink: 0;
}
.user-email { font-size: 11px; color: rgba(255,255,255,0.4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Top navbar ── */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0;
    height: var(--topbar-h);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--ab-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 100;
}
.topbar-left { display: flex; flex-direction: column; }
.topbar-title { font-size: 16px; font-weight: 700; color: var(--ab-text); letter-spacing: -0.3px; }
.topbar-sub { font-size: 12px; color: var(--ab-muted); margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Page header ── */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 800; color: var(--ab-text); letter-spacing: -0.5px; }
.page-subtitle { font-size: 13px; color: var(--ab-muted); margin-top: 3px; }

/* ── Cards ── */
.card {
    background: rgba(255,255,255,0.82);
    border: 1px solid var(--ab-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    margin-bottom: 16px;
    backdrop-filter: blur(8px);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--ab-border);
}
.card-title { font-size: 15px; font-weight: 700; color: var(--ab-text); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}
.btn--primary {
    background: var(--ab-btn-green);
    color: white;
    box-shadow: 0 4px 12px rgba(34,160,80,0.3);
}
.btn--primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(34,160,80,0.35); }

.btn--gold {
    background: var(--ab-gold-btn);
    color: var(--ab-dark);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(255,211,78,0.3);
}
.btn--gold:hover { opacity: 0.9; transform: translateY(-1px); }

.btn--ghost {
    background: rgba(255,255,255,0.7);
    color: var(--ab-muted);
    border: 1px solid var(--ab-border-md);
}
.btn--ghost:hover { background: white; color: var(--ab-text); }

.btn--danger { background: var(--red-err); color: white; }
.btn--danger:hover { opacity: 0.9; }
.btn--danger-subtle {
    background: rgba(220, 38, 38, 0.08);
    color: rgba(153, 27, 27, 0.88);
    border: 1px solid rgba(220, 38, 38, 0.16);
    box-shadow: none;
}
.btn--danger-subtle:hover {
    background: var(--red-err);
    color: white;
    border-color: var(--red-err);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.22);
}
.btn--danger-subtle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.16);
}

/* ── Confirm modal ── */
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: none;
}
.confirm-modal--open {
    display: block;
}
.confirm-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.46);
}
.confirm-modal__panel {
    position: relative;
    width: min(92vw, 440px);
    margin: 14vh auto 0;
    background: #fff;
    border-radius: var(--radius-lg);
    border: 1px solid var(--ab-border);
    box-shadow: var(--shadow-lg);
    padding: 20px 22px;
}
.confirm-modal__title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ab-text);
    margin-bottom: 8px;
}
.confirm-modal__message {
    font-size: 13px;
    line-height: 1.55;
    color: var(--ab-muted);
}
.confirm-modal__actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn--sm { padding: 6px 12px; font-size: 12px; border-radius: var(--radius-sm); }
.btn--locked { opacity: 0.4; cursor: not-allowed !important; pointer-events: none; }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}
.badge--pending { background: #FEF3C7; color: #92400E; }
.badge--processing { background: #DCFCE7; color: #166534; }
.badge--completed { background: #DCFCE7; color: #166534; }
.badge--failed { background: #FEE2E2; color: #991B1B; }

/* ── Progress bar ── */
.progress-wrap { margin: 12px 0; }
.progress-label { font-size: 13px; color: var(--ab-muted); margin-bottom: 6px; }
.progress-label--with-spinner { display: inline-flex; align-items: center; gap: 8px; }
.inline-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(27, 122, 62, 0.2);
    border-top-color: var(--ab-vivid);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
.progress-bar { background: rgba(34,160,80,0.12); border-radius: 100px; height: 7px; overflow: hidden; }
.progress-bar__fill {
    background: linear-gradient(90deg, var(--ab-vivid), var(--ab-light));
    height: 100%;
    border-radius: 100px;
    transition: width 0.4s ease;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius-md); font-size: 13px; margin-bottom: 14px; }
.alert--success { background: #DCFCE7; color: #166534; border-left: 3px solid var(--ab-vivid); }
.alert--error { background: #FEE2E2; color: #991B1B; border-left: 3px solid var(--red-err); }
.alert--info { background: #EFF6FF; color: #1E40AF; border-left: 3px solid #3B82F6; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 12px; font-weight: 700; color: var(--ab-text); margin-bottom: 6px; letter-spacing: 0.02em; }
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--ab-border-md);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: rgba(255,255,255,0.9);
    color: var(--ab-text);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.form-input:focus {
    outline: none;
    border-color: var(--ab-vivid);
    box-shadow: 0 0 0 3px rgba(34,160,80,0.12);
}
.form-help { font-size: 12px; color: var(--ab-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red-err); margin-top: 4px; }

/* ── Upload zone ── */
.upload-zone {
    border: 2px dashed var(--ab-border-md);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: rgba(255,255,255,0.5);
}
.upload-zone:hover { border-color: var(--ab-vivid); background: rgba(34,160,80,0.04); }
.upload-zone__icon { font-size: 44px; margin-bottom: 12px; }
.upload-zone__title { font-size: 16px; font-weight: 700; color: var(--ab-text); margin-bottom: 6px; }
.upload-zone__sub { font-size: 13px; color: var(--ab-muted); }

/* ── Lease list cards ── */
.lease-grid { display: flex; flex-direction: column; gap: 10px; }
.lease-card {
    background: rgba(255,255,255,0.82);
    border: 1px solid var(--ab-border);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
    backdrop-filter: blur(8px);
    border-left: 3px solid transparent;
}
.lease-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    border-left-color: var(--ab-vivid);
}
.lease-card__name { font-size: 15px; font-weight: 700; color: var(--ab-text); }
.lease-card__meta { font-size: 12px; color: var(--ab-muted); margin-top: 3px; }
.lease-card__right { display: flex; align-items: center; gap: 10px; }

/* ── Tab navigation ── */
.tab-nav {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--ab-border);
    margin-bottom: 20px;
}
.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--ab-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    font-family: inherit;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-btn:hover { color: var(--ab-text); }
.tab-btn--active { color: var(--ab-vivid); border-bottom-color: var(--ab-vivid); font-weight: 700; }

/* ── Abstract table ── */
.abstract-table { width: 100%; border-collapse: collapse; font-size: 13px; }

.abstract-table__section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 18px;
    background: var(--ab-btn-green);
    color: white;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.abstract-table__th {
    padding: 9px 14px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ab-muted);
    background: rgba(242,251,244,0.8);
    border-bottom: 1px solid var(--ab-border);
    white-space: nowrap;
}
.abstract-table__th--check { width: 44px; text-align: center; }
.abstract-table__th--label { width: 180px; }
.abstract-table__th--value { min-width: 220px; }
.abstract-table__th--evidence { min-width: 180px; }
.abstract-table__th--confidence { width: 90px; text-align: center; }

.abstract-table__row { border-bottom: 1px solid rgba(27,122,62,0.06); transition: background 0.1s; }
.abstract-table__row:hover { background: rgba(34,160,80,0.03); }
.abstract-table__row--reviewed { background: rgba(220,252,231,0.35); }
.abstract-table__row--reviewed:hover { background: rgba(220,252,231,0.5); }
.abstract-table__row:focus-within { background: rgba(34,160,80,0.1); }

.abstract-table__cell { padding: 10px 14px; vertical-align: top; line-height: 1.5; }
.abstract-table__cell--check { text-align: center; padding-top: 12px; }
.abstract-table__cell--label { font-weight: 600; color: var(--ab-green); }
.abstract-table__cell--value { color: var(--ab-text); }
.abstract-table__cell--evidence { color: var(--ab-muted); font-size: 12px; }
.abstract-table__cell--confidence { text-align: center; }
.inline-value-display {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    cursor: text;
}
.inline-value-text { flex: 1; }
.inline-edit-btn {
    opacity: 0;
    transition: opacity 0.12s ease;
    padding: 4px 8px;
    font-size: 11px;
}
.abstract-table__row:hover .inline-edit-btn,
.inline-value-display:focus-within .inline-edit-btn { opacity: 1; }
.inline-value-editor { display: flex; flex-direction: column; gap: 8px; }
.inline-edit-input { font-size: 12px; line-height: 1.45; padding: 8px 10px; }
.inline-edit-actions { display: flex; gap: 6px; justify-content: flex-end; }
.abstract-table__cell input:focus,
.abstract-table__cell textarea:focus {
    border-color: var(--ab-vivid);
    background: rgba(126,238,160,0.08);
    box-shadow: 0 0 0 3px rgba(34,160,80,0.2);
}

/* ── Review checkbox ── */
.review-checkbox {
    width: 22px; height: 22px;
    border: 1.5px solid rgba(27,122,62,0.25);
    border-radius: 6px;
    background: white;
    color: white;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    font-family: inherit;
}
.review-checkbox:hover { border-color: var(--ab-vivid); background: rgba(34,160,80,0.06); }
.review-checkbox--checked { background: var(--ab-vivid); border-color: var(--ab-vivid); color: white; }
.review-checkbox--checked:hover { background: var(--ab-green); border-color: var(--ab-green); }

/* ── Field label link ── */
.field-label-link { color: var(--ab-green); text-decoration: none; font-weight: 600; font-size: 13px; }
.field-label-link:hover { color: var(--ab-vivid); text-decoration: underline; }

/* ── Evidence + badges ── */
.evidence-snippet { display: block; font-style: italic; color: var(--ab-muted-lt); font-size: 11px; margin-top: 3px; line-height: 1.4; }
.page-badge { display: inline-block; background: rgba(34,160,80,0.1); color: var(--ab-vivid); font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; margin-bottom: 3px; letter-spacing: 0.03em; }
.doc-source-badge { display: inline-block; background: rgba(255,211,78,0.15); color: var(--ab-gold-deep); font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; margin-left: 4px; }
.confidence-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.confidence-badge--high { background: #DCFCE7; color: #166534; }
.confidence-badge--medium { background: #FEF9C3; color: #854D0E; }
.confidence-badge--low { background: #FEE2E2; color: #991B1B; }
.edited-badge { display: inline-block; background: rgba(255,211,78,0.2); color: var(--ab-gold-deep); font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.empty-field { color: var(--ab-muted-lt); font-style: italic; font-size: 12px; }

/* ── Chat widget — anchored dropdown ── */
.chat-widget-anchor { position: relative; display: inline-block; }

.chat-widget-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 420px;
    max-height: 560px;
    background: rgba(255,255,255,0.96);
    border: 1px solid var(--ab-border-md);
    border-radius: var(--radius-xl);
    box-shadow: 0 12px 48px rgba(0,0,0,0.16);
    backdrop-filter: blur(16px);
    z-index: 500;
    flex-direction: column;
    overflow: hidden;
    animation: chatDropIn 0.2s ease;
}
.chat-widget-dropdown--open { display: flex; }

@keyframes chatDropIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-widget-header {
    background: var(--ab-btn-green);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.chat-widget-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ab-mint);
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-widget-coin { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.chat-widget-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    transition: background 0.15s;
    font-family: inherit;
}
.chat-widget-close:hover { background: rgba(255,255,255,0.25); color: white; }

.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 360px;
    scroll-behavior: smooth;
}

.chat-widget-input {
    padding: 12px 14px;
    border-top: 1px solid var(--ab-border);
    background: rgba(242,251,244,0.5);
    flex-shrink: 0;
}
.chat-input-row { display: flex; gap: 8px; }
.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--ab-border-md);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: white;
    color: var(--ab-text);
    resize: none;
    font-family: inherit;
    line-height: 1.4;
}
.chat-input:focus { outline: none; border-color: var(--ab-vivid); box-shadow: 0 0 0 2px rgba(34,160,80,0.1); }
.chat-send-btn {
    background: var(--ab-btn-green);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.chat-send-btn:hover { opacity: 0.9; }

/* ── Chat messages ── */
.message { max-width: 88%; }
.message--user { align-self: flex-end; }
.message--assistant { align-self: flex-start; }
.message__bubble { padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.6; }
.message--user .message__bubble {
    background: var(--ab-btn-green);
    color: white;
    border-radius: 14px 14px 2px 14px;
}
.message--assistant .message__bubble {
    background: white;
    border: 1px solid var(--ab-border);
    border-radius: 14px 14px 14px 2px;
    color: var(--ab-text);
}
.message__citations { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.citation {
    padding: 7px 10px;
    background: rgba(34,160,80,0.06);
    border-left: 2px solid var(--ab-vivid);
    border-radius: 0 6px 6px 0;
    font-size: 11px;
}
.citation__page { font-weight: 700; color: var(--ab-vivid); font-size: 10px; margin-bottom: 2px; }
.citation__text { color: var(--ab-muted); font-style: italic; line-height: 1.5; }
.citation-group { margin-top: 6px; }
.citation-group__summary {
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    color: var(--ab-muted);
    user-select: none;
    list-style: none;
}
.citation-group__summary::-webkit-details-marker { display: none; }
.citation-group__summary::before { content: "▸ "; color: var(--ab-vivid); }
.citation-group[open] .citation-group__summary::before { content: "▾ "; }
.citation-group__list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.chat-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--ab-muted);
}
.chat-empty__icon { font-size: 32px; margin-bottom: 8px; }
.chat-empty__title { font-size: 14px; font-weight: 600; color: var(--ab-text); margin-bottom: 4px; }
.chat-empty__sub { font-size: 12px; }
.chat-thinking { display: flex; gap: 4px; padding: 10px 14px; }
.chat-thinking span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--ab-light);
    animation: thinking 1.2s infinite;
}
.chat-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes thinking { 0%,80%,100%{opacity:0.3;transform:scale(0.8)} 40%{opacity:1;transform:scale(1)} }

/* ── Document viewer ── */
.doc-viewer { display: flex; flex-direction: column; }
.doc-viewer__toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ab-border);
    background: rgba(242,251,244,0.6);
    gap: 12px;
    flex-shrink: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.doc-viewer__toolbar-left { display: flex; align-items: center; gap: 10px; flex: 1; }
.doc-viewer__toolbar-right { display: flex; gap: 6px; }
.doc-viewer__select {
    padding: 7px 10px;
    border: 1px solid var(--ab-border-md);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: white;
    color: var(--ab-text);
    max-width: 340px;
    font-family: inherit;
}
.doc-viewer__meta { font-size: 11px; color: var(--ab-muted); }
.doc-viewer__title-bar {
    padding: 10px 16px;
    background: var(--ab-btn-green);
    color: white;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.doc-viewer__doc-type { font-size: 11px; color: var(--ab-mint); font-weight: 600; }

.doc-viewer__search-bar { border-bottom: 1px solid var(--ab-border); }
.doc-viewer__search-input-row { display: flex; gap: 8px; padding: 12px 14px; }
.doc-viewer__search-results { overflow-y: auto; max-height: 520px; }
.doc-viewer__search-hint { padding: 24px 16px; font-size: 13px; color: var(--ab-muted); text-align: center; }
.doc-viewer__search-result { padding: 14px 16px; border-bottom: 1px solid var(--ab-border); transition: background 0.1s; }
.doc-viewer__search-result:hover { background: rgba(34,160,80,0.03); }
.doc-viewer__result-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; color: var(--ab-muted); flex-wrap: wrap; }
.doc-viewer__result-text {
    font-size: 13px;
    line-height: 1.7;
    color: var(--ab-text);
    font-family: Georgia, 'Times New Roman', serif;
}
.doc-viewer__result-text mark {
    background: rgba(255,211,78,0.4);
    color: var(--ab-dark);
    border-radius: 2px;
    padding: 0 2px;
}

.doc-viewer__full { overflow-y: auto; max-height: 620px; }
.doc-viewer__pages { padding: 0; }
.doc-viewer__page { margin-bottom: 0; border-bottom: 1px solid var(--ab-border); }
.doc-viewer__page-header {
    padding: 6px 16px;
    background: #E1F2E8;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ab-muted);
    border-bottom: 1px solid var(--ab-border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.doc-viewer__page-content { padding: 20px 24px; background: white; }

/* Document text formatting */
.doc-viewer__page-text {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 13.5px;
    line-height: 1.9;
    color: var(--ab-text);
    white-space: normal;
    overflow-wrap: anywhere;
}
.doc-viewer__page-text p { 
    margin-bottom: 14px; 
    line-height: 1.85;
}
.doc-viewer__page-text strong { 
    display: block;
    font-weight: 700;
    color: var(--ab-text);
    margin-top: 18px;
    margin-bottom: 6px;
    font-size: 13px;
    letter-spacing: 0.02em;
}
.doc-viewer__page-text p:last-child { margin-bottom: 0; }

/* ── Utilities ── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--ab-muted); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ab-muted); }
.empty-state__icon { font-size: 44px; margin-bottom: 12px; }
.empty-state__title { font-size: 18px; font-weight: 700; color: var(--ab-text); margin-bottom: 8px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }

/* ── Document type badges ── */
.doc-type-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.doc-type-original_lease { background: #DBEAFE; color: #1E40AF; }
.doc-type-amendment { background: rgba(255,211,78,0.25); color: #92400E; }
.doc-type-exhibit { background: rgba(27,122,62,0.1); color: var(--ab-green); }
.doc-type-side_letter { background: #EDE9FE; color: #5B21B6; }
.doc-type-guaranty { background: #DCFCE7; color: #166534; }
.doc-type-snda { background: #FEE2E2; color: #991B1B; }
.doc-type-unknown { background: rgba(0,0,0,0.06); color: #6B7280; }

/* ── Field review page ── */
.field-review-card { max-width: 760px; }
.reasoning-block {
    padding: 12px 16px;
    background: rgba(255,211,78,0.1);
    border-left: 3px solid var(--ab-gold);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-bottom: 18px;
}
.reasoning-label { font-size: 10px; font-weight: 700; color: var(--ab-gold-deep); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.reasoning-text { font-size: 13px; color: var(--ab-muted); line-height: 1.6; }
.evidence-block { margin-bottom: 18px; }
.evidence-label { font-size: 10px; font-weight: 700; color: var(--ab-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.evidence-item {
    padding: 10px 14px;
    background: rgba(34,160,80,0.05);
    border-left: 2px solid var(--ab-vivid);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 6px;
}
.evidence-page { font-size: 10px; font-weight: 700; color: var(--ab-vivid); margin-bottom: 3px; }
.evidence-text { font-size: 12px; color: var(--ab-muted); font-style: italic; line-height: 1.5; font-family: Georgia, serif; }
/* ── AbstractBuddy Design System v2 ── */
/* Palette: Forest Green + Warm Gold + Glassy Whites */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Product shell and responsive refinements. */
:root { --ab-muted: #526b5b; --ab-muted-lt: #62776a; --ab-danger: #b42318; --ab-bg: #f5f7f5; --topbar-h: 76px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #b17b0b; outline-offset: 3px; }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
a { color: var(--ab-dark); }
.main-content { min-width: 0; width: calc(100% - var(--sidebar-w)); }
.main-inner { max-width: 1500px; margin: 0 auto; padding: 30px 36px; }
.sidebar-brand { text-decoration: none; min-height: var(--topbar-h); }
.brand-name { color: #fff; }
.brand-tagline, .sidebar-footer { color: #d3e6d8; }
.nav-item { color: #e0eee5; padding: 12px; font-size: 14px; }
.nav-item--active { color: #fff; background: #ffffff26; box-shadow: inset 3px 0 var(--ab-gold); }
.sidebar-footer { font-size: 12px; }
.topbar { background: #fff; padding: 0 36px; gap: 16px; }
.workspace-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu { position: relative; margin-left: auto; flex-shrink: 0; }
.account-menu summary { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid var(--ab-border-md); border-radius: 10px; cursor: pointer; list-style: none; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-avatar { position: relative; display: inline-flex; width: 34px; height: 34px; flex-shrink: 0; }
.account-inquiry-badge { position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: #b42318; }
.user-avatar { background: #e7f2e9; color: var(--ab-dark); width: 34px; height: 34px; }
.account-identity { font-weight: 600; max-width: 200px; overflow-wrap: anywhere; line-height: 1.4; }
.account-identity small { display: block; font-size: 11px; color: var(--ab-muted); font-weight: 500; }
.account-menu__panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(280px, 88vw); background: white; border: 1px solid var(--ab-border-md); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; }
.account-menu__heading { padding: 10px; color: var(--ab-muted); font-size: 12px; overflow-wrap: anywhere; }
.account-menu__heading strong { display: block; color: var(--ab-text); }
.account-menu__panel a, .account-menu__panel button { display: block; width: 100%; padding: 11px; color: var(--ab-text); text-decoration: none; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; border-radius: 6px; }
.account-menu__panel a:hover, .account-menu__panel button:hover { background: var(--ab-bg); }
.page-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.page-toolbar .topbar-left { min-width: 0; flex: 1 1 260px; }
.topbar-title { font-size: 24px; overflow-wrap: anywhere; }
.topbar-sub { font-size: 13px; }
.page-toolbar .topbar-actions { flex-wrap: wrap; align-items: flex-start; }
.card { background: #fff; backdrop-filter: none; }
.page-title { font-size: 26px; }
.btn--secondary { background: #fff; color: var(--ab-text); border: 1px solid var(--ab-border-md); }
.btn--primary { background: #186437; box-shadow: none; }
.btn--gold { background: #f6cf65; box-shadow: none; }
.btn--danger-subtle { background: #fff; box-shadow: none; }
.btn { min-height: 38px; }
.form-input { min-height: 42px; }
.upload-content { max-width: 850px; }
.lease-card > div { min-width: 0; }
.lease-card__name, .lease-card__meta, .topbar-sub { overflow-wrap: anywhere; }
.lease-card__right { flex-shrink: 0; }
.inline-edit-btn { opacity: 1; }
.export-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.export-help { flex-basis: 100%; color: var(--ab-muted); font-size: 12px; }
.request-error { position: relative; }
.nav-toggle, .nav-backdrop { display: none; }
.skip-link { position: fixed; left: 16px; top: -100px; z-index: 2000; padding: 12px; background: white; }
.skip-link:focus { top: 10px; }
.confirm-modal__panel { max-height: 80vh; overflow-y: auto; }
.doc-viewer__toolbar, .doc-viewer__toolbar-left { flex-wrap: wrap; }
.doc-viewer__select { max-width: 100%; }
.doc-viewer__title-bar { gap: 12px; flex-wrap: wrap; overflow-wrap: anywhere; }
.chat-widget-dropdown { max-width: calc(100vw - 32px); }
.mt-2 { margin-top: 8px; }
.alert--warning { background: #fff5d8; color: #78520b; }
@media (max-width: 1000px) {
    :root { --sidebar-w: 185px; }
    .main-inner { padding: 24px; }
    .topbar { padding: 0 24px; }
    .topbar-actions { width: 100%; }
}
@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); visibility: hidden; width: 260px; }
    .navigation-open .sidebar { transform: none; visibility: visible; }
    .navigation-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 190; background: #15291b88; border: 0; }
    .nav-toggle { display: inline-flex; }
    .main-content { margin-left: 0; width: 100%; }
    .main-inner { padding: 20px 16px; }
    .topbar { left: 0; padding: 0 16px; gap: 10px; }
    .workspace-name { display: none; }
    .account-identity { max-width: 150px; }
    .page-title, .topbar-title { font-size: 22px; }
    .card { padding: 18px; }
    .lease-card { padding: 16px; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
    .upload-zone { padding: 28px 16px; }
    .chat-widget-dropdown { position: fixed; top: 90px; left: 16px; right: 16px; width: auto; max-height: calc(100dvh - 110px); }
    .tab-nav { overflow-x: auto; }
    .tab-btn { padding: 10px 14px; }
    .doc-viewer__search-input-row { flex-wrap: wrap; }
    .flex { flex-wrap: wrap; }
    .confirm-modal__panel { margin-top: 8vh; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
.export-link[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.chat-messages { display: flex; flex-direction: column; gap: 16px; padding: 24px; min-height: 250px; max-height: 60vh; overflow: auto; }
.chat-input-area { padding: 16px 0; }
.account-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Lease actions and CRE consultation. */
.lease-header { align-items: start; gap: 24px; }
.lease-header .topbar-left { flex: 1 1 280px; }
.lease-actions { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; max-width: 100%; }
.consult-action { width: 280px; max-width: 100%; }
.consult-button { min-height: 44px; font-size: 14px; padding: 11px 18px; }
.consult-action p { margin-top: 8px; font-size: 12px; color: var(--ab-muted); line-height: 1.5; }
.action-menu { position: relative; }
.action-menu summary { min-height: 44px; list-style: none; white-space: nowrap; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu__panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 90; width: 260px; max-width: calc(100vw - 32px); padding: 8px; border: 1px solid var(--ab-border-md); border-radius: 12px; background: #fff; box-shadow: var(--shadow-md); }
.action-menu__panel p { padding: 8px; font-size: 12px; color: var(--ab-muted); }
.action-menu__panel a, .action-menu__panel button { display: block; padding: 11px 12px; width: 100%; border: 0; background: transparent; border-radius: 6px; text-align: left; text-decoration: none; font: inherit; cursor: pointer; }
.action-menu__panel a[href]:hover, .action-menu__panel button:hover { background: var(--ab-bg); }
.action-menu__panel .menu-danger { color: var(--red-err); }
.advisor-panel { position: fixed; top: var(--topbar-h); bottom: 0; right: 0; width: 480px; z-index: 300; background: white; border-left: 1px solid var(--ab-border-md); box-shadow: -8px 0 30px #102b1710; display: flex; flex-direction: column; }
.advisor-panel__header { display: flex; align-items: center; justify-content: space-between; padding: 20px; gap: 16px; border-bottom: 1px solid var(--ab-border); }
.advisor-panel__header h2 { font-size: 20px; }
.advisor-panel__header p { font-size: 12px; color: var(--ab-muted); overflow-wrap: anywhere; }
.advisor-scope { padding: 12px 20px; color: var(--ab-muted); font-size: 12px; background: var(--ab-bg); }
.advisor-messages { flex: 1; min-height: 80px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.advisor-messages .message { max-width: 96%; }
.advisor-messages .message__bubble { white-space: pre-wrap; overflow-wrap: anywhere; }
.advisor-sources { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.advisor-source { padding: 9px 10px; border: 1px solid var(--ab-border-md); border-radius: 8px; background: #f4f9f5; color: var(--ab-dark); font: inherit; font-size: 12px; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.advisor-starters { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 20px; }
.advisor-starters button { border: 1px solid var(--ab-border-md); border-radius: 20px; padding: 7px 10px; background: white; color: var(--ab-dark); font: inherit; font-size: 11px; cursor: pointer; }
.advisor-composer { border-top: 1px solid var(--ab-border); padding: 14px 20px 20px; }
.advisor-composer textarea { resize: vertical; min-height: 72px; max-height: 25vh; }
.advisor-composer__footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 10px; }
.advisor-composer__footer span { font-size: 10px; color: var(--ab-muted); }
.advisor-status { padding: 0 20px 8px; font-size: 12px; color: var(--ab-muted); }
.advisor-status:empty { display: none; }
.doc-viewer__page { scroll-margin-top: 100px; }
@media (min-width: 1101px) {
    .advisor-open .main-content { margin-right: 480px; width: calc(100% - var(--sidebar-w) - 480px); }
    .advisor-open .lease-actions { width: 100%; }
}
@media (max-width: 1100px) {
    .advisor-panel { inset: 0; width: 100%; z-index: 700; height: 100dvh; }
    .advisor-open { overflow: hidden; }
}
@media (max-width: 760px) {
    .consult-action { max-width: none; flex-basis: 100%; }
    .consult-button { width: 100%; justify-content: center; }
    .lease-actions { width: 100%; }
    .action-menu__panel { left: 0; right: auto; }
    .advisor-panel__header, .advisor-messages { padding: 16px; }
    .advisor-scope { padding: 10px 16px; }
    .advisor-starters { padding: 6px 16px; }
    .advisor-composer { padding: 12px 16px; }
}

/* Mobile app shell and touch targets. */
.nav-close { display:none; }
@media(max-width:760px) {
    .navigation-open { overflow:hidden; }
    .sidebar { width:min(300px, calc(100vw - 40px)); max-height:100dvh; overscroll-behavior:contain; padding-bottom:env(safe-area-inset-bottom); }
    .nav-close { display:inline-flex; align-self:flex-end; align-items:center; gap:12px; min-height:44px; margin:8px 12px 0; padding:8px 12px; color:#fff; background:transparent; border:1px solid #ffffff50; border-radius:8px; font:inherit; cursor:pointer; }
    .nav-close span { font-size:22px; }
    .btn,.tab-btn,.account-menu summary { min-height:44px; }
    .account-identity { max-width:clamp(86px,32vw,150px); }
    .app-body input:not([type=checkbox]):not([type=radio]),.app-body select,.app-body textarea { font-size:16px; }
    .main-inner { padding-bottom:calc(24px + env(safe-area-inset-bottom)); }
    .sidebar-footer a { display:inline-flex; align-items:center; min-height:44px; }
    .account-menu__panel a,.account-menu__panel button { min-height:44px; }
}
