/* ===== VTN CRM – Global Styles ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #1E3A5F;
  --primary-light: #2E5B9A;
  --primary-dark: #142848;
  --accent: #E8A020;
  --accent-light: #F5C050;
  --success: #1A7F4B;
  --warning: #C47A10;
  --danger: #B02020;
  --info: #1A6FA0;
  --bg: #F4F6FB;
  --card: #FFFFFF;
  --border: #D8DEF0;
  --text: #1A2540;
  --text-muted: #6B7A9A;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(30,58,95,0.10);
  --shadow-lg: 0 8px 32px rgba(30,58,95,0.15);
}
html, body { height: 100%; font-family: 'Inter', Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }

/* ===== LOGIN ===== */
.login-page { display: flex; align-items: stretch; min-height: 100vh; background: var(--bg); }
.login-wrapper { display: flex; width: 100%; min-height: 100vh; }
.login-left {
  flex: 1; background: linear-gradient(145deg, var(--primary-dark) 0%, var(--primary-light) 100%);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 48px; color: #fff; position: relative; overflow: hidden;
}
.login-left::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 80%, rgba(255,255,255,0.05) 0%, transparent 60%);
}
.login-brand { text-align: center; z-index: 1; }
.brand-logo {
  width: 80px; height: 80px; border-radius: 20px;
  background: rgba(255,255,255,0.15); border: 2px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700; letter-spacing: 1px; margin: 0 auto 16px;
}
.login-brand h1 { font-size: 36px; font-weight: 700; letter-spacing: 2px; }
.login-brand p { font-size: 15px; opacity: 0.7; margin-top: 6px; }
.login-tagline { margin-top: 48px; z-index: 1; max-width: 320px; text-align: center; }
.login-tagline p { font-size: 15px; opacity: 0.65; line-height: 1.7; }
.login-right { width: 420px; display: flex; align-items: center; justify-content: center; padding: 48px 40px; background: var(--card); }
.login-box { width: 100%; max-width: 340px; }
.login-box h2 { font-size: 26px; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.login-sub { color: var(--text-muted); margin-bottom: 28px; }
.login-hint { margin-top: 20px; text-align: center; color: var(--text-muted); font-size: 12px; }
.login-hint code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
.input-eye { position: relative; }
.input-eye input { width: 100%; padding-right: 40px; }
.eye-toggle { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); cursor: pointer; font-size: 16px; opacity: 0.5; }

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w); background: var(--primary); min-height: 100vh;
  display: flex; flex-direction: column; position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100; box-shadow: 2px 0 16px rgba(0,0,0,0.15);
}
.sidebar-brand {
  padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-brand .logo { width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; letter-spacing: 0.5px; }
.sidebar-brand .brand-name { color: #fff; }
.sidebar-brand .brand-name strong { display: block; font-size: 15px; letter-spacing: 0.5px; }
.sidebar-brand .brand-name span { font-size: 11px; opacity: 0.6; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section { padding: 12px 16px 4px; font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.4); letter-spacing: 1.2px; text-transform: uppercase; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: rgba(255,255,255,0.75); text-decoration: none; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all 0.18s; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; border-left-color: var(--accent); }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .nav-badge { margin-left: auto; background: var(--accent); color: var(--primary-dark); font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--primary-dark); }
.user-info strong { display: block; font-size: 13px; color: #fff; }
.user-info span { font-size: 11px; color: rgba(255,255,255,0.5); text-transform: capitalize; }
.logout-btn { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 12px; background: rgba(255,255,255,0.08); border-radius: 8px; color: rgba(255,255,255,0.7); font-size: 13px; cursor: pointer; border: none; width: 100%; transition: 0.18s; }
.logout-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }

/* ===== MAIN CONTENT ===== */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { height: var(--header-h); background: var(--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; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.topbar-left h1 { font-size: 18px; font-weight: 600; color: var(--primary); }
.topbar-left p { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.page-content { padding: 24px; flex: 1; }

/* ===== CARDS ===== */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--primary); }
.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow); transition: transform 0.18s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-icon.blue { background: #EBF1FB; color: var(--primary-light); }
.stat-icon.green { background: #E6F5EE; color: var(--success); }
.stat-icon.amber { background: #FEF4E0; color: var(--warning); }
.stat-icon.purple { background: #F0EBF8; color: #6B40B5; }
.stat-info strong { display: block; font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-info span { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: block; }

/* ===== CHARTS ===== */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 20px; box-shadow: var(--shadow); }
.chart-card h4 { font-size: 14px; font-weight: 600; color: var(--primary); margin-bottom: 16px; }
.chart-wrap { position: relative; height: 220px; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table thead th { background: var(--primary); color: #fff; padding: 11px 14px; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: 0.5px; white-space: nowrap; }
table thead th:first-child { border-radius: 0; }
table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
table tbody tr:hover { background: #F0F4FC; }
table tbody td { padding: 10px 14px; font-size: 13px; vertical-align: middle; }
.text-muted { color: var(--text-muted); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-blue { background: #EBF1FB; color: var(--primary-light); }
.badge-green { background: #E6F5EE; color: var(--success); }
.badge-amber { background: #FEF4E0; color: var(--warning); }
.badge-red { background: #FCEAEA; color: var(--danger); }
.badge-gray { background: #EAECF3; color: var(--text-muted); }
.badge-purple { background: #F0EBF8; color: #6B40B5; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: all 0.18s; }
.btn-primary { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: var(--primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #156040; }
.btn-warning { background: var(--accent); color: var(--primary-dark); }
.btn-warning:hover { background: var(--accent-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8e1a1a; }
.btn-outline { background: transparent; color: var(--primary-light); border: 1px solid var(--primary-light); }
.btn-outline:hover { background: var(--primary-light); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 8px; justify-content: center; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.3px; text-transform: uppercase; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); background: var(--card); font-family: inherit; transition: border-color 0.18s, box-shadow 0.18s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(46,91,154,0.12); }
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 20px; }
.form-section { margin-bottom: 28px; }
.form-section-title { font-size: 12px; font-weight: 700; color: var(--primary-light); letter-spacing: 1px; text-transform: uppercase; padding: 8px 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.form-actions { display: flex; gap: 10px; padding-top: 8px; justify-content: flex-end; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* ===== SEARCH & FILTERS ===== */
.filters-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-box input { padding-left: 36px; }
.search-box::before { content: '🔍'; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; pointer-events: none; }
.filter-select { min-width: 150px; width: auto; }

/* ===== ALERTS ===== */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert-error { background: #FCEAEA; color: var(--danger); border: 1px solid #F0C0C0; }
.alert-success { background: #E6F5EE; color: var(--success); border: 1px solid #A8DDB8; }
.alert-info { background: #E6F2FB; color: var(--info); border: 1px solid #A8CDE8; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--card); border-radius: 14px; width: 90%; max-width: 720px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: translateY(-16px); transition: transform 0.2s; }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-wide { max-width: 960px; }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal-header h3 { font-size: 17px; font-weight: 600; color: var(--primary); }
.modal-close { width: 32px; height: 32px; border-radius: 8px; background: var(--bg); border: none; cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.modal-close:hover { background: var(--border); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== COLUMN HEADER FILTERS ===== */
table thead th { vertical-align: middle; padding: 11px 14px; position: relative; }
th.has-filter { cursor: pointer; user-select: none; }
th.has-filter .th-label { display: flex; align-items: center; gap: 5px; }
th.has-filter .th-label::after {
  content: '▾';
  font-size: 10px;
  opacity: 0.6;
  transition: transform 0.15s;
}
th.has-filter.filter-open .th-label::after { transform: rotate(180deg); opacity: 1; }
th.has-filter.filter-active .th-label::after { content: '●'; font-size: 8px; color: var(--accent-light); opacity: 1; }

.col-filter-select,
.col-filter-input {
  display: none;
  width: 100%;
  margin-top: 7px;
  padding: 5px 7px;
  font-size: 11px;
  font-weight: 400;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  animation: fadeIn 0.15s ease;
}
th.filter-open .col-filter-select,
th.filter-open .col-filter-input { display: block; }
.col-filter-select:focus,
.col-filter-input:focus { border-color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.22); }
.col-filter-select option { background: var(--primary); color: #fff; font-size: 12px; }
.col-filter-input::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.7; cursor: pointer; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* ===== PAGINATION ===== */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: flex-end; padding: 12px 0; }
.page-btn { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text); white-space: nowrap; }
.page-btn.active { background: var(--primary-light); color: #fff; border-color: var(--primary-light); }
.page-btn:hover:not(.active) { background: var(--bg); }
.page-info { font-size: 12px; color: var(--text-muted); margin-right: 8px; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h4 { font-size: 16px; font-weight: 600; color: var(--primary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-muted); }

/* ===== LOADING ===== */
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--primary-light); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 40px auto; display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== CHIPS ===== */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.chip-primary { background: #EBF1FB; color: var(--primary-light); }

/* ===== UTILS ===== */
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.fw-600 { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
}
@media (max-width: 640px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== ADMIN ROLE BADGE ===== */
.role-admin { background: #FEF4E0; color: var(--warning); }
.role-user { background: #EBF1FB; color: var(--primary-light); }

/* ===== TABLE ACTIONS ===== */
.action-btns { display: flex; gap: 5px; }

/* ===== VIEW MODAL ===== */
.view-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.view-field label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 3px; }
.view-field span { font-size: 13px; color: var(--text); }

/* ===== REPORTS ===== */
.report-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.export-card { border: 2px solid var(--border); border-radius: var(--radius); padding: 24px; text-align: center; cursor: pointer; transition: all 0.18s; }
.export-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.export-card .export-icon { font-size: 36px; margin-bottom: 10px; }
.export-card h4 { font-size: 14px; font-weight: 600; color: var(--primary); }
.export-card p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.export-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
