/* ============================================================
   RHYTHM CAPITAL — CLIENT PORTAL THEME
   Shared across every client-* page. Loaded via <link>.
   Requires client-sidebar.js (which auto-injects the sidebar).
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,500;1,9..144,300;1,9..144,400&family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --ink: #0e0a1a;
  --aubergine: #1a0f2e;
  --aubergine-2: #2a1a3d;
  --champagne: #c9a961;
  --champagne-2: #b89346;
  --champagne-3: #e6c77f;
  --ivory: #f5f1e8;
  --cream: #faf7f0;
  --bone: #e8e2d3;
  --rule: rgba(14, 10, 26, 0.12);
  --rule-soft: rgba(14, 10, 26, 0.08);
  --rule-strong: rgba(201, 169, 97, 0.35);
  --muted: #6b5d6b;
  --muted-2: #8a7d8a;
  --white: #fff;
  --success: #3d6b4f;
  --success-bg: rgba(61, 107, 79, 0.1);
  --warning: #a57929;
  --warning-bg: rgba(165, 121, 41, 0.1);
  --danger: #9a4a5a;
  --danger-bg: rgba(154, 74, 90, 0.1);
  --info: #405a7c;
  --info-bg: rgba(64, 90, 124, 0.08);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { font-family: var(--sans); color: var(--ink); background: var(--ivory); }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--aubergine); color: var(--champagne); }

/* ============ ADMIN BAR (for impersonation) ============ */
.admin-bar {
  display: none;
  background: var(--aubergine);
  color: var(--champagne);
  padding: 10px 24px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  border-bottom: 1px solid var(--champagne);
}
.admin-bar.show { display: block; }
.admin-bar em {
  font-family: var(--serif); font-style: italic; color: var(--ivory);
  text-transform: none; letter-spacing: 0; font-size: 13px; margin-left: 6px;
}
.admin-bar a {
  color: var(--champagne-3); margin-left: 12px;
  border-bottom: 1px dotted rgba(201, 169, 97, 0.4);
}

/* ============ MAIN LAYOUT ============ */
main.main-content {
  padding: clamp(32px, 5vw, 56px) clamp(20px, 4vw, 48px);
  min-height: 100vh;
}
.container { max-width: 1240px; margin: 0 auto; }

/* ============ HERO HEADER ============ */
.page-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 32px;
  margin-bottom: 40px;
  border-bottom: 1px solid var(--rule);
}
.page-hero .hero-text .eyebrow {
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--champagne-2); font-weight: 500;
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.page-hero .hero-text .eyebrow::before {
  content: ''; width: 28px; height: 1px; background: var(--champagne);
}
.page-hero h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 4vw, 46px);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.06;
  color: var(--ink);
  margin-bottom: 10px;
}
.page-hero h1 em { font-style: italic; color: var(--aubergine); font-weight: 400; }
.page-hero .subtitle {
  color: var(--muted); font-size: 15.5px; line-height: 1.5; max-width: 60ch;
}
.page-hero .hero-right { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ============ STAT CARDS ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--rule);
  padding: 26px 24px;
  position: relative;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
  cursor: default;
}
.stat-card.clickable { cursor: pointer; }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 40px; height: 2px;
  background: var(--champagne);
  transition: width 0.4s;
}
.stat-card:hover::before { width: 100%; }
.stat-card.clickable:hover {
  border-color: var(--rule-strong);
  transform: translateY(-2px);
  box-shadow: 0 18px 40px -20px rgba(26, 15, 46, 0.12);
}
.stat-card.active {
  border-color: var(--aubergine);
  background: var(--cream);
}
.stat-card.active::before { width: 100%; background: var(--aubergine); }
.stat-card .stat-label {
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; margin-bottom: 14px;
}
.stat-card .stat-value {
  font-family: var(--serif);
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 300;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.stat-card .stat-note {
  font-family: var(--serif); font-style: italic; font-size: 12px; color: var(--muted-2);
}

/* ============ SECTION HEADS ============ */
.section { margin-bottom: 48px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule-soft);
  flex-wrap: wrap;
  gap: 14px;
}
.section-head h2 {
  font-family: var(--serif);
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 300;
  color: var(--ink);
  letter-spacing: -0.015em;
}
.section-head h2 em { font-style: italic; color: var(--aubergine); font-weight: 400; }
.section-head .view-all {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); transition: color 0.3s;
}
.section-head .view-all:hover { color: var(--aubergine); }

/* ============ TABS / FILTERS ============ */
.tab-row {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--rule-soft);
  flex-wrap: wrap;
}
.tab {
  padding: 14px 24px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all 0.25s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.tab:hover { color: var(--aubergine); }
.tab.active {
  color: var(--aubergine);
  border-bottom-color: var(--champagne);
}
.tab .tab-count {
  font-family: var(--serif); font-style: italic; font-size: 12px;
  color: var(--champagne-2); font-weight: 400;
  padding: 1px 8px; border: 1px solid var(--rule); border-radius: 20px;
}
.tab.active .tab-count { border-color: var(--champagne); color: var(--aubergine); }

/* Filter buttons (alt style) */
.filter-btn {
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--rule-soft);
  color: var(--muted);
  font-size: 12px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s;
}
.filter-btn:hover { border-color: var(--aubergine); color: var(--aubergine); }
.filter-btn.active {
  background: var(--aubergine); color: var(--ivory); border-color: var(--aubergine);
}

/* ============ CARDS GRID ============ */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.card {
  background: var(--white);
  border: 1px solid var(--rule);
  padding: 24px;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
}
.card:hover {
  border-color: var(--aubergine);
  transform: translateY(-2px);
  box-shadow: 0 18px 40px -20px rgba(26, 15, 46, 0.15);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule-soft);
}
.card-title {
  font-family: var(--serif); font-size: 18px; font-weight: 400;
  color: var(--ink); line-height: 1.2; letter-spacing: -0.01em;
}
.card-title em { font-style: italic; color: var(--aubergine); }
.card-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.card-badge.success { color: var(--success); }
.card-badge.warning { color: var(--warning); }
.card-badge.info { color: var(--info); }
.card-badge.danger { color: var(--danger); }
.card-details { display: grid; gap: 8px; font-size: 13.5px; color: var(--muted); }
.card-details .detail-row {
  display: flex; justify-content: space-between; gap: 12px;
}
.card-details .detail-row span:first-child {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted-2);
}
.card-details .detail-row span:last-child {
  color: var(--ink); font-weight: 500;
}
.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-soft);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px;
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid transparent;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
}
.btn svg { width: 12px; height: 12px; transition: transform 0.3s; }
.btn:hover svg { transform: translateX(3px); }
.btn-primary {
  background: var(--aubergine); color: var(--ivory); border-color: var(--aubergine);
}
.btn-primary:hover { background: var(--ink); transform: translateY(-1px); }
.btn-ghost {
  background: transparent; color: var(--aubergine); border-color: var(--rule);
}
.btn-ghost:hover { border-color: var(--aubergine); }
.btn-gold {
  background: var(--champagne); color: var(--ink); border-color: var(--champagne);
}
.btn-gold:hover { background: var(--champagne-2); transform: translateY(-1px); }
.btn-danger {
  background: transparent; color: var(--danger); border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: var(--ivory); }
.btn-sm { padding: 9px 16px; font-size: 11px; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; margin-bottom: 8px;
}
.form-input,
input[type="text"], input[type="email"], input[type="tel"],
input[type="password"], input[type="number"], input[type="date"], input[type="url"],
select, textarea {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--rule);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
  transition: all 0.25s;
}
.form-input:focus, input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--aubergine);
  box-shadow: 0 0 0 3px rgba(26, 15, 46, 0.08);
}
textarea { min-height: 100px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted-2); }

.search-input {
  background: var(--white) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b5d6b' stroke-width='2'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>") no-repeat 14px center;
  padding-left: 40px;
}

/* ============ MODAL ============ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 10, 26, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border: 1px solid var(--rule);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}
.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--aubergine), var(--champagne), var(--aubergine));
}
.modal-header {
  padding: 32px 32px 20px;
  border-bottom: 1px solid var(--rule-soft);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
}
.modal-header h2 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.modal-header h2 em { font-style: italic; color: var(--aubergine); }
.modal-close {
  font-size: 22px;
  color: var(--muted);
  line-height: 1;
  padding: 4px 8px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--aubergine); }
.modal-body { padding: 24px 32px; font-size: 14px; line-height: 1.6; color: var(--ink); }
.modal-footer {
  padding: 20px 32px;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  padding: 64px 24px;
  text-align: center;
  background: var(--white);
  border: 1px dashed var(--rule);
}
.empty-state h3 {
  font-family: var(--serif); font-style: italic;
  font-size: 20px; color: var(--aubergine); font-weight: 400;
  margin-bottom: 10px;
}
.empty-state p {
  color: var(--muted); font-size: 14.5px; line-height: 1.6;
  max-width: 44ch; margin: 0 auto 24px;
}

/* ============ TABLE ============ */
.data-table {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--rule);
  border-collapse: collapse;
}
.data-table thead {
  background: var(--cream);
  border-bottom: 1px solid var(--rule);
}
.data-table th {
  font-family: var(--serif); font-style: italic;
  font-weight: 400; font-size: 12px;
  color: var(--aubergine);
  padding: 14px 18px;
  text-align: left;
  letter-spacing: 0.02em;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--rule-soft);
  transition: background 0.2s;
}
.data-table tbody tr:hover { background: var(--cream); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td { padding: 14px 18px; font-size: 14px; color: var(--ink); }

/* ============ LIST (documents, messages, notifications) ============ */
.row-list { list-style: none; background: var(--white); border: 1px solid var(--rule); }
.row-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule-soft);
  transition: background 0.2s;
}
.row-item:last-child { border-bottom: none; }
.row-item:hover { background: var(--cream); }
.row-icon {
  width: 40px; height: 40px;
  background: var(--cream);
  border: 1px solid var(--rule-soft);
  color: var(--champagne-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.row-icon svg { width: 18px; height: 18px; }
.row-main { flex: 1; min-width: 0; }
.row-title {
  font-size: 14px; color: var(--ink); font-weight: 500;
  margin-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-sub {
  font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-meta {
  font-family: var(--serif); font-style: italic;
  font-size: 12px; color: var(--muted-2);
  text-align: right;
  flex-shrink: 0;
}
.row-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ============ FORM LAYOUTS ============ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.form-card {
  background: var(--white);
  border: 1px solid var(--rule);
  padding: clamp(28px, 4vw, 40px);
}
.form-card-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 300;
  color: var(--ink);
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule-soft);
  letter-spacing: -0.01em;
}
.form-card-title em { font-style: italic; color: var(--aubergine); font-weight: 400; }

/* ============ TOAST / ALERT ============ */
.alert {
  padding: 14px 20px;
  border-left: 3px solid var(--champagne);
  background: var(--cream);
  font-size: 13.5px;
  color: var(--ink);
  margin-bottom: 18px;
}
.alert.success { border-left-color: var(--success); background: var(--success-bg); color: var(--success); }
.alert.danger { border-left-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.alert.warning { border-left-color: var(--warning); background: var(--warning-bg); color: var(--warning); }
.alert strong { font-family: var(--serif); font-style: italic; font-weight: 400; }

/* ============ FOOTER NOTE ============ */
.page-foot {
  margin-top: 60px;
  padding-top: 28px;
  border-top: 1px solid var(--rule-soft);
  text-align: center;
  font-size: 12px;
  color: var(--muted-2);
  font-family: var(--serif); font-style: italic;
}
.page-foot a { color: var(--aubergine); border-bottom: 1px dotted var(--rule); }

/* ============ UTILITIES ============ */
.hidden { display: none !important; }
.spacer-sm { height: 12px; }
.spacer-md { height: 24px; }
.spacer-lg { height: 40px; }
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.toolbar .search-input { max-width: 340px; flex: 1; min-width: 200px; }

/* ============ PROGRESS METER ============ */
.meter { height: 3px; background: var(--rule); overflow: hidden; }
.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--champagne-2), var(--champagne-3));
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
  width: 0%;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  .page-hero { flex-direction: column; align-items: flex-start; }
  .modal-header, .modal-body, .modal-footer { padding-left: 22px; padding-right: 22px; }
}
