/* ── Shared ──────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f0f2f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Auth pages (signin.html, setup.html) ────────────────────────────────── */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* Sign-in card */
.signin-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%; max-width: 380px;
  text-align: center;
  box-shadow: 0 4px 32px rgba(0,0,0,.10);
}
.app-icon { margin-bottom: 20px; }
.signin-card h1 { font-size: 26px; font-weight: 700; margin: 0 0 6px; color: #1a202c; }
.subtitle { color: #718096; font-size: 14px; margin-bottom: 32px; }

/* Setup card */
.setup-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%; max-width: 520px;
  box-shadow: 0 4px 32px rgba(0,0,0,.10);
}
.setup-card h1 { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.step {
  border-left: 3px solid #e2e8f0;
  padding: 12px 16px; margin: 16px 0;
  border-radius: 0 6px 6px 0;
  background: #f8fafc; font-size: 13px; color: #4a5568;
}
.step.active { border-color: #1e87f0; background: #eff6ff; color: #1e40af; }
.step.done   { border-color: #22c55e; background: #f0fdf4; color: #15803d; }
.step.error  { border-color: #ef4444; background: #fef2f2; color: #991b1b; }
.step-title  { font-weight: 600; margin-bottom: 3px; }

/* ── App (index.html) ────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 220px;
  --navbar-h: 56px;
  --accent: #1e87f0;
}

/* Navbar */
#navbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--navbar-h);
  background: #1a202c; display: flex; align-items: center;
  padding: 0 20px; gap: 16px; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
#navbar .brand { color: #fff; font-size: 18px; font-weight: 700; letter-spacing: .5px; flex: 1; }
#navbar .user-info { color: #a0aec0; font-size: 13px; }
#navbar .nav-actions { display: flex; gap: 8px; align-items: center; }
#navbar .nav-actions .uk-button {
  background: transparent;
  color: #cbd5e0;
  border: 1px solid #4a5568;
  border-radius: 6px;
}
#navbar .nav-actions .uk-button:hover {
  background: #2d3748;
  color: #fff;
  border-color: #718096;
}

/* Sidebar */
#sidebar {
  position: fixed; top: var(--navbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w); background: #fff;
  border-right: 1px solid #e2e8f0; overflow-y: auto;
  display: flex; flex-direction: column;
}
#sidebar nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer; font-size: 14px;
  color: #4a5568; text-decoration: none; border: none; background: none;
  width: 100%; text-align: left; transition: background .15s, color .15s;
}
.nav-item:hover { background: #f7fafc; color: #1a202c; }
.nav-item.active { background: #eff6ff; color: var(--accent); font-weight: 600; }
.nav-item .nav-icon { flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-divider { height: 1px; background: #e2e8f0; margin: 8px 16px; }
.nav-badge {
  margin-left: auto; background: #fed7d7; color: #c53030;
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
}

/* Main content */
#main {
  margin-left: var(--sidebar-w);
  margin-top: var(--navbar-h);
  padding: 28px;
  min-height: calc(100vh - var(--navbar-h));
}

/* Views */
.view { display: none; }
.view.active { display: block; }

/* Page header */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 20px; font-weight: 700; color: #1a202c; margin: 0; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.07); }
.stat-card .stat-label { font-size: 12px; color: #718096; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: #1a202c; }
.stat-card .stat-value.red   { color: #e53e3e; }
.stat-card .stat-value.green { color: #38a169; }
.stat-card .stat-value.amber { color: #d69e2e; }
.stat-card .stat-value.blue  { color: #3182ce; }

/* Charts */
.chart-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; margin-bottom: 28px; }
.chart-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.07); }
.chart-card h3 { font-size: 14px; font-weight: 600; color: #4a5568; margin: 0 0 16px; text-transform: uppercase; letter-spacing: .5px; }
.chart-container { position: relative; }

/* Tables */
.table-card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.07); margin-bottom: 20px; }
.table-card h3 { font-size: 14px; font-weight: 600; color: #4a5568; margin: 0 0 16px; text-transform: uppercase; letter-spacing: .5px; }
.uk-table td, .uk-table th { padding: 10px 12px; }
.uk-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: #718096; }
.action-btns { white-space: nowrap; }

/* Status badges */
.badge-current      { background: #c6f6d5; color: #276749; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.badge-expired      { background: #fed7d7; color: #9b2c2c; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.badge-none         { background: #e2e8f0; color: #718096; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.badge-reminder-new { background: #c6f6d5; color: #276749; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.badge-reminder-mid { background: #fefcbf; color: #975a16; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.badge-reminder-old { background: #fed7d7; color: #9b2c2c; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }

/* Template editor */
#template-split { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }
.template-list-item {
  padding: 10px 14px; cursor: pointer; border-radius: 6px;
  font-size: 13px; color: #4a5568; border: 1px solid transparent;
  margin-bottom: 4px; transition: background .15s;
}
.template-list-item:hover { background: #f7fafc; }
.template-list-item.active { background: #eff6ff; border-color: #bee3f8; color: #1e40af; font-weight: 600; }
#template-body { font-family: "Courier New", monospace; font-size: 13px; line-height: 1.6; resize: vertical; min-height: 300px; }

/* Mailer */
.mailer-preview {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 16px; min-height: 200px; font-family: "Courier New", monospace;
  font-size: 13px; line-height: 1.7; white-space: pre-wrap; color: #2d3748;
}

/* Loading overlay */
#loading-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; flex-direction: column; gap: 12px;
}
#loading-overlay.hidden { display: none; }
#loading-overlay p { color: #4a5568; font-size: 14px; }

/* Misc */
.empty-state { text-align: center; padding: 48px; color: #a0aec0; }
.empty-state svg { margin-bottom: 12px; }
.text-muted { color: #a0aec0; font-size: 12px; }
.renewal-soon { background: #fffbeb; }
.renewal-overdue { background: #fff5f5; }
