/* ============================================================
   Kombot Monitor — Design System v2
   Google Material / Admin Console aesthetic
   ============================================================ */

:root {
    /* Brand */
    --primary:        #f28c00;
    --primary-dark:   #e07c00;
    --primary-light:  #fff3e0;
    --secondary:      #1a8944;

    /* Surfaces */
    --bg:             #f1f3f4;
    --bg-card:        #ffffff;
    --bg-sidebar:     #ffffff;

    /* Text */
    --text:           #202124;
    --text-secondary: #5f6368;
    --text-muted:     #80868b;

    /* Borders */
    --border:         #e8eaed;
    --border-light:   #f1f3f4;

    /* Semantic */
    --success:  #188038;
    --warning:  #f9ab00;
    --danger:   #d93025;
    --info:     #1a73e8;

    /* Elevation — Google formula */
    --shadow-1: 0 1px 2px rgba(60,64,67,.15), 0 1px 3px rgba(60,64,67,.08);
    --shadow-2: 0 1px 3px rgba(60,64,67,.20), 0 2px 8px rgba(60,64,67,.12);
    --shadow-3: 0 2px 6px rgba(60,64,67,.20), 0 4px 16px rgba(60,64,67,.12);
    /* legacy */
    --shadow:    var(--shadow-1);
    --shadow-lg: var(--shadow-3);

    /* Shape */
    --radius:    8px;
    --radius-sm: 4px;
    --radius-lg: 12px;

    /* Layout */
    --sidebar-width:  256px;
    --topbar-height:  64px;

    /* Font */
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Login
   ============================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.login-container { width: 100%; max-width: 420px; padding: 24px; }
.login-brand {
    text-align: center;
    margin-bottom: 32px;
}
.login-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 48px;
    background: var(--primary);
    border-radius: 12px;
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    margin-bottom: 12px;
}
.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.login-brand p { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2);
    border: 1px solid var(--border);
    padding: 36px;
}
.login-header { margin-bottom: 24px; }
.login-header h2 { font-size: 1.125rem; font-weight: 600; color: var(--text); }
.login-header p { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}
.login-form input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-card);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(242,140,0,0.12);
}

/* ---- Alerts ---- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.8rem;
    font-weight: 500;
}
.alert-error  { background: #fce8e6; color: #c5221f; border: 1px solid #f5c6c2; }
.alert-success { background: #e6f4ea; color: #137333; border: 1px solid #b7dfbe; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: background 0.15s, box-shadow 0.15s, color 0.15s;
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-2); }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--primary-light); border-color: var(--primary); }
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; box-shadow: var(--shadow-1); }
.btn-danger:hover { background: #b5281e; box-shadow: var(--shadow-2); }
.btn-sm { padding: 0 12px; height: 30px; font-size: 0.775rem; }
.btn-full { width: 100%; }
/* Icon button */
.btn-icon {
    width: 36px; height: 36px; padding: 0;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.active { color: var(--primary); background: var(--primary-light); }

/* ============================================================
   App layout
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }

/* ============================================================
   Sidebar — light, Google Admin Console style
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Header — aligns with topbar height */
.sidebar-header {
    height: var(--topbar-height);
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.sidebar-brand-mark {
    width: 30px; height: 30px;
    background: var(--primary);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}
.sidebar-brand-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.sidebar-brand-name span { color: var(--primary); }
.sidebar-close {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 50%;
}
.sidebar-close:hover { background: var(--bg); }

/* Nav */
.sidebar-nav { padding: 10px 10px; flex: 1; }
.nav-section { margin-bottom: 2px; }
.nav-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 10px 4px;
    display: block;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    height: 40px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8375rem;
    font-weight: 500;
    border-radius: 20px;
    margin-bottom: 1px;
    transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}
.nav-icon {
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    color: inherit;
    opacity: 0.8;
}
.nav-item.active .nav-icon { opacity: 1; color: var(--primary); }
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 10px;
}

/* Footer */
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 12px 14px;
    flex-shrink: 0;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--radius);
    transition: background 0.12s;
    cursor: default;
}
.sidebar-user:hover { background: var(--bg); }
.sidebar-user__avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem;
    flex-shrink: 0;
    letter-spacing: 0;
}
.sidebar-user__info { min-width: 0; }
.sidebar-user__name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user__role {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   Main area
   ============================================================ */
.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
    flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topbar-center { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 50%;
    transition: background 0.12s;
}
.hamburger:hover { background: var(--bg); color: var(--text); }

.page-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

/* User pill in topbar */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px 4px 4px;
    border-radius: 20px;
    transition: background 0.12s;
    cursor: default;
}
.topbar-user:hover { background: var(--bg); }
.topbar-user__avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.75rem;
    flex-shrink: 0;
}
.topbar-user__name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ============================================================
   Period selector
   ============================================================ */
.period-selector {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg);
    border-radius: 20px;
    padding: 3px;
    border: 1px solid var(--border);
}
.period-btn {
    padding: 4px 14px;
    border: none;
    border-radius: 16px;
    background: transparent;
    font-size: 0.775rem;
    font-weight: 500;
    font-family: var(--font);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.period-btn:hover { color: var(--text); background: rgba(0,0,0,0.04); }
.period-btn.active {
    background: var(--bg-card);
    color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow-1);
}
.period-custom-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 6px;
    padding-left: 8px;
    border-left: 1px solid var(--border);
}
.period-custom-inputs input[type="date"] {
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.775rem;
    font-family: var(--font);
    width: 128px;
    color: var(--text);
}
.period-custom-inputs input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
}
.period-custom-inputs span { color: var(--text-muted); font-size: 0.775rem; }

/* ============================================================
   Content
   ============================================================ */
.content { padding: 24px; flex: 1; }

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--border);
    padding: 20px 24px;
    margin-bottom: 20px;
    transition: box-shadow 0.15s;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}
.card-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* ============================================================
   KPI Grid
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--border);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow 0.15s;
}
.kpi-card:hover { box-shadow: var(--shadow-2); }
.kpi-label {
    font-size: 0.775rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}
.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    letter-spacing: -0.03em;
    /* remove gradient from v1 */
    background: none;
    -webkit-text-fill-color: var(--text);
    background-clip: unset;
}
.kpi-value.accent {
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
}

/* ============================================================
   Charts grid
   ============================================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.chart-container { position: relative; height: 280px; }

/* ============================================================
   Tables
   ============================================================ */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: var(--bg);
    padding: 10px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8375rem;
    color: var(--text);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8f9fa; }
tbody tr.clickable { cursor: pointer; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.badge-in      { background: #e6f4ea; color: #137333; }
.badge-out     { background: #e8f0fe; color: #1a73e8; }
.badge-error   { background: #fce8e6; color: #c5221f; }
.badge-warning { background: #fef7e0; color: #b06000; }
.badge-info    { background: #e8f0fe; color: #1558d6; }
.badge-debug   { background: var(--bg); color: var(--text-secondary); }
.badge-success { background: #e6f4ea; color: #137333; }

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    gap: 0;
}
.tab {
    padding: 0 20px;
    height: 44px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.8375rem;
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
    background: none;
    font-family: var(--font);
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    gap: 7px;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   Filter bar
   ============================================================ */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.filter-bar input,
.filter-bar select {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-card);
    height: 34px;
}
.filter-bar input:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(242,140,0,0.1);
}

/* ============================================================
   Chat Bubbles
   ============================================================ */
.chat-list { max-height: 600px; overflow-y: auto; padding: 10px; }
.chat-bubble {
    max-width: 70%;
    padding: 9px 13px 7px;
    border-radius: 18px;
    margin-bottom: 3px;
    font-size: 0.875rem;
    line-height: 1.5;
    position: relative;
    animation: bubbleIn 0.18s ease-out;
}
@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chat-bubble.incoming {
    background: #ffffff;
    border-bottom-left-radius: 5px;
    margin-right: auto;
    box-shadow: 0 1px 1px rgba(0,0,0,0.08);
    color: var(--text);
}
.chat-bubble.outgoing {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 5px;
    margin-left: auto;
    box-shadow: 0 1px 1px rgba(242,140,0,0.2);
}
.chat-meta {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 3px;
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    opacity: 0.8;
}
.chat-bubble.outgoing .chat-meta { color: rgba(255,255,255,0.75); }
.chat-bubble + .chat-bubble.incoming,
.chat-bubble + .chat-bubble.outgoing { margin-bottom: 3px; }
.chat-bubble.last-in-group.incoming  { border-bottom-left-radius: 18px; margin-bottom: 10px; }
.chat-bubble.last-in-group.outgoing  { border-bottom-right-radius: 18px; margin-bottom: 10px; }

/* ============================================================
   Conversation layout
   ============================================================ */
.conv-layout {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--border);
    overflow: hidden;
    height: calc(100vh - 175px);
    min-height: 540px;
}

/* Sidebar */
.conv-sidebar {
    width: 340px;
    min-width: 280px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: #fafbfc;
}
.conv-sidebar-header {
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
    background: #fff;
}
.conv-sidebar-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.conv-sidebar-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    padding: 1px 8px;
    border-radius: 10px;
    letter-spacing: 0;
}
.conv-search-wrap { position: relative; }
.conv-search-icon {
    position: absolute;
    left: 11px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    line-height: 1;
    display: flex;
}
.conv-search {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border);
    border-radius: 22px;
    font-size: 0.8rem;
    font-family: var(--font);
    outline: none;
    background: var(--bg);
    transition: border-color 0.15s, box-shadow 0.15s;
    color: var(--text);
}
.conv-search::placeholder { color: #aab4c0; }
.conv-search:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(242,140,0,0.1);
    background: #fff;
}
.conv-user-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #e0e4ea transparent;
}
.conv-user-list::-webkit-scrollbar { width: 4px; }
.conv-user-list::-webkit-scrollbar-thumb { background: #dde1e8; border-radius: 4px; }
.conv-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    transition: background 0.12s ease;
}
.conv-user-item:hover { background: rgba(0,0,0,0.03); }
.conv-user-item.active {
    background: rgba(242,140,0,0.07);
    border-left: 3px solid var(--primary);
    padding-left: 11px;
}
.conv-user-item.active .conv-user-name { color: var(--primary-dark); }
.conv-user-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
    flex-shrink: 0; letter-spacing: 0.5px;
}
.conv-user-info { flex: 1; min-width: 0; }
.conv-user-name {
    font-weight: 600; font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 1.3;
}
.conv-user-preview {
    font-size: 0.775rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 2px; line-height: 1.3;
}
.conv-user-meta {
    text-align: right; flex-shrink: 0;
    display: flex; flex-direction: column;
    align-items: flex-end; gap: 5px;
}
.conv-user-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.conv-user-item.active .conv-user-time { color: var(--primary); }
.conv-user-badge {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary); color: #fff;
    font-size: 0.62rem; font-weight: 700;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px;
}

/* Chat area */
.conv-chat-area {
    flex: 1; display: flex; flex-direction: column;
    min-width: 0; background: #fff;
}
.conv-chat-header {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    background: #fff; min-height: 62px; gap: 12px;
}
.conv-chat-header-left {
    display: flex; align-items: center;
    gap: 12px; min-width: 0; flex: 1;
}
.conv-chat-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.875rem; flex-shrink: 0;
    background: var(--primary);
}
.conv-chat-header-info {
    display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.conv-chat-header-info strong {
    font-size: 0.9rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-chat-header-info small { font-size: 0.72rem; color: var(--text-muted); }
.conv-chat-header-actions {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.conv-icon-btn {
    width: 32px; height: 32px; border-radius: 50%;
    border: none; background: transparent; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.conv-icon-btn:hover { background: var(--bg); color: var(--text); }
.conv-icon-btn.active { color: var(--primary); background: var(--primary-light); }
.conv-refresh-label {
    font-size: 0.72rem; color: var(--text-muted); white-space: nowrap;
}
.conv-chat-messages {
    flex: 1; overflow-y: auto;
    padding: 20px 18px;
    display: flex; flex-direction: column;
    background: #f4f6f8;
    scrollbar-width: thin;
    scrollbar-color: #d1d9e0 transparent;
}
.conv-chat-messages::-webkit-scrollbar { width: 5px; }
.conv-chat-messages::-webkit-scrollbar-thumb { background: #cdd5de; border-radius: 5px; }
.conv-chat-messages .chat-bubble {
    max-width: 62%;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.conv-date-separator {
    text-align: center; margin: 14px 0 10px;
    display: flex; align-items: center; gap: 10px;
    font-size: 0.7rem; color: var(--text-muted);
}
.conv-date-separator::before,
.conv-date-separator::after {
    content: ''; flex: 1; height: 1px; background: rgba(0,0,0,0.08);
}
.conv-date-separator span {
    background: #e8ecf0; color: #667587;
    padding: 3px 12px; border-radius: 12px;
    font-weight: 500; white-space: nowrap; letter-spacing: 0.02em;
}
.conv-empty-chat {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px; color: var(--text-muted);
    background: #f4f6f8; padding: 40px;
}
.conv-empty-chat-icon {
    width: 72px; height: 72px; border-radius: 50%;
    background: rgba(0,0,0,0.05);
    display: flex; align-items: center; justify-content: center;
}
.conv-empty-chat p {
    font-size: 0.9rem; font-weight: 500;
    color: #8896a4; text-align: center;
}
.conv-empty-chat small { font-size: 0.775rem; color: #aab4c0; text-align: center; }

/* Skeleton loader */
.conv-skeleton-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}
.skeleton-circle {
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite; flex-shrink: 0;
}
.skeleton-lines { flex: 1; }
.skeleton-line {
    height: 10px; border-radius: 5px;
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite; margin-bottom: 7px;
}
.skeleton-line:last-child { width: 60%; margin-bottom: 0; }
@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* Mobile conversation */
@media (max-width: 768px) {
    .conv-layout { flex-direction: column; height: auto; }
    .conv-sidebar { width: 100%; min-width: 0; max-height: 260px; border-right: none; border-bottom: 1px solid var(--border); }
    .conv-chat-messages { min-height: 400px; }
    .conv-chat-messages .chat-bubble { max-width: 80%; }
}

/* ============================================================
   Question groups
   ============================================================ */
.q-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.q-group:hover { box-shadow: var(--shadow-1); }
.q-group-header {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    background: #fafbfc;
    gap: 12px;
}
.q-group-header:hover { background: #f5f6fa; }
.q-group-left { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; }
.q-group-rank { font-weight: 700; font-size: 0.875rem; color: var(--primary); flex-shrink: 0; width: 28px; }
.q-group-topic { margin-bottom: 3px; }
.q-group-representative {
    font-size: 0.8rem; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 500px;
}
.q-group-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.q-group-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.q-group-count { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.q-group-users { font-size: 0.72rem; color: var(--text-muted); }
.q-group-chevron { font-size: 0.65rem; color: var(--text-muted); transition: transform 0.2s; }
.q-group.open .q-group-chevron { transform: rotate(180deg); }
.q-group-body { display: none; padding: 0 16px 16px; border-top: 1px solid var(--border); }
.q-group.open .q-group-body { display: block; }
.q-group-period { font-size: 0.775rem; color: var(--text-muted); padding: 10px 0 8px; }
.q-group-samples { margin-top: 8px; }
.q-group-samples strong { font-size: 0.775rem; display: block; margin-bottom: 8px; }
.q-sample {
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    border-left: 3px solid var(--primary);
}
.q-sample-content { font-size: 0.8rem; line-height: 1.45; }
.q-sample-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 3px; }

/* ============================================================
   Trending
   ============================================================ */
.trending-list { padding: 4px 0; }
.trending-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
}
.trending-item:last-child { border-bottom: none; }
.trending-rank {
    font-weight: 700; font-size: 0.9rem;
    color: var(--text-muted); width: 22px;
    text-align: center; flex-shrink: 0;
}
.trending-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.trending-info strong { font-size: 0.8375rem; }
.trending-info small { font-size: 0.72rem; color: var(--text-muted); }

/* ============================================================
   Coverage matrix
   ============================================================ */
.coverage-matrix { overflow-x: auto; }
.coverage-matrix table { font-size: 0.775rem; }
.coverage-matrix th { position: sticky; top: 0; z-index: 2; }
.coverage-cell { text-align: center; min-width: 50px; }
.coverage-0   { background: #fce8e6; color: #c5221f; }
.coverage-low  { background: #fef7e0; color: #b06000; }
.coverage-good { background: #e6f4ea; color: #137333; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex; align-items: center;
    justify-content: center; gap: 12px;
    margin-top: 20px; padding-top: 16px;
    border-top: 1px solid var(--border);
}
.pagination-info { font-size: 0.8rem; color: var(--text-muted); }

/* ============================================================
   Loading & spinner
   ============================================================ */
.loading {
    display: flex; align-items: center;
    justify-content: center;
    padding: 40px; color: var(--text-muted);
    font-size: 0.8rem; gap: 10px;
}
.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state p { font-size: 0.875rem; font-weight: 500; }

/* ============================================================
   Detail panel (slide-in)
   ============================================================ */
.detail-panel {
    position: fixed;
    top: 0; right: -500px;
    width: 500px; height: 100vh;
    background: var(--bg-card);
    box-shadow: -2px 0 24px rgba(60,64,67,0.15);
    z-index: 200;
    transition: right 0.25s ease;
    overflow-y: auto;
    display: flex; flex-direction: column;
}
.detail-panel.open { right: 0; }
.detail-panel-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    justify-content: space-between;
    position: sticky; top: 0;
    background: var(--bg-card); z-index: 1;
    flex-shrink: 0;
}
.detail-panel-body { padding: 20px; flex: 1; }
.detail-close {
    background: none; border: none;
    cursor: pointer; color: var(--text-muted);
    padding: 6px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s, color 0.12s;
}
.detail-close:hover { background: var(--bg); color: var(--text); }
.overlay {
    position: fixed; inset: 0;
    background: rgba(32,33,36,0.32);
    z-index: 150; display: none;
    backdrop-filter: blur(1px);
}
.overlay.show { display: block; }

/* ============================================================
   Settings form
   ============================================================ */
.settings-form { max-width: 560px; }
.settings-form .form-group { margin-bottom: 18px; }
.settings-form label {
    display: block; font-weight: 500;
    margin-bottom: 6px; font-size: 0.8rem;
    color: var(--text-secondary);
}
.settings-form input,
.settings-form select {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text);
}
.settings-form input:focus,
.settings-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(242,140,0,0.1);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(32,33,36,0.45);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-3);
    width: 100%; max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    animation: modalIn 0.2s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.97) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal__header {
    display: flex; align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.modal__header h3 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.modal__close {
    background: none; border: none;
    cursor: pointer; color: var(--text-muted);
    padding: 4px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.12s, color 0.12s;
}
.modal__close:hover { background: var(--bg); color: var(--text); }

/* ============================================================
   Roles grid
   ============================================================ */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.role-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    border: 1px solid var(--border);
    padding: 18px 20px;
    transition: box-shadow 0.15s;
}
.role-card:hover { box-shadow: var(--shadow-2); }
.role-card--system { border-color: var(--primary); border-width: 2px; }
.role-card__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; gap: 8px; }
.role-card__name { font-size: 0.9375rem; font-weight: 700; color: var(--text); }
.role-card__slug {
    font-size: 0.7rem; color: var(--text-secondary);
    background: var(--bg); padding: 2px 7px;
    border-radius: var(--radius-sm); white-space: nowrap;
}
.role-card__desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 14px; }
.role-card__perms { margin-bottom: 14px; }
.role-card__perm-group { margin-bottom: 8px; }
.role-card__perm-label {
    font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); display: block; margin-bottom: 4px;
}
.role-card__actions {
    display: flex; gap: 8px;
    padding-top: 12px; border-top: 1px solid var(--border);
}

/* ============================================================
   Permission pills
   ============================================================ */
.perm-pill {
    display: inline-block;
    padding: 2px 8px; border-radius: 10px;
    font-size: 0.7rem; font-weight: 600;
    margin: 2px 2px 2px 0;
}
.perm-pill--on  { background: #e6f4ea; color: #137333; }
.perm-pill--off { background: var(--bg); color: #9aa0a6; text-decoration: line-through; }

/* ============================================================
   Permission checkboxes
   ============================================================ */
.perm-section { margin: 16px 0 20px; }
.perm-section__title { font-weight: 600; font-size: 0.875rem; margin-bottom: 12px; }
.perm-group { margin-bottom: 16px; }
.perm-group__label {
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); margin-bottom: 8px;
}
.perm-checkboxes { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
.perm-checkbox {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    font-size: 0.8rem;
}
.perm-checkbox:hover { background: var(--bg); }
.perm-checkbox input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; accent-color: var(--primary); }
.perm-checkbox input[type="checkbox"]:checked + .perm-checkbox__name { color: var(--secondary); }
.perm-checkbox__name { font-weight: 600; display: block; }
.perm-checkbox__desc { font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 1px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-3); }
    .sidebar-close { display: flex; }
    .hamburger { display: flex; }
    .main-area { margin-left: 0; }
    .charts-grid { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-panel { width: 100%; right: -100%; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .topbar { padding: 0 16px; }
    .content { padding: 16px; }
    .topbar-center { display: none; }
}
