@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

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

:root {
    --primary: #1E3A5F;
    --primary-dark: #152C4A;
    --primary-light: #E8EDF5;
    --success: #059669;
    --success-light: #D1FAE5;
    --warning: #D97706;
    --warning-light: #FEF3C7;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --gray-50: #F8FAFC;
    --gray-100: #F1F5F9;
    --gray-200: #E4E7EB;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;
    --gray-900: #0F172A;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --font: 'Fira Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', monospace;
    --header-h: 56px;
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 16px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================== HEADER ===================== */
.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 16px;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--gray-900);
}
.header-logo svg { flex-shrink: 0; width: 24px; height: 24px; }
.header-nav { display: flex; align-items: center; gap: 10px; }
.header-nav a, .header-nav button {
    font-size: 0.85rem;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}
.header-nav a:hover, .header-nav button:hover { background: var(--gray-100); color: var(--gray-900); text-decoration: none; }
.header-nav .btn-primary { background: var(--primary); color: white; }
.header-nav .btn-primary:hover { background: var(--primary-dark); color: white; }
.user-badge { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--gray-600); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.75rem;
}

@media (max-width: 640px) {
    .header { padding: 0 12px; }
    .header-logo { font-size: 0.9rem; gap: 6px; }
    .header-logo svg { width: 20px; height: 20px; }
    .header-nav { gap: 6px; }
    .header-nav a, .header-nav button { padding: 6px 10px; font-size: 0.8rem; }
    .user-badge span:last-child { display: none; }
    .header-nav > a:not(.hamburger-btn):not(.keep-mobile),
    .header-nav > .user-badge,
    .header-nav > .btn:not(.hamburger-btn):not(.keep-mobile) {
        display: none !important;
    }
    .hamburger-menu { display: block; }
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1;
    min-height: 44px;
    touch-action: manipulation;
}
.btn-sm { padding: 8px 14px; font-size: 0.8rem; min-height: 36px; }
.btn-lg { padding: 16px 32px; font-size: 1.05rem; min-height: 52px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline { background: white; border: 1px solid var(--primary); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--primary-dark); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-block { width: 100%; }

@media (max-width: 640px) {
    .btn { padding: 10px 16px; font-size: 0.85rem; }
    .btn-sm { padding: 7px 12px; font-size: 0.78rem; min-height: 34px; }
    .btn-lg { padding: 14px 24px; font-size: 0.95rem; min-height: 48px; }
}

/* ===================== CARDS ===================== */
.card { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--gray-200); font-weight: 600; font-size: 0.85rem; display: flex; align-items: center; justify-content: space-between; letter-spacing: 0.02em; }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--gray-200); display: flex; gap: 8px; }

/* ===================== REQUEST CARDS (tech panel) ===================== */
.request-card {
    background: white; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 10px 14px;
    display: flex; align-items: center; gap: 12px; transition: box-shadow 0.15s, border-color 0.15s;
}
.request-card:hover { border-color: var(--gray-300); box-shadow: var(--shadow); }
.request-card-available { border-color: var(--warning); background: #fffbeb; }
.request-card-head { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; flex-shrink: 0; }
.request-card-id { font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem; color: var(--gray-700); }
.request-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.request-card-name { font-weight: 600; font-size: 0.88rem; color: var(--gray-800); }
.request-card-problem { font-size: 0.78rem; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.request-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
@media (max-width: 640px) {
    .request-card { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
    .request-card-head { flex-direction: row; min-width: 0; gap: 8px; width: 100%; }
    .request-card-body { width: 100%; }
    .request-card-actions { width: 100%; justify-content: flex-end; }
    .request-card-actions .btn { min-height: 36px; padding: 6px 12px; font-size: 0.78rem; }
}

/* ===================== STATUS ===================== */
.status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 20px;
    font-size: 0.72rem; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.status-pending { background: var(--warning-light); color: #B45309; }
.status-in_progress { background: var(--primary-light); color: var(--primary); }
.status-resolved { background: var(--success-light); color: #047857; }
.status-closed { background: var(--gray-100); color: var(--gray-500); }
.status-on_hold { background: #FEF3C7; color: #D97706; }

/* ===================== LAYOUTS ===================== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.page { padding: 20px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ===================== FORMS ===================== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-input {
    width: 100%; padding: 12px 14px;
    border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
    font-size: 0.9rem; font-family: inherit;
    transition: border-color 0.15s;
    min-height: 44px;
}
.form-input-lg { padding: 14px 16px; font-size: 0.95rem; }
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,95,0.12); }
select.form-input { cursor: pointer; }

@media (max-width: 640px) {
    .form-input { font-size: 16px; /* prevent iOS zoom */ padding: 10px 12px; }
    .form-input-lg { font-size: 16px; padding: 12px 14px; }
}

/* ===================== HOME / HERO ===================== */
.hero { text-align: center; padding: 56px 20px 40px; max-width: 720px; margin: 0 auto; }
.hero h1 { font-size: 1.8rem; font-weight: 700; color: var(--gray-900); margin-bottom: 14px; line-height: 1.25; }
.hero p { font-size: 1rem; color: var(--gray-500); margin-bottom: 28px; line-height: 1.6; }
.hero .btn { margin: 4px; }

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 16px;
    padding: 0 16px 56px;
    max-width: 960px;
    margin: 0 auto;
}
.feature-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 24px 20px; text-align: center; transition: box-shadow 0.2s; }
.feature-card:hover { box-shadow: var(--shadow-lg); }
.feature-card .icon { width: 48px; height: 48px; margin: 0 auto 14px; background: var(--primary-light); border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--primary); }
.feature-card .icon svg { width: 24px; height: 24px; }
.feature-card h3 { font-size: 0.95rem; margin-bottom: 8px; color: var(--gray-900); }
.feature-card p { font-size: 0.85rem; color: var(--gray-500); line-height: 1.5; }

@media (max-width: 640px) {
    .hero { padding: 36px 16px 28px; }
    .hero h1 { font-size: 1.45rem; }
    .hero p { font-size: 0.9rem; margin-bottom: 20px; }
    .features { gap: 12px; padding: 0 16px 40px; }
    .feature-card { padding: 20px 16px; }
    .feature-card .icon { width: 40px; height: 40px; }
    .feature-card .icon svg { width: 20px; height: 20px; }
    .feature-card h3 { font-size: 0.88rem; }
    .feature-card p { font-size: 0.8rem; }
}

/* ===================== CHAT ===================== */
.chat-container { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - var(--header-h)); }
.chat-header { padding: 14px 20px; background: white; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.chat-header h2 { font-size: 0.95rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; background: var(--gray-50); }
.msg {
    max-width: 75%; padding: 10px 14px;
    border-radius: 12px; font-size: 0.875rem; line-height: 1.5;
    animation: fadeIn 0.2s ease-out;
    word-break: break-word;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.msg-system { align-self: center; background: var(--gray-100); color: var(--gray-500); font-size: 0.78rem; max-width: 90%; text-align: center; }
.msg-user { align-self: flex-end; background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.msg-technician, .msg-admin { align-self: flex-start; background: white; border: 1px solid var(--gray-200); border-bottom-left-radius: 4px; }
.msg-technician .sender, .msg-admin .sender { color: var(--primary); }
.msg-user .sender { color: rgba(255,255,255,0.75); font-weight: 500; }
.msg .sender { font-size: 0.68rem; font-weight: 600; margin-bottom: 3px; opacity: 0.8; }
.msg-user .sender { color: rgba(255,255,255,0.8); }
.msg .time { font-size: 0.62rem; opacity: 0.6; margin-top: 4px; }
.msg .attachment-link { display: inline-block; margin-top: 6px; padding: 5px 10px; background: var(--gray-100); border-radius: 6px; font-size: 0.78rem; }

.chat-input-area { padding: 12px 20px; background: white; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; align-items: flex-end; }
.chat-input-area textarea { flex: 1; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 0.875rem; font-family: inherit; resize: none; min-height: 44px; max-height: 120px; }
.chat-input-area textarea:focus { outline: none; border-color: var(--primary); }

@media (max-width: 640px) {
    .chat-messages { padding: 12px 14px; gap: 8px; }
    .msg { max-width: 85%; font-size: 0.85rem; padding: 9px 12px; }
    .chat-input-area { padding: 10px 12px; gap: 8px; }
    .chat-input-area textarea { font-size: 16px; min-height: 40px; }
}

/* ===================== TABLE ===================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--gray-200); }
th { font-weight: 600; color: var(--gray-600); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; background: var(--gray-50); white-space: nowrap; }
tr:hover td { background: var(--gray-50); }
td:first-child { font-family: var(--font-mono); font-weight: 500; font-size: 0.82rem; }

@media (max-width: 640px) {
    table { font-size: 0.8rem; }
    th, td { padding: 10px 12px; }
}

/* ===================== STATS ===================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 16px; transition: box-shadow 0.2s, border-color 0.2s; }
.stat-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--gray-900); font-family: var(--font-mono); }
.stat-card .stat-label { font-size: 0.75rem; color: var(--gray-500); margin-top: 2px; }

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 110px), 1fr)); gap: 10px; }
    .stat-card { padding: 12px; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .stat-card .stat-label { font-size: 0.7rem; }
}

/* ===================== MODAL ===================== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal { background: white; border-radius: var(--radius); max-width: 640px; width: 100%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: white; z-index: 1; }
.modal-header h3 { font-size: 0.95rem; }
.modal-body { padding: 18px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: white; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray-400); padding: 4px 8px; min-width: 36px; min-height: 36px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { color: var(--gray-600); }

@media (max-width: 640px) {
    .modal-overlay { padding: 0; }
    .modal { max-width: 100%; max-height: 100vh; border-radius: 0; height: 100vh; }
    .modal-header { padding: 12px 14px; }
    .modal-body { padding: 14px; }
    .modal-footer { padding: 10px 14px; }
}

/* ===================== FLASH ===================== */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 0.85rem; }
.flash-info { background: var(--primary-light); color: var(--primary); }
.flash-error { background: var(--danger-light); color: var(--danger); }
.flash-success { background: var(--success-light); color: var(--success); }

/* ===================== LOGIN ===================== */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: white; border: 1px solid var(--gray-200); border-radius: 12px; padding: 32px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 1.35rem; text-align: center; margin-bottom: 6px; }
.auth-card p { text-align: center; color: var(--gray-500); margin-bottom: 20px; font-size: 0.85rem; }

@media (max-width: 640px) {
    .auth-card { padding: 22px; }
    .auth-card h1 { font-size: 1.1rem; }
    .auth-card p { font-size: 0.8rem; margin-bottom: 16px; }
}

/* ===================== NOTIFICATION ===================== */
.notif-dot { width: 8px; height: 8px; background: var(--danger); border-radius: 50%; display: inline-block; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===================== PRINT ===================== */
@media print {
    .header, .chat-input-area, .no-print, .chat-overlay { display: none !important; }
    body { background: white; }
    .chat-container { height: auto; }
    .msg-tech, .msg-admin { border: 1px solid #ccc; }
}

/* ===================== SPINNER ===================== */
.spinner { width: 20px; height: 20px; border: 2px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== TABS ===================== */
.tabs { display: flex; border-bottom: 1px solid var(--gray-200); margin-bottom: 16px; gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab {
    padding: 12px 16px; font-size: 0.85rem; font-weight: 500;
    color: var(--gray-500); cursor: pointer; border-bottom: 2px solid transparent;
    transition: all 0.15s; background: none; border-top: none; border-left: none; border-right: none;
    font-family: inherit; white-space: nowrap; min-height: 40px;
}
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

@media (max-width: 640px) {
    .tab { padding: 10px 12px; font-size: 0.8rem; }
}

/* ===================== CHAT POPUP OVERLAY ===================== */
.chat-overlay { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; }
.chat-popup {
    width: 100%; max-width: 800px; height: 90vh;
    background: white; border-radius: 12px; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); margin: 20px;
}
.chat-popup-header { padding: 12px 18px; background: white; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 8px; }
.chat-popup-header h2 { font-size: 0.9rem; }
.chat-popup-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-popup-body .chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; background: var(--gray-50); }
.chat-popup-body .chat-input-area { padding: 10px 18px; background: white; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; align-items: flex-end; flex-shrink: 0; }
#newRequestFlow { flex: 1; min-height: 0; }

.chat-input-wrap { flex: 1; display: flex; align-items: flex-end; position: relative; }
.chat-input-wrap textarea { flex: 1; padding-right: 40px; min-height: 42px; resize: none; }
.chat-attach { position: absolute; right: 6px; bottom: 6px; cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.chat-attach:hover { background: var(--gray-100); }
.chat-send { width: 42px; height: 42px; border-radius: 50%; background: var(--primary); color: white; border: none; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; transition: background 0.15s; }
.chat-send:hover { background: var(--primary-dark); }
.chat-send:disabled { opacity: 0.4; cursor: default; }

@media (max-width: 640px) {
    .chat-popup { height: 100vh; height: 100dvh; margin: 0; border-radius: 0; }
    .chat-popup-header { padding: 10px 14px; flex-wrap: wrap; }
    .chat-popup-header h2 { font-size: 0.85rem; }
    .chat-popup-header .btn { padding: 7px 10px; font-size: 0.78rem; min-height: 32px; }
    .chat-popup-body .chat-messages { padding: 12px 14px; gap: 8px; }
    .chat-popup-body .chat-input-area { padding: 8px 12px; gap: 6px; }
    #newRequestFlow { flex: 1; min-height: 0; max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px); }
    .chat-send { width: 38px; height: 38px; }
    .chat-send svg { width: 18px; height: 18px; }
}

/* ===================== STEP PROGRESS (chat creation flow) ===================== */
.step-progress { display: flex; gap: 4px; margin-bottom: 20px; }
.step-dot { height: 6px; flex: 1; border-radius: 3px; background: var(--gray-200); transition: all 0.2s; }
.step-dot.active { background: var(--primary); }
.step-dot.done { background: var(--success); }
.step-question { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.step-icon { font-size: 1.5rem; flex-shrink: 0; }
.step-label { font-size: 0.95rem; font-weight: 600; color: var(--gray-800); }
.step-info { font-size: 0.78rem; color: var(--gray-400); margin-top: 10px; }
.autosave-info { font-size: 0.72rem; color: var(--gray-400); margin-top: 2px; }
.btn-block { width: 100%; }

@media (max-width: 640px) {
    .step-icon { font-size: 1.25rem; }
    .step-label { font-size: 0.88rem; }
    .step-info, .autosave-info { font-size: 0.72rem; }
}

/* ===================== VIEW GRID (modal info display) ===================== */
.view-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.view-item { padding: 10px 14px; background: var(--gray-50); border-radius: var(--radius-sm); }
.view-label { font-size: 0.68rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; margin-bottom: 3px; }
.view-value { font-size: 0.88rem; font-weight: 500; }
.view-full { grid-column: 1/-1; }

@media (max-width: 640px) {
    .view-grid { grid-template-columns: 1fr; gap: 8px; }
}

/* ===================== MOBILE TABS (tech chat) ===================== */
.mobile-tabs { display: none; background: var(--gray-100); border-bottom: 1px solid var(--gray-200); }
.mobile-tab { flex: 1; padding: 10px; border: none; background: transparent; font-size: 0.82rem; font-weight: 500; color: var(--gray-500); cursor: pointer; font-family: inherit; transition: all 0.15s; text-align: center; }
.mobile-tab.active { background: white; color: var(--primary); font-weight: 600; box-shadow: inset 0 -2px 0 var(--primary); }

/* ===================== ADMIN/Tech split layout ===================== */
.split-page { display: grid; grid-template-columns: 1fr 340px; height: calc(100vh - var(--header-h)); }
.split-chat { display: flex; flex-direction: column; border-right: 1px solid var(--gray-200); overflow: hidden; }
.split-sidebar { display: flex; flex-direction: column; overflow-y: auto; padding: 18px; background: white; border-left: 1px solid var(--gray-200); }

@media (max-width: 900px) {
    .split-page { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: auto; min-height: calc(100vh - var(--header-h)); }
    .split-chat { height: 60vh; border-right: none; border-bottom: 1px solid var(--gray-200); }
    .split-sidebar { max-height: 40vh; }
}
@media (max-width: 640px) {
    .mobile-tabs { display: flex; }
    .split-page { grid-template-columns: 1fr; grid-template-rows: 1fr; height: calc(100vh - var(--header-h) - 41px); min-height: 0; }
    .split-chat { display: none; height: 100%; border-right: none; border-bottom: none; }
    .split-chat.active { display: flex; }
    .split-sidebar { display: none; max-height: none; padding: 14px; border-left: none; }
    .split-sidebar.active { display: flex; }
}

/* ===================== ADMIN SIDEBAR ===================== */
.admin-layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - var(--header-h)); }
.admin-sidebar { background: var(--gray-900); color: white; padding: 14px 0; }
.admin-sidebar .nav-item { display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: var(--gray-300); font-size: 0.85rem; cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-family: inherit; transition: all 0.15s; }
.admin-sidebar .nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.admin-sidebar .nav-item.active { background: var(--primary); color: white; font-weight: 500; }
.admin-sidebar .nav-item .icon { width: 20px; text-align: center; flex-shrink: 0; }
.admin-sidebar .nav-section { padding: 8px 20px; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gray-500); font-weight: 600; }
.admin-content { padding: 20px; overflow-y: auto; }
.admin-content h1 { font-size: 1.15rem; margin-bottom: 16px; }
.module { display: none; }
.module.active { display: block; }

.admin-mobile-nav { display: none; }

@media (max-width: 768px) {
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { display: none; }
    .admin-content { padding: 14px; padding-bottom: 80px; }
    .admin-content h1 { font-size: 1rem; }

    .admin-mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid var(--gray-200);
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }
    .admin-mobile-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 8px 2px;
        border: none;
        background: none;
        color: var(--gray-500);
        font-family: inherit;
        font-size: 0.65rem;
        cursor: pointer;
        transition: all 0.15s;
    }
    .admin-mobile-item .icon { stroke-width: 2; }
    .admin-mobile-item.active { color: white; background: var(--primary); }
}

/* ===================== CHART BAR ===================== */
.chart-bar-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 20px; }
.chart-bar { display: flex; align-items: end; gap: 4px; height: 140px; padding: 8px 0; }
.chart-bar-item { flex: 1; background: var(--primary-light); border-radius: 4px 4px 0 0; position: relative; min-height: 4px; min-width: 20px; transition: height 0.3s; }
.chart-bar-item:hover { background: var(--primary); }
.chart-bar-item .label { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 0.58rem; color: var(--gray-400); white-space: nowrap; }
.chart-bar-value { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 0.65rem; font-weight: 600; color: var(--gray-700); }

/* ===================== LOG LIST ===================== */
.log-list { max-height: 500px; overflow-y: auto; font-size: 0.8rem; }
.log-item { padding: 8px 12px; border-bottom: 1px solid var(--gray-100); display: flex; gap: 10px; align-items: start; }
.log-item:hover { background: var(--gray-50); }
.log-time { color: var(--gray-400); white-space: nowrap; font-size: 0.72rem; min-width: 70px; }
.log-action { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 0.66rem; font-weight: 500; text-transform: uppercase; min-width: 56px; text-align: center; }

/* ===================== TECH CARD ===================== */
.tech-card { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border: 1px solid var(--gray-200); border-radius: var(--radius); margin-bottom: 8px; background: white; }
.tech-card:hover { border-color: var(--primary); }

@media (max-width: 640px) {
    .tech-card { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
    .log-list { font-size: 0.85rem; padding: 0 2px; }
    .log-item {
        flex-direction: column;
        gap: 6px;
        padding: 12px;
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-sm);
        margin-bottom: 8px;
        background: white;
    }
    .log-item:last-child { margin-bottom: 0; border-bottom: 1px solid var(--gray-200); }
    .log-item:hover { background: var(--gray-50); }
    .log-time { font-size: 0.75rem; min-width: auto; }
    .log-action { align-self: flex-start; }
    .log-item strong { color: var(--gray-900); }

    /* Reports mobile */
    #reportContent .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
    #reportContent .stat-card { padding: 12px 8px; }
    #reportContent .stat-value { font-size: 1.3rem; }
    #reportContent .stat-label { font-size: 0.7rem; }
    #reportContent .table-wrap table { font-size: 0.78rem; }
    #reportContent th, #reportContent td { padding: 6px 8px; }
    #reportContent .card-header { font-size: 0.8rem; padding: 10px 12px; }
    .chart-bar-wrap { margin: 0 -4px; padding: 18px 4px 24px; }
    .chart-bar { height: 120px; gap: 6px; }
    .chart-bar-item { border-radius: 6px 6px 0 0; }
    .chart-bar-item .label { font-size: 0.6rem; bottom: -18px; }
    .chart-bar-value { font-size: 0.7rem; top: -18px; }
}

/* ===================== MOBILE HORIZONTAL SCROLL ===================== */
@media (max-width: 640px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .container { padding: 0 12px; }
    .page { padding: 14px 0; }
    h1 { font-size: 1.1rem !important; }
}

/* ===================== FLOATING CHAT BUTTON ===================== */
#floatingChat { position: fixed; bottom: 20px; right: 20px; z-index: 999; }
#floatingChatBtn {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px; background: var(--primary); color: white;
    border: none; border-radius: 50px;
    box-shadow: 0 4px 16px rgba(30,58,95,0.35);
    font-weight: 500; font-size: 0.85rem; cursor: pointer;
    transition: all 0.2s; font-family: inherit;
}
@media (max-width: 640px) {
    #floatingChat { bottom: 14px; right: 14px; }
    #floatingChatBtn { padding: 12px 16px; font-size: 0.8rem; gap: 8px; }
    #floatingChatLabel { display: none; }
    #floatingChatNotif { width: 12px; height: 12px; }
}

/* ===================== ATTACHMENTS LIST ===================== */
.attachments-list { margin-top: 10px; }
.attachments-list a { display: block; padding: 6px 10px; background: white; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); margin-bottom: 4px; font-size: 0.8rem; }
.attachments-list a:hover { border-color: var(--primary); text-decoration: none; }

/* ===================== STATUS: ON_HOLD ===================== */
.status-on_hold { background: #fef3c7; color: #d97706; }

/* ===================== PREDEFINED MESSAGES QUICK BAR ===================== */
.quickbar-toggle {
    padding: 6px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    cursor: pointer;
    color: var(--gray-600);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
}
.quickbar-toggle:hover { background: var(--gray-100); }

.quickbar-panel {
    max-height: 220px;
    overflow-y: auto;
    padding: 8px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}
.quickbar-category {
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 4px 4px 6px;
}
.quickbar-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--gray-700);
    font-family: inherit;
    margin-bottom: 4px;
    line-height: 1.4;
    transition: all 0.15s;
}
.quickbar-item:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

/* ===================== TYPING INDICATOR ===================== */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    align-self: flex-start;
    animation: fadeIn 0.2s ease-out;
}
.typing-indicator .typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-indicator .typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator .typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}
.typing-label {
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-left: 4px;
    margin-bottom: 2px;
    font-style: italic;
}

/* Hamburger menu */
.hamburger-menu { position: relative; }
.hamburger-btn {
    width: 46px; height: 46px;
    border: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--primary);
    font-size: 2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.hamburger-btn:hover { background: var(--gray-50); }
.hamburger-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    z-index: 100;
    overflow: hidden;
}
.hamburger-dropdown.open { display: block; }
.hamburger-dropdown .hamburger-user {
    padding: 12px 16px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 10px;
}
.hamburger-dropdown .hamburger-user .user-avatar {
    width: 32px; height: 32px;
    font-size: 0.75rem;
}
.hamburger-dropdown a, .hamburger-dropdown button.dd-link {
    display: block;
    padding: 10px 16px;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.1s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.hamburger-dropdown a:hover, .hamburger-dropdown button.dd-link:hover { background: var(--gray-50); }

/* Hamburger visible only on mobile */
@media (min-width: 641px) {
    .hamburger-menu { display: none; }
}

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.pagination-pages { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.pagination-btn {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 36px;
}
.pagination-btn:hover:not(:disabled) { background: var(--gray-50); border-color: var(--primary); color: var(--primary); }
.pagination-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.pagination-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination-info { font-size: 0.78rem; color: var(--gray-500); margin-left: 8px; }

@media (max-width: 640px) {
    .pagination { gap: 6px; }
    .pagination-btn { padding: 6px 10px; font-size: 0.8rem; min-width: 32px; }
    .pagination-info { width: 100%; text-align: center; margin-left: 0; margin-top: 6px; }
}

/* Uniform heading and text-field sizes */
h1, h2, h3, h4, h5, h6 { font-size: 1.1rem !important; }
.form-input, .form-input-lg, input.form-input, textarea.form-input, select.form-input {
    font-size: 0.9rem !important;
    padding: 12px 14px !important;
    min-height: 44px !important;
}
@media (max-width: 640px) {
    .form-input, .form-input-lg, input.form-input, textarea.form-input, select.form-input {
        font-size: 16px !important;
        padding: 10px 12px !important;
        min-height: 44px !important;
    }
}