/* NovarisOS Design System — Navy / Gold / Cream palette */
:root {
  --navy: #0a1628;
  --navy-mid: #132240;
  --navy-light: #1d3461;
  --gold: #c9a84c;
  --gold-light: #e8cc7a;
  --cream: #faf6ee;
  --cream-dark: #f0e8d5;
  --white: #ffffff;
  --text: #1a1a2e;
  --text-light: #5a6a8a;
  --success: #2d8a6e;
  --warning: #c9943a;
  --danger: #c94a4a;
  --border: #e0d9c8;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;

  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 2px 16px rgba(10, 22, 40, 0.08);
  --shadow-lg: 0 8px 32px rgba(10, 22, 40, 0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── Login Screen ─── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(201,168,76,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(29,52,97,0.4) 0%, transparent 50%);
  padding: 24px;
}

.login-card {
  background: var(--cream);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  color: var(--navy);
  letter-spacing: 0.02em;
}

.login-logo span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-transform: uppercase;
  margin-top: 4px;
}

.login-card h2 {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--navy);
  margin-bottom: 24px;
  font-weight: 500;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--navy);
  color: var(--cream);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.btn-primary:hover { background: var(--navy-mid); }
.btn-primary:active { transform: translateY(1px); }

.login-error {
  background: #fef2f2;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ─── Dashboard Shell ─── */
.dashboard-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dash-header {
  background: var(--navy);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.dash-logo {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--cream);
}

.dash-logo span {
  color: var(--gold);
  font-size: 11px;
  display: block;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: var(--font-body);
  font-weight: 600;
  margin-top: -2px;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-advisor-name {
  color: var(--cream);
  font-size: 13px;
  font-weight: 500;
  opacity: 0.8;
}

.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  color: var(--cream);
  padding: 6px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.4);
}

.dash-body {
  flex: 1;
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Client List ─── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 500;
  color: var(--navy);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 4px;
}

.stat-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  color: var(--navy);
  line-height: 1;
}

.stat-card .stat-value.gold { color: var(--gold); }

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.client-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
  text-decoration: none;
  color: inherit;
  display: block;
}

.client-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--gold-light);
}

.client-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.client-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--navy);
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
}

.status-badge.active { background: #e6f4ed; color: var(--success); }
.status-badge.review { background: #fef3e2; color: var(--warning); }

.client-aum {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  color: var(--gold);
  margin-bottom: 12px;
}

.client-meta {
  font-size: 12px;
  color: var(--text-light);
}

.client-actions-count {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.client-actions-count svg {
  width: 14px;
  height: 14px;
  stroke: var(--text-light);
}

/* ─── Edit buttons ─── */
.btn-edit-client {
  background: none;
  border: 1.5px solid var(--gold);
  color: var(--gold);
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  font-family: var(--font-body);
}
.btn-edit-client:hover { background: var(--gold); color: var(--white); }

.btn-edit-sm {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  font-family: var(--font-body);
  flex-shrink: 0;
}
.btn-edit-sm:hover { border-color: var(--gold); color: var(--gold); }

/* ─── Portfolio layout with chart ─── */
.portfolio-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}

.donut-section { text-align: center; flex-shrink: 0; }

.donut-label-top {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 12px;
}

.donut-wrap svg { display: block; }

.donut-legend {
  margin-top: 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.donut-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.donut-legend-name { color: var(--text); flex: 1; }
.donut-legend-pct { color: var(--text-light); font-weight: 600; }

.portfolio-table-wrap { flex: 1; min-width: 0; }

/* ─── Detail header right ─── */
.detail-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* ─── Modal ─── */
#edit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,22,40,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  padding: 24px;
}

.modal-box {
  background: var(--cream);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--navy);
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--navy); }

.modal-body .form-group { margin-bottom: 16px; }
.modal-body select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--white);
  outline: none;
}
.modal-body select:focus { border-color: var(--gold); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.modal-error {
  background: #fef2f2;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin: 16px 0 0;
  display: none;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.btn-cancel {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-light);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  font-family: var(--font-body);
}
.btn-cancel:hover { border-color: var(--navy); color: var(--navy); }

.btn-save {
  background: var(--navy);
  border: none;
  color: var(--cream);
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font-body);
}
.btn-save:hover { background: var(--navy-mid); }

/* ─── Liability card with edit ─── */
.liability-info { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.liability-card { display: flex; align-items: center; gap: 12px; }

/* ─── Action item with edit ─── */
.action-item { gap: 12px; }
.action-item .edit-action-btn { margin-left: auto; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .dash-body { padding: 16px; }
  .stat-bar { grid-template-columns: repeat(2, 1fr); }
  .client-grid { grid-template-columns: 1fr; }
  .detail-name { font-size: 28px; }
  .detail-header { flex-direction: column; }
  .detail-tabs { overflow-x: auto; }
  .portfolio-layout { flex-direction: column; }
  .donut-section { margin: 0 auto; }
}

/* ─── Client Detail ─── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  text-decoration: none;
  margin-bottom: 20px;
  cursor: pointer;
  transition: color 0.2s;
}

.back-link:hover { color: var(--navy); }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.detail-name {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 500;
  color: var(--navy);
  line-height: 1.1;
  margin-bottom: 8px;
}

.detail-aum {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--gold);
  margin-bottom: 6px;
}

.net-worth {
  font-size: 14px;
  color: var(--text-light);
}

.net-worth strong { color: var(--text); }

.detail-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
}

.detail-tab {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-body);
}

.detail-tab:hover { color: var(--navy); }
.detail-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.detail-section { display: none; }
.detail-section.active { display: block; }

/* Portfolio */
.allocation-table {
  width: 100%;
  border-collapse: collapse;
}

.allocation-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
}

.allocation-table td {
  padding: 12px;
  border-bottom: 1px solid var(--cream-dark);
  font-size: 14px;
  color: var(--text);
}

.allocation-table tr:hover td { background: var(--cream); }

.allocation-bar-wrap {
  background: var(--cream-dark);
  border-radius: 4px;
  height: 8px;
  width: 100%;
  overflow: hidden;
}

.allocation-bar {
  height: 100%;
  background: var(--gold);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* Liabilities */
.liabilities-list { display: flex; flex-direction: column; gap: 12px; }

.liability-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.liability-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.liability-amount {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--danger);
  font-weight: 500;
}

/* Actions */
.action-list { display: flex; flex-direction: column; gap: 12px; }

.action-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.action-priority {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.action-priority.high { background: var(--danger); }
.action-priority.medium { background: var(--gold); }
.action-priority.low { background: var(--success); }

.action-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.action-due {
  font-size: 12px;
  color: var(--text-light);
}

.action-status {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 12px;
}

.action-status.pending { background: #fef3e2; color: var(--warning); }
.action-status.done { background: #e6f4ed; color: var(--success); }

/* ─── Loading / Spinner ─── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--cream-dark);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 60px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-light);
  font-size: 14px;
}

.loading-row {
  text-align: center;
  padding: 32px;
  color: var(--text-light);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .dash-body { padding: 16px; }
  .stat-bar { grid-template-columns: repeat(2, 1fr); }
  .client-grid { grid-template-columns: 1fr; }
  .detail-name { font-size: 28px; }
  .detail-header { flex-direction: column; }
  .detail-tabs { overflow-x: auto; }
}