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

:root {
    --bg-body:      #0d1117;
    --bg-surface:   #131a24;
    --bg-card:      #161d29;
    --bg-input:     #1c2433;
    --border:       #222d3d;
    --border-light: #2d3a4d;

    --accent:       #2ecc71;
    --accent-hover: #27ae60;
    --accent-dim:   rgba(46,204,113,.10);

    --danger:       #e74c3c;
    --warning:      #f39c12;
    --info:         #3498db;

    --text:         #c8d6e5;
    --text-muted:   #637893;
    --text-heading: #f0f4f8;

    --radius:       12px;
    --radius-sm:    8px;
    --radius-xs:    6px;

    --shadow:       0 4px 24px rgba(0,0,0,.4);
    --shadow-sm:    0 2px 8px rgba(0,0,0,.3);

    --sidebar-width: 260px;
    --navbar-height: 64px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; }

.icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
}
.icon-sm  { width: 16px; height: 16px; }
.icon-lg  { width: 24px; height: 24px; }
.icon-xl  { width: 28px; height: 28px; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0b1222 0%, #111b2e 50%, #152238 100%);
}
.auth-container { width: 100%; max-width: 520px; padding: 20px; }
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 8px; }
.auth-logo .logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px; height: 56px;
    border-radius: 14px;
    background: var(--accent-dim);
    margin: 0 auto 12px;
}
.auth-logo .logo-icon svg { width: 28px; height: 28px; stroke: var(--accent); }
.auth-logo h1 { font-size: 1.6rem; color: var(--accent); font-weight: 700; }
.auth-card h2 { text-align: center; font-size: 1.1rem; color: var(--text-muted); margin-bottom: 24px; font-weight: 400; }
.auth-footer-text { text-align: center; margin-top: 18px; font-size: .88rem; color: var(--text-muted); }

.layout { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s;
}
.sidebar-logo {
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
}
.sidebar-logo .logo-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--accent-dim);
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-logo .logo-icon svg { width: 20px; height: 20px; stroke: var(--accent); }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-section-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: 16px 16px 8px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: .9rem;
    transition: all .2s;
    margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--accent-dim); color: var(--text); }
.sidebar-nav a.active { background: var(--accent-dim); color: var(--accent); }
.sidebar-nav a .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-nav a .nav-icon svg { width: 18px; height: 18px; }
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logout-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--accent-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all .2s;
    flex-shrink: 0;
}
.sidebar-logout-btn:hover {
    background: rgba(231,76,60,.15);
    color: var(--danger);
}
.sidebar-logout-btn .nav-icon { width: 18px; height: 18px; }
.sidebar-logout-btn .nav-icon svg { width: 18px; height: 18px; }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.sidebar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem;
    flex-shrink: 0;
}
.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.sidebar-user-name {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-company {
    font-size: .72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.main-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: calc(100vw - var(--sidebar-width));
}

.navbar {
    height: var(--navbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
}
.navbar-left { display: flex; align-items: center; gap: 12px; }
.navbar-left h2 { font-size: 1.1rem; font-weight: 600; color: var(--text-heading); }
.navbar-right { display: flex; align-items: center; gap: 16px; }
.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: var(--bg-card);
    border-radius: 50px;
    border: 1px solid var(--border);
}
.navbar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
}
.navbar-user span { font-size: .88rem; color: var(--text); }
.hamburger {
    display: none;
    background: none; border: none;
    color: var(--text); font-size: 1.5rem;
    cursor: pointer;
}

.content { flex: 1; padding: 28px; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-heading); margin-bottom: 24px; }
.page-breadcrumb { font-size: .82rem; color: var(--text-muted); margin-bottom: 4px; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
}
.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-card .stat-icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--accent);
}
.stat-card .stat-info { flex: 1; }
.stat-card .stat-label {
    font-size: .78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 2px;
}
.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-heading);
    line-height: 1.2;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.chart-container h3 {
    font-size: 1rem;
    color: var(--text-heading);
    margin-bottom: 16px;
}

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: .88rem;
    font-weight: 500;
    color: var(--text-muted);
}
.form-group label small { font-weight: 400; opacity: .7; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group input[type="color"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-family: var(--font);
    font-size: .93rem;
    transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-group textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.req { color: var(--danger); }

.checkbox-group label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: .88rem;
    cursor: pointer;
    color: var(--text);
}
.checkbox-group input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-xs);
    font-family: var(--font);
    font-size: .93rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-block { width: 100%; }

.alert {
    padding: 12px 18px;
    border-radius: var(--radius-xs);
    margin-bottom: 18px;
    font-size: .9rem;
}
.alert p { margin-bottom: 4px; }
.alert p:last-child { margin-bottom: 0; }
.alert-error { background: rgba(231,76,60,.10); border: 1px solid var(--danger); color: #e98b84; }
.alert-success { background: rgba(46,204,113,.10); border: 1px solid var(--accent); color: var(--accent); }
.alert-info { background: rgba(52,152,219,.10); border: 1px solid var(--info); color: var(--info); }

.table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table-wrap table { width: 100%; border-collapse: collapse; }
.table-wrap th {
    text-align: left;
    padding: 12px 18px;
    font-size: .82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
.table-wrap td {
    padding: 12px 18px;
    font-size: .9rem;
    border-bottom: 1px solid var(--border);
}
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap tr:hover td { background: var(--accent-dim); }

.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
}
.role-badge.admin { background: rgba(46,204,113,.15); color: var(--accent); }
.role-badge.support { background: rgba(52,152,219,.15); color: var(--info); }

.chat-layout { display: grid; grid-template-columns: 320px 1fr; gap: 0; height: calc(100vh - var(--navbar-height) - 56px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }

.chat-sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.chat-sidebar-header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-heading);
    font-size: .95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .15s;
}
.chat-item:hover, .chat-item.active { background: var(--accent-dim); }
.chat-item-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; color: var(--accent);
    flex-shrink: 0;
}
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name { font-weight: 600; font-size: .9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-preview { font-size: .82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.chat-item-time { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }
.chat-item-unread {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    font-size: .7rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.chat-main { display: flex; flex-direction: column; background: var(--bg-body); }
.chat-main-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.chat-main-header h3 { font-size: .95rem; color: var(--text-heading); }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 1rem; }

.msg { max-width: 70%; padding: 10px 16px; border-radius: 18px; font-size: .9rem; line-height: 1.5; position: relative; animation: msgIn .25s ease; }
.msg.visitor { align-self: flex-start; background: var(--bg-card); color: var(--text); border-bottom-left-radius: 4px; }
.msg.agent   { align-self: flex-end;   background: var(--accent); color: #000; border-bottom-right-radius: 4px; }
.msg.ai      { align-self: flex-end;   background: #6c5ce7; color: #fff; border-bottom-right-radius: 4px; }
.msg-time { font-size: .72rem; color: var(--text-muted); margin-top: 4px; }
.msg.agent .msg-time, .msg.ai .msg-time { color: rgba(0,0,0,.5); }

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-input {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    display: flex;
    gap: 10px;
}
.chat-input input {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 50px;
    color: var(--text);
    font-family: var(--font);
    font-size: .9rem;
}
.chat-input input:focus { outline: none; border-color: var(--accent); }
.chat-input button {
    padding: 10px 20px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-input button:hover { background: var(--accent-hover); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.code-snippet {
    background: var(--bg-body);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 16px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: .85rem;
    color: var(--accent);
    word-break: break-all;
    position: relative;
}
.code-snippet .copy-btn {
    position: absolute;
    top: 8px; right: 8px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: var(--radius-xs);
    padding: 4px 10px;
    font-size: .78rem;
    cursor: pointer;
    font-weight: 600;
}
.install-instructions {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 20px;
}
.install-instructions h3 { margin-bottom: 12px; color: var(--text-heading); display: flex; align-items: center; gap: 8px; }
.install-instructions ol { padding-left: 20px; color: var(--text-muted); font-size: .9rem; }
.install-instructions ol li { margin-bottom: 8px; }

.color-preview-row { display: flex; align-items: center; gap: 12px; }
.color-preview-row input[type="color"] {
    width: 48px; height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    padding: 2px;
}

.ai-toggle-label {
    display: flex !important;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    padding: 16px 20px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .2s;
}
.ai-toggle-label:hover { border-color: var(--accent); }
.ai-toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
.ai-toggle-switch input { opacity: 0; width: 0; height: 0; }
.ai-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-light);
    border-radius: 26px;
    transition: background .3s;
    cursor: pointer;
}
.ai-toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px; height: 20px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .3s;
}
.ai-toggle-switch input:checked + .ai-toggle-slider { background: var(--accent); }
.ai-toggle-switch input:checked + .ai-toggle-slider::before { transform: translateX(22px); }

.tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.app-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .82rem;
    color: var(--text-muted);
}
.app-footer a { color: var(--text-muted); }
.app-footer a:hover { color: var(--accent); }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow);
    animation: modalIn .2s ease;
}
.modal h3 { margin-bottom: 18px; color: var(--text-heading); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(.95); }
    to   { opacity: 1; transform: scale(1); }
}

.plan-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 12px;
    letter-spacing: .5px;
}
.plan-free { background: rgba(149, 165, 166, 0.15); color: #95a5a6; }
.plan-premium { background: rgba(155, 89, 182, 0.15); color: #9b59b6; }

.ai-usage-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 24px;
}
.ai-usage-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: .9rem;
    color: var(--text-muted);
}
.ai-usage-header strong { color: var(--text-heading); }
.ai-progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}
.ai-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width .3s ease;
}
.ai-progress-fill.danger { background: #e74c3c; }
.ai-limit-warning {
    color: #e74c3c;
    font-size: .85rem;
    margin-top: 10px;
    font-weight: 500;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.admin-table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 2px solid var(--border);
}
.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-heading);
}
.admin-table tbody tr:hover { background: rgba(255,255,255,.02); }
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: .8rem;
    font-weight: 500;
}
.badge-success { background: rgba(46, 204, 113, .15); color: #2ecc71; }
.badge-muted { background: var(--bg-input); color: var(--text-muted); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }


.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99;
    opacity: 0;
    transition: opacity .3s;
}
.sidebar-backdrop.visible {
    display: block;
    opacity: 1;
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: 4px 0 30px rgba(0,0,0,.5);
    }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; max-width: 100vw; }
    .hamburger { display: block; }

    .navbar { padding: 0 16px; }
    .navbar-left h2 { font-size: .95rem; }
    .navbar-user { padding: 4px 10px; }
    .navbar-user span { font-size: .82rem; }

    .content { padding: 20px 16px; }

    .stat-cards { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-card .stat-icon { width: 40px; height: 40px; }
    .stat-card .stat-value { font-size: 1.3rem; }

    .settings-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .chat-layout { grid-template-columns: 1fr; height: calc(100vh - var(--navbar-height) - 48px); }
    .chat-sidebar {
        position: absolute;
        top: 0; left: 0; bottom: 0;
        width: 280px;
        z-index: 10;
        transform: translateX(-100%);
        transition: transform .3s;
        box-shadow: 4px 0 20px rgba(0,0,0,.4);
    }
    .chat-layout { position: relative; }
    .chat-sidebar.mobile-open { transform: translateX(0); }

    .chat-main-header { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
    .chat-main-header h3 { font-size: .88rem; }

    .chat-input { padding: 10px 12px; gap: 8px; }
    .chat-input input { padding: 8px 14px; font-size: .85rem; }
    .chat-input button { padding: 8px 16px; font-size: .82rem; }

    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap table { min-width: 600px; }
    .table-wrap th, .table-wrap td { padding: 10px 12px; font-size: .82rem; }
    .admin-table th, .admin-table td { padding: 10px 12px; font-size: .82rem; }

    .modal { max-width: 95%; padding: 20px; margin: 10px; }

    .app-footer { padding: 12px 16px; flex-wrap: wrap; gap: 8px; font-size: .75rem; }

    .tabs { overflow-x: visible; flex-wrap: wrap; }
    .tabs::-webkit-scrollbar { display: none; }
    .tab-btn { flex: 1 1 auto; padding: 10px 4px; font-size: .85rem; white-space: normal; line-height: 1.2; text-align: center; justify-content: center; display: flex; align-items: center; }

    .page-title { font-size: 1.2rem; margin-bottom: 16px; }
}

@media (max-width: 576px) {
    .content { padding: 14px 12px; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px 12px; flex-direction: column; align-items: flex-start; gap: 8px; }
    .stat-card .stat-icon { width: 36px; height: 36px; }
    .stat-card .stat-icon svg { width: 18px; height: 18px; }
    .stat-card .stat-value { font-size: 1.25rem; }
    .auth-card { padding: 28px 20px; }
    .chat-sidebar { width: 100%; }

    .btn { padding: 8px 16px; font-size: .85rem; }
    .btn-block { padding: 10px; }

    .form-group input[type="text"],
    .form-group input[type="email"],
    .form-group input[type="password"],
    .form-group input[type="tel"],
    .form-group select,
    .form-group textarea { font-size: .88rem; padding: 9px 12px; }

    .ai-usage-box { padding: 12px; }
    .ai-usage-header { font-size: .82rem; }

    .code-snippet { font-size: .75rem; padding: 12px; }
}
