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

:root {
  --bg: #F6F6FB;
  --surface: #FFFFFF;
  --border: #ECECF3;
  --border-soft: #F1F1F6;
  --text: #1A1A2E;
  --text-muted: #5A5A72;
  --text-faint: #8A8AA3;
  --text-fainter: #9494A8;
  --text-faintest: #B4B4C4;
  --purple: #4F3DE0;
  --purple-dark: #3A2BC0;
  --purple-light: #6C5CE7;
  --purple-bg: #F3F1FF;
  --purple-bg-soft: #EFEBFF;
  --teal: #14B8A6;
  --orange: #F5A524;
  --pink: #F0577A;
  --pink-dark: #DE4568;
}

/* Dark theme — overrides only the chrome tokens (background/surface/border/
   primary text). Brand accents (purple/teal/orange/pink), status badge
   colors, and the muted text greys stay the same in both themes — a
   deliberate simplification (see README Scope Decision #8), not a
   pixel-perfect reskin of every inline-styled element. Toggled via a topbar
   button in both portals (see js/app.js), persisted to localStorage. */
:root[data-theme="dark"] {
  --bg: #15151F;
  --surface: #1E1E2B;
  --border: #2C2C3C;
  --border-soft: #262635;
  --text: #EDEDF2;
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #33334A; }
:root[data-theme="dark"] .tab-btn { background: var(--surface); border-color: var(--border); }
:root[data-theme="dark"] .filter-group select { background: var(--surface); color: var(--text); border-color: var(--border); }
:root[data-theme="dark"] .search-box input { color: var(--text); }
:root[data-theme="dark"] .field input,
:root[data-theme="dark"] .field select,
:root[data-theme="dark"] .field textarea { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .modal { background: var(--surface); }
:root[data-theme="dark"] .btn-secondary { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .login-card { background: var(--surface); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #E3E3EE; border-radius: 8px; }

a { color: var(--purple); text-decoration: none; }
a:hover { color: var(--purple-dark); }

button { font-family: inherit; cursor: pointer; }

/* --- Layout --- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
}

.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 0 4px 28px; }
.sidebar-logo .mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--purple-light), var(--purple));
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo .name { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; }

.create-invoice-btn {
  cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  background: var(--purple-bg); border: 1px solid #E4DEFF; border-radius: 14px;
  padding: 14px 16px; margin-bottom: 26px;
}
.create-invoice-btn:hover { background: #EAE5FF; }
.create-invoice-btn .label { font-size: 13.5px; font-weight: 700; line-height: 1.3; color: var(--purple); }
.create-invoice-btn .icon {
  width: 32px; height: 32px; border-radius: 10px; background: var(--purple); flex: none;
  display: flex; align-items: center; justify-content: center;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px; color: var(--text-muted); font-weight: 600; font-size: 14px;
}
.nav-item:hover { background: #F7F6FE; }
.nav-item.active { background: var(--purple-bg); color: var(--purple); font-weight: 700; }
.nav-item svg { flex: none; }

.go-pro {
  background: linear-gradient(160deg, var(--purple), var(--purple-light));
  border-radius: 16px; padding: 18px; color: white; position: relative; overflow: hidden;
}
.go-pro .title { font-size: 13px; font-weight: 700; margin-bottom: 4px; position: relative; }
.go-pro .desc { font-size: 11.5px; opacity: 0.85; line-height: 1.4; margin-bottom: 12px; position: relative; }
.go-pro .upgrade {
  background: white; color: var(--purple); font-size: 12.5px; font-weight: 700;
  border-radius: 9px; padding: 8px 0; text-align: center; position: relative; cursor: pointer;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.main-content { padding: 28px 40px 32px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.topbar h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.topbar .subtitle { font-size: 13px; color: var(--text-faint); font-weight: 600; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative;
}
.icon-btn:hover { background: #EFEEF7; }

.profile-pill { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 6px 10px 6px 6px; border-radius: 12px; }
.profile-pill:hover { background: var(--bg); }
.avatar {
  width: 32px; height: 32px; border-radius: 9px; background: var(--purple-bg-soft); color: var(--purple);
  font-size: 12.5px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none;
}
.profile-name { font-size: 13.5px; font-weight: 700; }

/* --- Cards --- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1000px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card { border-radius: 16px; padding: 18px 20px; color: white; }
.stat-card .icon-wrap {
  width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.stat-card .value { font-size: 20px; font-weight: 800; }
.stat-card .label { font-size: 12.5px; opacity: 0.85; font-weight: 600; margin-top: 2px; }
.stat-card.purple { background: var(--purple); }
.stat-card.teal { background: var(--teal); }
.stat-card.orange { background: var(--orange); }
.stat-card.pink { background: var(--pink); }

.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 14px; font-weight: 700; }

.list-card { background: var(--surface); border-radius: 16px; border: 1px solid var(--border); overflow: hidden; margin-bottom: 28px; }
.list-row { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.list-row:last-child { border-bottom: none; }
.list-row .swatch { width: 44px; height: 44px; border-radius: 12px; flex: none; }
.list-row .main-text { flex: 1; min-width: 0; }
.list-row .title { font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .desc { font-size: 12.5px; color: var(--text-fainter); margin-top: 3px; }
.list-row .meta { font-size: 12px; color: var(--text-faintest); margin-top: 6px; font-weight: 600; }

.badge { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 20px; white-space: nowrap; }
.badge.paid, .badge.delivered { background: #E6FBF6; color: #0E9A85; }
.badge.pending { background: #FFF3E0; color: #B4780A; }
.badge.failed { background: #FCE7EA; color: #C23050; }
.badge.expired { background: #F1F1F6; color: #6B6B80; }

.tab-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn {
  border: 1px solid var(--border); background: white; color: var(--text-muted);
  font-size: 13px; font-weight: 700; padding: 8px 16px; border-radius: 10px; cursor: pointer;
}
.tab-btn.active { background: var(--purple); color: white; border-color: var(--purple); }

.toggle-row { display: flex; align-items: center; gap: 10px; flex: none; }
.toggle-label { font-size: 12px; color: var(--text-fainter); font-weight: 600; }
.toggle { width: 36px; height: 20px; border-radius: 20px; position: relative; cursor: pointer; flex: none; background: #DADAE6; }
.toggle.on { background: var(--purple); }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: left 0.15s; }
.toggle.on .knob { left: 18px; }

.row-actions { display: flex; gap: 8px; flex: none; }
.row-actions .icon-btn { width: 30px; height: 30px; border-radius: 8px; background: transparent; }
.row-actions .icon-btn:hover { background: var(--bg); }

/* --- Packages --- */
.filters-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.filters-left { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-group span { font-size: 12.5px; color: var(--text-fainter); font-weight: 600; }
.filter-group select {
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12.5px;
  font-family: inherit; font-weight: 700; color: var(--text); background: white;
}
.count-label { font-size: 12.5px; color: var(--text-faintest); font-weight: 600; }

.search-box {
  display: flex; align-items: center; gap: 8px; background: var(--bg);
  border-radius: 11px; padding: 9px 14px; width: 220px;
}
.search-box input { border: none; outline: none; background: transparent; font-size: 13px; font-family: inherit; width: 100%; color: var(--text); }

.btn-primary {
  background: var(--pink); color: white; font-size: 13px; font-weight: 700;
  padding: 11px 20px; border-radius: 11px; border: none; cursor: pointer;
}
.btn-primary:hover { background: var(--pink-dark); }
.btn-secondary {
  background: white; color: var(--text); font-size: 13px; font-weight: 700;
  padding: 11px 20px; border-radius: 11px; border: 1px solid var(--border); cursor: pointer;
}

.package-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; padding-bottom: 8px; }
@media (max-width: 1100px) { .package-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .package-grid { grid-template-columns: 1fr; } }

.package-card {
  border-radius: 18px; padding: 20px; color: white; display: flex; flex-direction: column;
  min-height: 190px; position: relative;
}
.package-card .top-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.package-card .category-badge { font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; background: rgba(255,255,255,0.22); padding: 4px 9px; border-radius: 20px; }
.package-card .star { cursor: pointer; }
.package-card .title { font-size: 18px; font-weight: 800; line-height: 1.25; margin-bottom: 8px; }
.package-card .subtitle { font-size: 12.5px; opacity: 0.9; line-height: 1.5; flex: 1; }
.package-card .bottom-row { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.package-card .saved-label { font-size: 11.5px; font-weight: 700; opacity: 0.85; }
.package-card .type-icon {
  width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
}
.package-card .delete-btn { position: absolute; top: 16px; right: 46px; cursor: pointer; opacity: 0.85; }
.package-card .delete-btn:hover { opacity: 1; }

/* --- Placeholder / empty state --- */
.placeholder-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 48px;
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
}
.placeholder-card .icon-circle {
  width: 56px; height: 56px; border-radius: 16px; background: var(--purple-bg-soft);
  display: flex; align-items: center; justify-content: center;
}
.placeholder-card .title { font-size: 15px; font-weight: 700; }
.placeholder-card .desc { font-size: 13px; color: var(--text-fainter); max-width: 320px; line-height: 1.5; }

/* --- Table (Clients) --- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--text-fainter); padding: 14px 20px; border-bottom: 1px solid var(--border); }
.table td { padding: 14px 20px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
.table tr:last-child td { border-bottom: none; }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,26,46,0.4); display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: white; border-radius: 18px; padding: 28px; width: 420px; max-width: calc(100vw - 40px);
}
.modal h2 { margin: 0 0 18px; font-size: 17px; font-weight: 800; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 13.5px; font-family: inherit; color: var(--text); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--purple); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-error { color: var(--pink-dark); font-size: 12.5px; margin-bottom: 12px; min-height: 1em; }

/* --- Login page --- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: white; border-radius: 20px; padding: 40px; width: 360px; box-shadow: 0 20px 50px rgba(26,26,46,0.08); }
.login-card .sidebar-logo { padding-bottom: 24px; justify-content: center; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; text-align: center; }
.login-card .sub { font-size: 13px; color: var(--text-fainter); text-align: center; margin-bottom: 24px; }
.login-error { color: var(--pink-dark); font-size: 12.5px; margin-bottom: 12px; min-height: 1em; text-align: center; }

.empty-note { padding: 24px; text-align: center; color: var(--text-fainter); font-size: 13px; }

/* --- Skeleton loading placeholders (see js/app.js skeletonRowsHtml) —
   applied to a representative set of list views (Invoices, Contacts,
   Campaigns) rather than an exhaustive pass over every list. --- */
@keyframes skeleton-pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }
.skeleton-row { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.skeleton-row:last-child { border-bottom: none; }
.skeleton-swatch { width: 44px; height: 44px; border-radius: 12px; flex: none; background: var(--border); animation: skeleton-pulse 1.3s ease-in-out infinite; }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-line { height: 10px; border-radius: 6px; background: var(--border); animation: skeleton-pulse 1.3s ease-in-out infinite; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-65 { width: 65%; }

/* --- Toast notifications (see js/app.js showToast) — non-blocking
   feedback for a representative set of actions, alongside (not fully
   replacing) existing alert()-based error handling. --- */
#toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.toast {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 18px; font-size: 13.5px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(26,26,46,0.15); max-width: 320px; animation: toast-in 0.2s ease-out;
}
.toast.error { border-color: var(--pink-dark); color: var(--pink-dark); }
.toast.success { border-color: #0E9A85; color: #0E9A85; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
