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

/* ─── Variables ────────────────────────────────────────────────────────────── */
:root {
  --primary: #4a90e2;
  --primary-gradient: linear-gradient(135deg, #4a90e2 0%, #667eea 100%);
  --success: #4CAF50;
  --warning: #FF9800;
  --danger: #f44336;
  --sidebar-w: 240px;

  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f4;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-900: #212529;

  --text-primary: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #e0e0e0;
  --bg: #f5f7fa;

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 10px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}

/* ─── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ─── Layout (sidebar + main) ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 12px;
  top: 12px;
  width: var(--sidebar-w);
  height: calc(100vh - 24px);
  background: var(--primary-gradient);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(74,144,226,0.3);
  display: flex;
  flex-direction: column;
  color: var(--white);
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 0.6rem 1rem;
  margin: 0.75rem;
  text-align: center;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.65rem 1.25rem;
  cursor: pointer;
  transition: background var(--transition);
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.15);
  color: var(--white);
}
.nav-item svg { flex-shrink: 0; opacity: 0.85; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 0.75rem;
  color: rgba(255,255,255,0.6);
  text-align: center;
}

.main-content {
  margin-left: calc(var(--sidebar-w) + 24px);
  padding: 24px 24px 24px 0;
  flex: 1;
  min-width: 0;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary-gradient); color: var(--white); box-shadow: 0 2px 8px rgba(74,144,226,0.35); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-success { background: linear-gradient(45deg,#4CAF50,#66BB6A); color: var(--white); }
.btn-danger { background: linear-gradient(45deg,#f44336,#ef5350); color: var(--white); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Stat cards ──────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}
.stat-card.green::before { background: linear-gradient(90deg,#4CAF50,#66BB6A); }
.stat-card.blue::before  { background: var(--primary-gradient); }
.stat-card.orange::before{ background: linear-gradient(90deg,#FF9800,#FFB74D); }
.stat-card.red::before   { background: linear-gradient(90deg,#f44336,#ef5350); }

.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); margin: 0.25rem 0; }
.stat-sub   { font-size: 0.75rem; color: var(--text-secondary); }

/* ─── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  padding: 0.65rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--text-primary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-green  { background: #e8f5e9; color: #2e7d32; }
.badge-blue   { background: #e3f2fd; color: #1565c0; }
.badge-orange { background: #fff3e0; color: #e65100; }
.badge-red    { background: #ffebee; color: #c62828; }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  padding: 0.55rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74,144,226,0.15);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 120px; }

/* ─── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }

/* ─── Month picker ────────────────────────────────────────────────────────── */
.month-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}
.month-picker select {
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text-primary);
}

/* ─── Toasts ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--white);
  animation: toastIn 0.3s ease;
  max-width: 320px;
}
.toast-success { background: #2e7d32; }
.toast-error   { background: #c62828; }
.toast-info    { background: #1565c0; }
@keyframes toastIn { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }

/* ─── Login page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0c71c3 0%, #15314e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-logo p { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.login-error {
  background: #ffebee;
  color: #c62828;
  border-radius: var(--radius-md);
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  margin-bottom: 1rem;
  display: none;
}

/* ─── Index / App cards ───────────────────────────────────────────────────── */
.hub-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0c71c3 0%, #15314e 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.hub-header {
  text-align: center;
  color: var(--white);
  margin-bottom: 2.5rem;
}
.hub-header h1 { font-size: 1.8rem; font-weight: 700; }
.hub-header p  { font-size: 0.9rem; opacity: 0.75; margin-top: 6px; }
.hub-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  width: 100%;
  max-width: 700px;
}
.hub-card {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  color: var(--white);
  backdrop-filter: blur(8px);
}
.hub-card:hover {
  background: rgba(255,255,255,0.18);
  transform: translateY(-4px);
}
.hub-card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}
.hub-card-icon.green { background: linear-gradient(135deg,#4CAF50,#66BB6A); }
.hub-card-icon.pink  { background: linear-gradient(135deg,#e91e63,#ff5722); }
.hub-card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
.hub-card p  { font-size: 0.82rem; opacity: 0.8; margin-bottom: 1rem; line-height: 1.5; }
.hub-card ul { list-style: none; padding: 0; font-size: 0.8rem; opacity: 0.75; }
.hub-card ul li::before { content: '✓ '; }
.hub-card ul li { margin-bottom: 3px; }
.hub-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.9;
  transition: opacity var(--transition);
}
.hub-nav-link:hover { opacity: 1; }

/* ─── Tabs ────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 1.5rem;
  width: fit-content;
}
.tab {
  padding: 0.45rem 1.1rem;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  border: none;
  background: transparent;
  font-family: inherit;
}
.tab.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ─── Rich text editor toolbar ────────────────────────────────────────────── */
.editor-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: var(--gray-50);
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.editor-toolbar button {
  padding: 4px 8px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background var(--transition);
}
.editor-toolbar button:hover { background: var(--gray-200); color: var(--text-primary); }
.editor-body {
  border: 1.5px solid var(--border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  min-height: 200px;
  padding: 0.75rem;
  font-size: 0.875rem;
  outline: none;
  font-family: inherit;
  line-height: 1.6;
}
.editor-body:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(74,144,226,0.15); }

/* ─── Client checkbox list ────────────────────────────────────────────────── */
.client-list {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 260px;
  overflow-y: auto;
}
.client-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
  cursor: pointer;
  transition: background var(--transition);
}
.client-list-item:last-child { border-bottom: none; }
.client-list-item:hover { background: var(--gray-50); }
.client-list-item input[type="checkbox"] { cursor: pointer; }
.client-list-search {
  padding: 0.5rem 0.9rem;
  border-bottom: 1.5px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}
.client-list-search input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 0.85rem;
  font-family: inherit;
}

/* ─── Chart (SVG bar chart) ───────────────────────────────────────────────── */
.bar-chart-wrap {
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.bar-chart-wrap svg text { font-family: inherit; fill: var(--text-muted); }

/* ─── Loading state ───────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  gap: 10px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 1rem; opacity: 0.35; }
.empty-state p { font-size: 0.875rem; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { position: static; width: 100%; height: auto; border-radius: 0; margin: 0; left: 0; top: 0; }
  .main-content { margin-left: 0; padding: 1rem; }
  .app-layout { flex-direction: column; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .hub-cards { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}
