@font-face {
    font-family: 'Intelbras Sans';
    src: url('Intelbras-Sans.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
}

/* ============================================================
   DESIGN TOKENS — Precision Tech Dark (Intelbras Brandbook)
   ============================================================ */
:root {
    /* Surfaces */
    --bg: #0d1c1e;
    --surface: #163134;
    --surface-raised: #1c3b3e;
    --surface-sunken: #091618;
    --surface-overlay: rgba(22, 49, 52, 0.95);

    /* Borders */
    --border: #1f4245;
    --border-strong: #035144;

    /* Brand */
    --primary: #06CB3F;
    --primary-dim: #05a832;
    --primary-glow: rgba(6, 203, 63, 0.12);
    --primary-text: #002204;
    --mint: #85FFC5;
    --mint-dim: rgba(133, 255, 197, 0.12);
    --teal: #035144;

    /* Text */
    --text: #d9f6fa;
    --text-muted: #7ab8bc;
    --text-faint: #456a6d;

    /* Chat bubbles */
    --bubble-in: #162e32;
    --bubble-in-bdr: #1f4245;
    --bubble-out: #082a14;
    --bubble-out-bdr: #0e3d1e;
    --bubble-sys: #111f21;

    /* Status */
    --error: #ff5059;
    --error-bg: rgba(186, 26, 26, 0.12);
    --error-border: rgba(186, 26, 26, 0.35);

    /* Shape */
    --r-xs: 2px;
    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-2xl: 20px;
    --r-pill: 9999px;

    /* Typography */
    --font: 'Intelbras Sans', 'Inter', ui-sans-serif, system-ui,
        -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(6, 203, 63, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(3, 81, 68, 0.15) 0%, transparent 60%);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

.grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 16px;
    margin-top: 16px;
    align-items: start;
}

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

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 16px;
}

/* ============================================================
   TOOLBAR / HEADER
   ============================================================ */
.toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--surface);
    border-color: var(--border-strong);
    position: relative;
    overflow: hidden;
}

/* Accent line on top */
.toolbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--mint) 100%);
}

.toolbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

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

.toolbar-brand img {
    height: 26px;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.toolbar-version {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: var(--r-pill);
}

.row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ============================================================
   FILE INPUT
   ============================================================ */
.filebox {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.filebox input[type="file"] {
    display: none;
}

.filelabel {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font);
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    white-space: nowrap;
}

.filelabel::before {
    content: '📂';
    font-size: 14px;
}

.filelabel:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-glow);
}

#filename {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--r-md);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s, opacity 0.15s, transform 0.1s;
    background: var(--primary);
    color: var(--primary-text);
}

.btn:not(:disabled):hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn:not(:disabled):active {
    transform: translateY(0);
    filter: brightness(0.95);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn.secondary {
    background: var(--surface-sunken);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn.secondary:not(:disabled):hover {
    border-color: var(--mint);
    color: var(--mint);
    background: var(--mint-dim);
}

.btn.ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn.ghost:not(:disabled):hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-glow);
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress-bar {
    height: 4px;
    background: var(--surface-sunken);
    border-radius: var(--r-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--mint) 100%);
    border-radius: var(--r-pill);
    transition: width 0.25s ease;
    width: 0%;
    box-shadow: 0 0 8px rgba(6, 203, 63, 0.4);
}

/* ============================================================
   INPUTS
   ============================================================ */
.input {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 9px 12px;
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-width: 0;
}

.input::placeholder {
    color: var(--text-faint);
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* datetime-local icon tint */
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
}

/* ============================================================
   FILTER ROW CONTAINER
   ============================================================ */
.filter-section {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* ============================================================
   ERROR BOX
   ============================================================ */
.error {
    color: var(--error);
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    padding: 10px 14px;
    border-radius: var(--r-lg);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.error::before {
    content: '⚠';
    font-size: 14px;
}

/* ============================================================
   SESSION LIST (VIRTUAL)
   ============================================================ */
.sessions-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
}

.sessions-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 12px;
}

.sessions {
    position: relative;
    overflow-y: auto;
    max-height: 74vh;
    border-radius: var(--r-md);
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.sessions::-webkit-scrollbar {
    width: 4px;
}

.sessions::-webkit-scrollbar-track {
    background: transparent;
}

.sessions::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-pill);
}

.session-item {
    padding: 10px 12px;
    border-radius: var(--r-lg);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: background 0.14s, border-color 0.14s;
    position: absolute;
    left: 0;
    right: 0;
}

.session-item:hover {
    background: var(--mint-dim);
    border-color: var(--border);
}

.session-item.active {
    background: var(--primary-glow);
    border-color: var(--primary);
}

.session-item .proto {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-item.active .proto {
    color: var(--primary);
}

.session-item .meta-line {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   CHIPS / BADGES
   ============================================================ */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--r-pill);
    font-size: 11px;
    font-weight: 500;
    background: var(--mint-dim);
    color: var(--mint);
    border: 1px solid rgba(133, 255, 197, 0.2);
    white-space: nowrap;
}

.chip.count {
    background: var(--surface-sunken);
    color: var(--text-muted);
    border-color: var(--border);
    min-width: 36px;
    justify-content: center;
    font-weight: 600;
}

.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: var(--r-sm);
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    color: var(--text-faint);
    margin-left: 3px;
    letter-spacing: 0.02em;
}

/* ============================================================
   CONVERSATION HEADER
   ============================================================ */
.conv-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 12px;
}

.conv-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.conv-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ============================================================
   CHAT AREA
   ============================================================ */
.chat {
    height: 68vh;
    overflow-y: auto;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.chat::-webkit-scrollbar {
    width: 4px;
}

.chat::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-pill);
}

/* ============================================================
   BUBBLES
   ============================================================ */
.bubble {
    max-width: 70%;
    padding: 10px 13px;
    border-radius: var(--r-xl);
    line-height: 1.45;
    font-size: 13px;
}

.bubble.left {
    background: var(--bubble-in);
    border: 1px solid var(--bubble-in-bdr);
    border-bottom-left-radius: var(--r-sm);
    align-self: flex-start;
}

.bubble.right {
    background: var(--bubble-out);
    border: 1px solid var(--bubble-out-bdr);
    border-bottom-right-radius: var(--r-sm);
    align-self: flex-end;
}

.bubble.system {
    background: var(--bubble-sys);
    border: 1px dashed var(--border);
    align-self: center;
    max-width: 540px;
    text-align: center;
    border-radius: var(--r-lg);
}

.bubble-sender {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 4px;
    color: var(--text-faint);
}

.bubble.right .bubble-sender {
    color: rgba(6, 203, 63, 0.6);
}

.bubble.system .bubble-sender {
    color: var(--text-faint);
}

.bubble-body {
    color: var(--text);
}

.bubble-meta {
    display: block;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-faint);
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
}

.bubble.right .bubble-meta {
    justify-content: flex-end;
}

.bubble.system .bubble-meta {
    justify-content: center;
}

/* ============================================================
   UTILITY
   ============================================================ */
.title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.muted {
    color: var(--text-muted);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

.count-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-faint);
}


.footer {
    text-align: center;
    padding: 30px;
    color: #6b7280;
}