/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #1a1a1a;
    line-height: 1.5;
}
a { text-decoration: none; color: inherit; cursor: pointer; }

/* Login */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
}
.login-card {
    background: #fff; border-radius: 12px; padding: 48px; width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.login-card h1 { font-size: 28px; color: #1a237e; margin-bottom: 4px; }
.login-subtitle { color: #666; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 4px; color: #333; }
.form-input {
    width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 8px;
    font-size: 14px; outline: none; transition: border 0.2s;
}
.form-input:focus { border-color: #1a237e; }
.error-banner {
    background: #fdecea; color: #c62828; padding: 10px 14px; border-radius: 8px;
    margin-bottom: 16px; font-size: 14px;
}

/* Buttons */
.btn-primary {
    width: 100%; padding: 12px; background: #1a237e; color: #fff;
    border: none; border-radius: 8px; font-size: 16px; font-weight: 600;
    cursor: pointer; transition: background 0.2s;
}
.btn-primary:hover { background: #283593; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-small {
    padding: 4px 12px; background: #e8eaf6; color: #1a237e; border: none;
    border-radius: 6px; font-size: 13px; cursor: pointer;
}
.btn-small:hover { background: #c5cae9; }
.btn-back {
    background: none; border: none; color: #1a237e; font-size: 14px;
    cursor: pointer; margin-bottom: 16px; padding: 0;
}
.btn-back:hover { text-decoration: underline; }

/* Dashboard Layout */
.dashboard { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: #1a1a2e; color: #fff; display: flex;
    flex-direction: column; position: fixed; top: 0; bottom: 0;
}
.sidebar-header { padding: 24px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { font-size: 22px; font-weight: 700; }
.sidebar-email { font-size: 12px; color: rgba(255,255,255,0.5); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; }
.sidebar nav { flex: 1; padding: 12px 0; }
.nav-link {
    display: block; padding: 10px 20px; font-size: 15px; color: rgba(255,255,255,0.7);
    transition: all 0.2s; cursor: pointer;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link-active { background: rgba(255,255,255,0.12); color: #fff; font-weight: 600; border-left: 3px solid #7c4dff; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.btn-signout {
    width: 100%; padding: 8px; background: rgba(255,255,255,0.1); color: #fff;
    border: none; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.btn-signout:hover { background: rgba(255,255,255,0.2); }

.main-content { margin-left: 240px; flex: 1; padding: 32px; }

/* Page */
.page h2 { font-size: 24px; font-weight: 700; margin-bottom: 20px; }
.page h3 { font-size: 18px; font-weight: 600; margin: 20px 0 12px; }

/* Toolbar */
.toolbar { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search-input {
    padding: 8px 14px; border: 1px solid #ddd; border-radius: 8px;
    font-size: 14px; width: 300px; outline: none;
}
.search-input:focus { border-color: #1a237e; }
.filter-chips { display: flex; gap: 6px; }
.chip {
    padding: 6px 14px; border: 1px solid #ddd; border-radius: 20px;
    background: #fff; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.chip:hover { border-color: #1a237e; }
.chip-active { background: #1a237e; color: #fff; border-color: #1a237e; }
.user-count { font-size: 13px; color: #666; margin-bottom: 12px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.data-table th { text-align: left; padding: 12px 16px; background: #f8f9fa; font-size: 13px; font-weight: 600; color: #666; border-bottom: 1px solid #eee; }
.data-table td { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: #f8f9ff; }

/* Tier Badges */
.tier-badge {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600; text-transform: uppercase;
}
.tier-free { background: #e0e0e0; color: #616161; }
.tier-pro { background: #e3f2fd; color: #1565c0; }
.tier-premium { background: #f3e5f5; color: #7b1fa2; }
.tier-admin { background: #fce4ec; color: #c62828; }

/* Detail */
.detail-card {
    background: #fff; border-radius: 8px; padding: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06); margin-bottom: 20px;
}
.detail-row { display: flex; padding: 10px 0; border-bottom: 1px solid #f0f0f0; }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-weight: 600; width: 120px; color: #666; font-size: 14px; }
.tier-buttons { display: flex; gap: 8px; }
.btn-tier {
    padding: 8px 20px; border: 2px solid #ddd; border-radius: 8px;
    background: #fff; cursor: pointer; font-weight: 600; transition: all 0.2s;
}
.btn-tier:hover { border-color: #1a237e; }
.btn-tier-active { background: #1a237e; color: #fff; border-color: #1a237e; }
.btn-tier:disabled { opacity: 0.5; cursor: not-allowed; }
.success-text { color: #2e7d32; margin-top: 8px; font-size: 14px; }
.error-text { color: #c62828; margin-top: 8px; font-size: 14px; }

/* Chat Layout */
.chat-layout { display: flex; height: calc(100vh - 64px); gap: 0; }
.chat-list {
    width: 300px; background: #fff; border-right: 1px solid #eee;
    overflow-y: auto; flex-shrink: 0;
}
.chat-list h3 { padding: 16px 20px; border-bottom: 1px solid #eee; }
.chat-item { padding: 12px 20px; border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background 0.15s; }
.chat-item:hover { background: #f8f9ff; }
.chat-item-active { background: #e8eaf6; }
.chat-item-name { font-weight: 600; font-size: 14px; }
.chat-item-preview { font-size: 13px; color: #888; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread { flex: 1; display: flex; flex-direction: column; }
.chat-thread h3 { padding: 16px 20px; border-bottom: 1px solid #eee; background: #fff; }
.messages-container { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.message { max-width: 70%; padding: 10px 14px; border-radius: 12px; font-size: 14px; }
.message-received { background: #f0f0f0; align-self: flex-start; border-bottom-left-radius: 4px; }
.message-sent { background: #1a237e; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.message-meta { font-size: 11px; opacity: 0.6; margin-top: 4px; }
.reply-bar { display: flex; gap: 8px; padding: 16px 20px; border-top: 1px solid #eee; background: #fff; }
.reply-input { flex: 1; padding: 10px 14px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; outline: none; }
.reply-input:focus { border-color: #1a237e; }
.btn-send {
    padding: 10px 20px; background: #1a237e; color: #fff; border: none;
    border-radius: 8px; font-weight: 600; cursor: pointer;
}
.btn-send:hover { background: #283593; }
.chat-load-more {
    padding: 12px 20px; text-align: center; color: #1a237e; font-weight: 600;
    cursor: pointer; border-top: 1px solid #f0f0f0; font-size: 13px;
}
.chat-load-more:hover { background: #f8f9ff; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
    background: #fff; border-radius: 12px; padding: 24px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06); text-align: center;
    border-top: 4px solid #1a237e;
}
.stat-value { font-size: 36px; font-weight: 700; color: #1a237e; }
.stat-label { font-size: 14px; color: #666; margin-top: 4px; }
.stat-total { border-top-color: #1a237e; }
.stat-total .stat-value { color: #1a237e; }
.stat-free { border-top-color: #9e9e9e; }
.stat-free .stat-value { color: #616161; }
.stat-pro { border-top-color: #1565c0; }
.stat-pro .stat-value { color: #1565c0; }
.stat-premium { border-top-color: #7b1fa2; }
.stat-premium .stat-value { color: #7b1fa2; }
.stat-admin { border-top-color: #c62828; }
.stat-admin .stat-value { color: #c62828; }

/* Empty State */
.empty-state { display: flex; align-items: center; justify-content: center; height: 200px; color: #999; font-size: 16px; }
