/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --sidebar-bg: #1a2540;
  --sidebar-hover: #2a3a5c;
  --sidebar-active: #3b5bdb;
  --accent: #3b5bdb;
  --accent-light: #dbe4ff;
  --topbar-h: 56px;
  --text-muted: #6c757d;
  --border: #e9ecef;
  --card-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ── Reset / Base ─────────────────────────────────────────────────────────── */
body { margin: 0; font-family: 'Segoe UI', system-ui, sans-serif; background: #f4f6fb; }
a { text-decoration: none; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #c8d0e7;
  display: flex; flex-direction: column;
  transition: width .25s ease;
  z-index: 1040;
  overflow: hidden;
}
.sidebar.collapsed { width: 64px; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
  min-height: var(--topbar-h);
}
.sidebar-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; flex-shrink: 0; }
.sidebar-logo-placeholder {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff; flex-shrink: 0;
}
.sidebar-brand-text { overflow: hidden; }
.brand-name { display: block; font-weight: 700; font-size: .95rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tagline { display: block; font-size: .72rem; color: #8899bb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; color: #c8d0e7; font-size: .88rem;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item i { font-size: 1.05rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-divider { height: 1px; background: rgba(255,255,255,.07); margin: 8px 16px; }
.text-danger-soft { color: #ff8080 !important; }

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .sidebar-brand-text { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }

/* ── Main content ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left .25s ease;
}
.main-content.expanded { margin-left: 64px; }

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle { color: #555; padding: 4px 8px; }
.topbar-title { flex: 1; font-weight: 600; font-size: .95rem; color: #333; }
.topbar-user { font-size: .85rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.stat-card {
  background: #fff; border-radius: 12px; padding: 20px 24px;
  box-shadow: var(--card-shadow); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: #1a2540; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.badge-draft    { background: #e9ecef; color: #495057; }
.badge-sent     { background: #cfe2ff; color: #084298; }
.badge-paid     { background: #d1e7dd; color: #0a3622; }
.badge-overdue  { background: #f8d7da; color: #842029; }
.badge-cancelled{ background: #e2e3e5; color: #41464b; }
.status-badge   { font-size: .75rem; padding: 3px 10px; border-radius: 20px; font-weight: 600; display: inline-block; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-card { background: #fff; border-radius: 12px; box-shadow: var(--card-shadow); border: 1px solid var(--border); overflow: hidden; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 600; background: #f8f9fa; border-bottom: 1px solid var(--border) !important; }
.table td { vertical-align: middle; font-size: .88rem; }
.table tbody tr:hover { background: #f8f9ff; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-card { background: #fff; border-radius: 12px; padding: 28px; box-shadow: var(--card-shadow); border: 1px solid var(--border); }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); font-weight: 600; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ── Invoice item row ─────────────────────────────────────────────────────── */
.item-row { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.item-row:hover { border-color: var(--accent); }

/* ── Page body spacing ───────────────────────────────────────────────────── */
.page-body { padding-top: 24px; }

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1a2540 0%, #2a3a5c 100%); }
.login-box { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 40px 36px; box-shadow: 0 8px 32px rgba(0,0,0,.18); }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { max-height: 60px; max-width: 180px; object-fit: contain; }
.login-logo-icon { font-size: 3rem; color: var(--accent); }
.login-brand { font-size: 1.3rem; font-weight: 700; color: #1a2540; text-align: center; margin-bottom: 4px; }
.login-sub { font-size: .85rem; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

/* ── Billing cycle pills ─────────────────────────────────────────────────── */
.billing-pill { font-size: .7rem; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.billing-one-time   { background: #fff3cd; color: #664d03; }
.billing-monthly    { background: #cfe2ff; color: #084298; }
.billing-quarterly  { background: #d1e7dd; color: #0a3622; }
.billing-yearly     { background: #e2d9f3; color: #432874; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar .nav-item span, .sidebar .sidebar-brand-text { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 12px; }
  .main-content { margin-left: 64px; }
}
