/* ── Reset & Variables ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #0D1B2A;
  --navy-mid:   #1a2d42;
  --red:        #C0392B;
  --red-hover:  #a93226;
  --gold:       #F0A500;
  --white:      #FFFFFF;
  --gray-light: #F4F6F9;
  --gray-mid:   #E8ECF0;
  --gray-text:  #6C757D;
  --text:       #2C3E50;
  --blue-light: #EBF5FB;
  --sidebar-w:  240px;
  --header-h:   64px;
  --shadow:     0 2px 12px rgba(0,0,0,.12);
  --radius:     8px;
}

body { font-family: 'Segoe UI', Arial, sans-serif; color: var(--text); background: var(--gray-light); }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth pages (login / signup / subscribe / connect) ────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  padding: 20px;
}

.auth-logo {
  color: var(--white);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-align: center;
}
.auth-logo span { color: var(--gold); }
.auth-tagline { color: rgba(255,255,255,.6); margin-bottom: 32px; font-size: .9rem; text-align: center; }

.auth-card {
  background: var(--white);
  border-radius: 12px;
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 16px 48px rgba(0,0,0,.3);
}

.auth-card h2 { font-size: 1.4rem; margin-bottom: 24px; color: var(--navy); }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; color: var(--navy); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--gray-mid);
  border-radius: var(--radius); font-size: .95rem; outline: none; transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--red); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: var(--radius); border: none; cursor: pointer;
  font-size: .95rem; font-weight: 600; transition: all .2s; text-decoration: none;
}
.btn-primary { background: var(--red); color: var(--white); width: 100%; justify-content: center; }
.btn-primary:hover { background: var(--red-hover); text-decoration: none; }
.btn-secondary { background: var(--navy); color: var(--white); }
.btn-secondary:hover { background: var(--navy-mid); text-decoration: none; }
.btn-outline { background: transparent; color: var(--red); border: 2px solid var(--red); }
.btn-outline:hover { background: var(--red); color: var(--white); text-decoration: none; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: #d4920a; text-decoration: none; }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-icon { padding: 6px 10px; font-size: .85rem; border-radius: 6px; }
.btn-edit { background: var(--blue-light); color: var(--navy); border: 1px solid #90caf9; }
.btn-delete { background: #fde8e8; color: var(--red); border: 1px solid #f9c0c0; }

.auth-footer { margin-top: 20px; text-align: center; font-size: .88rem; color: var(--gray-text); }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .9rem; }
.alert-error { background: #fde8e8; color: #922b21; border: 1px solid #f1948a; }
.alert-success { background: #d4efdf; color: #1e8449; border: 1px solid #82e0aa; }
.alert-info { background: #d6eaf8; color: #1a5276; border: 1px solid #85c1e9; }
.alert-warning { background: #fef9e7; color: #7d6608; border: 1px solid #f9e79f; }
.hidden { display: none !important; }

/* ── App shell (dashboard) ────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo .app-name { font-size: 1.2rem; font-weight: 800; letter-spacing: 2px; }
.sidebar-logo .app-name span { color: var(--gold); }
.sidebar-logo .user-email { font-size: .75rem; color: rgba(255,255,255,.5); margin-top: 4px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section-label {
  font-size: .7rem; font-weight: 700; letter-spacing: 1.5px;
  color: rgba(255,255,255,.35); padding: 12px 20px 4px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; cursor: pointer; color: rgba(255,255,255,.75);
  transition: all .2s; border-left: 3px solid transparent; font-size: .9rem;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: var(--white); }
.nav-item.active { background: rgba(192,57,43,.2); color: var(--white); border-left-color: var(--red); }
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer button { background: none; border: none; color: rgba(255,255,255,.6); cursor: pointer; font-size: .85rem; }
.sidebar-footer button:hover { color: var(--white); }

/* Main content */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* Top bar */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-mid);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--navy); flex: 1; }
.hamburger { display: none; background: none; border: none; cursor: pointer; font-size: 1.3rem; color: var(--navy); }

/* Content area */
.content { flex: 1; padding: 24px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-mid);
  display: flex; align-items: center; gap: 12px;
}
.card-header h3 { font-size: 1rem; color: var(--navy); flex: 1; }
.card-body { padding: 20px; }

/* ── Search bar ───────────────────────────────────────────────────────────── */
.search-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  margin-bottom: 16px;
}
.search-bar .form-group { margin: 0; flex: 1; min-width: 160px; }
.search-bar .form-group label { font-size: .8rem; }
.search-bar .form-group input { padding: 9px 12px; }

/* ── Data table ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: var(--navy); color: var(--white);
  padding: 10px 14px; text-align: left;
  font-size: .78rem; font-weight: 600; letter-spacing: .5px;
  white-space: nowrap;
}
tbody tr:nth-child(even) { background: var(--blue-light); }
tbody tr:hover { background: #dbeeff; }
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--gray-mid); vertical-align: middle; }
tbody td:first-child { font-weight: 600; color: var(--red); white-space: nowrap; }
.actions-cell { display: flex; gap: 6px; }

/* inline edit */
tbody td[contenteditable="true"] {
  outline: 2px solid var(--red); border-radius: 4px; background: #fff9f9;
}

/* empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-text); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .95rem; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal {
  background: var(--white); border-radius: 12px;
  width: 100%; max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  padding: 18px 24px; border-bottom: 1px solid var(--gray-mid);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; color: var(--navy); }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--gray-text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-mid); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px; border: 3px solid rgba(255,255,255,.3);
  border-top-color: var(--white); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px; z-index: 2000;
}
.toast {
  background: var(--navy); color: var(--white);
  padding: 12px 20px; border-radius: var(--radius);
  font-size: .9rem; box-shadow: var(--shadow);
  animation: slideIn .3s ease;
  max-width: 320px;
}
.toast.error { background: var(--red); }
.toast.success { background: #27ae60; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Dashboard stats ──────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); border-left: 4px solid var(--red);
}
.stat-card .stat-label { font-size: .78rem; color: var(--gray-text); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; color: var(--navy); margin-top: 4px; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: .76rem; font-weight: 600;
}
.badge-active { background: #d4efdf; color: #1e8449; }
.badge-inactive { background: var(--gray-mid); color: var(--gray-text); }
.badge-overdue { background: #fde8e8; color: var(--red); }
.badge-pending { background: #fef9e7; color: #7d6608; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .content { padding: 16px; }
  .auth-card { padding: 28px 24px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-title { font-size: .95rem; }
  table { font-size: .82rem; }
  thead th { padding: 8px 10px; }
  tbody td { padding: 8px 10px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .search-bar { flex-direction: column; }
  .search-bar .form-group { width: 100%; }
  .auth-card { padding: 24px 16px; }
}
