:root {
    --primary: rgb(162, 61, 50);
    --secondary: rgb(162, 61, 50);
    --success: #4caf50;
    --danger: #f44336;
    --warning: #ff9800;
    --info: #2196f3;
    --dark: #2c3e50;
    --light: #f8f9fa;
    --tasks: #667eea;
    --notes: #764ba2;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fa;
    color: var(--dark);
}

a { color: inherit; }

.container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
}

/* ============ Top bar ============ */
.topbar {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.topbar .brand {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}
.topbar .nav-links { display: flex; gap: 10px; flex-wrap: wrap; }
.topbar .nav-links a {
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
    transition: 0.2s;
}
.topbar .nav-links a.active,
.topbar .nav-links a:hover { background: rgba(162,61,50,0.1); color: var(--primary); }
.topbar .user-box { display: flex; align-items: center; gap: 12px; font-size: 14px; }

/* ============ Welcome card ============ */
.welcome-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    background: linear-gradient(135deg, rgba(162, 61, 50, 0.1) 0%, rgba(162, 61, 50, 0.05) 100%);
    border-right: 5px solid var(--primary);
}
.welcome-card h1 { font-size: 28px; margin-bottom: 10px; color: var(--dark); display: flex; align-items: center; gap: 10px; }
.welcome-card p { color: #666; font-size: 15px; }
.user-status { display: flex; gap: 15px; margin-top: 15px; flex-wrap: wrap; }
.status-item { display: flex; align-items: center; gap: 8px; padding: 8px 15px; background: rgba(255,255,255,0.8); border-radius: 20px; font-size: 14px; }

/* ============ Stats grid ============ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; border-radius: 15px; padding: 25px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); transition: transform .3s, box-shadow .3s; border-top: 4px solid; text-align: center; }
.stat-card:hover { transform: translateY(-5px); box-shadow: 0 5px 20px rgba(0,0,0,0.1); }
.stat-card.primary { border-top-color: var(--primary); }
.stat-card.success { border-top-color: var(--success); }
.stat-card.warning { border-top-color: var(--warning); }
.stat-card.danger { border-top-color: var(--danger); }
.stat-card.info { border-top-color: var(--info); }
.stat-icon { font-size: 34px; margin-bottom: 10px; }
.stat-number { font-size: 34px; font-weight: 700; margin: 8px 0; }
.stat-card.primary .stat-number { color: var(--primary); }
.stat-card.success .stat-number { color: var(--success); }
.stat-card.warning .stat-number { color: var(--warning); }
.stat-card.danger .stat-number { color: var(--danger); }
.stat-card.info .stat-number { color: var(--info); }
.stat-label { color: #666; font-size: 15px; font-weight: 600; }

/* ============ Section title ============ */
.section-title { font-size: 20px; font-weight: 700; color: var(--dark); margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 2px solid #f0f0f0; }

/* ============ Team / user card ============ */
.teams-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.team-card { background: white; border-radius: 15px; padding: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); transition: all .3s; border-right: 4px solid var(--primary); }
.team-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.team-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.team-title { font-size: 17px; font-weight: 700; color: var(--dark); display: flex; align-items: center; gap: 8px; }
.team-role { background: var(--primary); color: white; padding: 3px 10px; border-radius: 15px; font-size: 12px; font-weight: 600; }
.team-role.leader { background: #ff9800; }
.team-role.member { background: #4caf50; }
.team-role.intern { background: #2196f3; }
.team-description { color: #666; font-size: 13px; margin-bottom: 10px; }
.team-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid #f0f0f0; }
.team-actions { display: flex; gap: 8px; }

/* ============ Buttons ============ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: 8px; text-decoration: none; font-weight: 600; transition: all .3s; border: none; cursor: pointer; font-size: 14px; }
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%); color: white; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(162,61,50,0.3); }
.btn-secondary { background: #f5f5f5; color: var(--dark); border: 1px solid #ddd; }
.btn-secondary:hover { background: #e9e9e9; }
.btn-danger { background: #f44336; color: white; }
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(244,67,54,.3); }
.btn-tasks { background: linear-gradient(135deg, var(--tasks) 0%, #764ba2 100%); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { display: block; width: 100%; text-align: center; }

/* ============ Conversations / tickets list ============ */
.recent-tickets { background: white; border-radius: 15px; padding: 25px; margin-bottom: 30px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.ticket-list { margin-top: 10px; max-height: 560px; overflow-y: auto; }
.ticket-item { padding: 14px 10px; border-bottom: 1px solid #f0f0f0; transition: background .2s; cursor: pointer; }
.ticket-item:hover { background: #f9f9f9; }
.ticket-item.active { background: rgba(162,61,50,0.08); border-right: 3px solid var(--primary); }
.ticket-item:last-child { border-bottom: none; }
.ticket-title { font-weight: 600; margin-bottom: 5px; color: var(--dark); display: flex; justify-content: space-between; align-items: flex-start; }
.ticket-meta { display: flex; gap: 12px; font-size: 12px; color: #666; flex-wrap: wrap; }
.ticket-status { padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.status-open { background: #e3f2fd; color: #1565c0; }
.status-pending { background: #fff3e0; color: #f57c00; }
.status-closed { background: #f5f5f5; color: #666; }

/* ============ Chat window ============ */
.chat-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.chat-window { background: white; border-radius: 15px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); display: flex; flex-direction: column; height: 640px; }
.chat-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; background: #f9fafb; }
.msg-bubble { max-width: 70%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; position: relative; }
.msg-in { align-self: flex-start; background: white; border: 1px solid #eee; border-bottom-right-radius: 3px; }
.msg-out { align-self: flex-end; background: var(--primary); color: white; border-bottom-left-radius: 3px; }
.msg-time { font-size: 11px; opacity: .7; margin-top: 4px; display: block; }
.chat-input-bar { display: flex; gap: 10px; padding: 15px; border-top: 1px solid #f0f0f0; }
.chat-input-bar input { flex: 1; padding: 12px 15px; border-radius: 25px; border: 1px solid #ddd; font-size: 14px; }
.chat-input-bar button { border-radius: 50%; width: 44px; height: 44px; background: var(--primary); color: white; border: none; cursor: pointer; font-size: 16px; }
.empty-chat { display: flex; align-items: center; justify-content: center; height: 100%; color: #999; flex-direction: column; gap: 10px; }

/* ============ Modal ============ */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); }
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-content { background: white; width: 420px; max-width: 92%; margin: 20px auto; padding: 25px; border-radius: 12px; position: relative; }
.close-modal { position: absolute; left: 15px; top: 12px; font-size: 26px; font-weight: bold; cursor: pointer; color: #666; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--dark); font-size: 14px; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; }
.form-control:focus { outline: none; border-color: var(--primary); }
.checkbox-group { display: flex; align-items: center; gap: 10px; }

/* ============ Table ============ */
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 12px; overflow: hidden; }
.data-table th, .data-table td { padding: 12px 14px; text-align: right; font-size: 14px; border-bottom: 1px solid #f0f0f0; }
.data-table th { background: #faf7f6; color: var(--dark); font-weight: 700; }
.data-table tr:hover { background: #fafafa; }

/* ============ Login page ============ */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, rgba(162,61,50,.9), rgba(162,61,50,.6)); }
.login-box { background: white; padding: 40px; border-radius: 18px; width: 380px; max-width: 92%; box-shadow: 0 15px 40px rgba(0,0,0,.2); }
.login-box h1 { text-align: center; margin-bottom: 6px; color: var(--primary); }
.login-box p.sub { text-align: center; color: #888; margin-bottom: 25px; font-size: 14px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 15px; font-size: 14px; }
.alert-danger { background: #ffebee; color: #c62828; }
.alert-success { background: #e8f5e9; color: #2e7d32; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; }
.badge-private { background: #f5f5f5; color: #666; }
.badge-shared { background: #e8f5e9; color: #2e7d32; }

.empty-state { text-align: center; padding: 40px; background: white; border-radius: 15px; color: #666; }

/* ============ Usage counter (WhatsApp free-tier progress) ============ */
.usage-card { background: white; border-radius: 15px; padding: 25px; margin-bottom: 30px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.usage-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.usage-head h3 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.usage-numbers { font-size: 14px; color: #666; }
.usage-numbers b { color: var(--dark); font-size: 16px; }
.progress-track { width: 100%; height: 14px; background: #f0f0f0; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 10px; transition: width .4s ease; background: linear-gradient(90deg, var(--success), #7bc47f); }
.progress-fill.warn { background: linear-gradient(90deg, var(--warning), #ffb74d); }
.progress-fill.danger { background: linear-gradient(90deg, var(--danger), #ff7961); }
.usage-note { margin-top: 10px; font-size: 13px; color: #888; }

@media (max-width: 900px) {
    .chat-layout { grid-template-columns: 1fr; }
    .chat-window { height: 480px; }
}
@media (max-width: 768px) {
    .container { padding: 15px; }
    .stats-grid, .teams-grid { grid-template-columns: 1fr; }
    .team-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .topbar { flex-direction: column; gap: 10px; align-items: stretch; }
    .topbar .nav-links { justify-content: center; }
}
