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

:root {
  --bg: #F0EAE0;
  --surface: #FDFAF6;
  --border: #E2D9CC;
  --text: #1C1712;
  --text-muted: #7A6E65;
  --text-faint: #B5A99E;
  --accent: #B45309;
  --accent-light: #FEF3C7;
  --amber: #D97706;
  --amber-light: #FEF3C7;
  --green: #15803D;
  --green-light: #DCFCE7;
  --red: #B91C1C;
  --red-light: #FEE2E2;
  --blue: #1D4ED8;
  --blue-light: #EFF6FF;
  --sidebar-bg: #13100C;
  --sidebar-w: 220px;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ── LAYOUT ──────────────────────────────── */
body { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0;
  z-index: 10;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ── SIDEBAR ─────────────────────────────── */
.sidebar-logo {
  padding: 16px 14px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.logo-mark {
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}

.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}

/* New Invoice CTA */
.sidebar-cta {
  padding: 10px 12px 4px;
}
.sidebar-cta-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.sidebar-cta-btn:hover { background: #92400E; }

/* Nav sections */
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,.25);
  padding: 10px 12px 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 6px 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  color: rgba(255,255,255,.42);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  position: relative;
}

.nav-item svg {
  width: 15px; height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-item:hover { color: rgba(255,255,255,.78); background: rgba(255,255,255,.05); }
.nav-item.active { color: #fff; font-weight: 600; background: rgba(255,255,255,.08); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 2.5px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-count {
  margin-left: auto;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.5);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--amber);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* Earnings snapshot */
.sidebar-earnings {
  margin: 6px 12px;
  padding: 12px 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 10px;
}
.sidebar-earnings-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: rgba(255,255,255,.3);
  margin-bottom: 4px;
}
.sidebar-earnings-amount {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  line-height: 1.1;
}
.sidebar-earnings-sub {
  font-size: 11px;
  color: rgba(255,255,255,.35);
  margin-top: 3px;
}

/* Bottom */
.sidebar-bottom {
  padding: 8px 10px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-settings-link {
  color: rgba(255,255,255,.38) !important;
  font-size: 12.5px;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s;
}
.sidebar-profile:hover { background: rgba(255,255,255,.06); }

.profile-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.profile-name { font-size: 12.5px; font-weight: 600; color: #fff; }
.profile-role { font-size: 11px; color: rgba(255,255,255,.35); }

/* ── VIEWS ───────────────────────────────── */
.view {
  position: absolute;
  inset: 0;
  padding: 24px 32px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
}
.view.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}
.view::-webkit-scrollbar { width: 5px; }
.view::-webkit-scrollbar-track { background: transparent; }
.view::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.dash-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.dash-hero-title {
  font-family: 'Playfair Display', serif;
  font-size: 30px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.dash-hero-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

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

.view-title {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.view-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── STATS ───────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  font-family: 'Playfair Display', serif;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-value.amber { color: var(--amber); }
.stat-value.red { color: var(--red); }
.stat-value.green { color: var(--green); }

.stat-note { font-size: 11px; color: var(--text-faint); }

/* ── SECTION HEADER ──────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.link-muted {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
}
.link-muted:hover { color: var(--text); }

/* ── INVOICE LIST ────────────────────────── */
.invoice-list { display: flex; flex-direction: column; gap: 8px; }

.invoice-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.invoice-row:hover {
  border-color: #C9BFB3;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.inv-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.inv-status.draft { background: var(--text-faint); }
.inv-status.sent { background: var(--blue); }
.inv-status.paid { background: var(--green); }
.inv-status.overdue { background: var(--red); }

.inv-client { font-weight: 600; flex: 1; }
.inv-num { color: var(--text-muted); font-size: 13px; }
.inv-date { color: var(--text-faint); font-size: 12px; flex: 1; text-align: right; }
.inv-amount {
  font-weight: 700;
  font-size: 15px;
  min-width: 80px;
  text-align: right;
}
.inv-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  min-width: 64px;
  text-align: center;
}
.inv-badge.draft { background: var(--bg); color: var(--text-muted); }
.inv-badge.sent { background: var(--blue-light); color: var(--blue); }
.inv-badge.paid { background: var(--green-light); color: var(--green); }
.inv-badge.overdue { background: var(--red-light); color: var(--red); }

/* ── FILTER BAR ──────────────────────────── */
.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.filter-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.filter-btn:hover { border-color: var(--text-faint); color: var(--text); }
.filter-btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ── EMPTY STATE ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--text-muted); }
.mt-16 { margin-top: 16px; }

/* ── BUILDER ─────────────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 0;
  height: 100%;
  overflow: hidden;
}

.builder-form {
  overflow-y: auto;
  padding: 20px 28px;
  border-right: 1px solid var(--border);
}
.builder-form::-webkit-scrollbar { width: 5px; }
.builder-form::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.builder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}
.builder-actions { display: flex; gap: 8px; }

.form-section {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

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

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }

.form-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(28,25,23,.06);
}
.form-input::placeholder { color: var(--text-faint); }

.form-select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 6l4 4 4-4' stroke='%2378716C' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }

.form-textarea {
  min-height: 90px;
  resize: vertical;
}

/* Line items */
.line-item {
  display: grid;
  grid-template-columns: 1fr 80px 90px 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.line-item-header {
  display: grid;
  grid-template-columns: 1fr 80px 90px 32px;
  gap: 8px;
  margin-bottom: 6px;
}
.line-item-header span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.remove-line {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  line-height: 1;
  transition: color .15s;
}
.remove-line:hover { color: var(--red); }

/* ── INVOICE PREVIEW ─────────────────────── */
.builder-preview {
  overflow-y: auto;
  padding: 28px 24px;
  background: #EFEBE4;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.builder-preview::-webkit-scrollbar { width: 5px; }
.builder-preview::-webkit-scrollbar-thumb { background: rgba(0,0,0,.1); border-radius: 3px; }

.preview-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  text-align: center;
}

.invoice-preview {
  background: #fff;
  border-radius: 6px;
  padding: 36px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.03);
  font-size: 13px;
}

.preview-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}
.preview-pay-wrap {
  margin-top: 24px;
  text-align: center;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.preview-pay-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 12px 32px;
  border-radius: 8px;
  text-decoration: none;
  letter-spacing: 0.3px;
}
.paypal-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.paypal-prefix {
  padding: 0 10px;
  font-size: 13px;
  color: var(--text-faint);
  background: var(--surface);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  height: 40px;
  display: flex;
  align-items: center;
}
.paypal-input {
  border: none !important;
  border-radius: 0 !important;
  flex: 1;
}
.preview-logo {
  max-height: 64px;
  max-width: 180px;
  object-fit: contain;
  display: block;
  margin-bottom: 6px;
}
.logo-upload-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.logo-preview-wrap {
  width: 80px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.logo-preview-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.logo-placeholder {
  font-size: 11px;
  color: var(--text-faint);
}
.logo-remove-btn {
  font-size: 12px;
  color: var(--red);
  border-color: var(--red);
}
.preview-brand {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.preview-from-email { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.preview-from-address { font-size: 11px; color: var(--text-muted); }
.preview-invoice-label {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}
.preview-invoice-num { font-size: 11px; color: var(--text-muted); text-align: right; margin-top: 2px; }

.preview-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.preview-meta-block {}
.preview-meta-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.preview-meta-value { font-size: 13px; font-weight: 500; }
.preview-meta-sub { font-size: 11px; color: var(--text-muted); }

.preview-items { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.preview-items th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.preview-items th:last-child, .preview-items td:last-child { text-align: right; }
.preview-items td {
  padding: 10px 8px;
  border-bottom: 1px solid #F5F5F5;
  font-size: 12px;
}

.preview-totals { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin-bottom: 24px; }
.preview-total-row { display: flex; gap: 40px; font-size: 12px; }
.preview-total-row.final {
  font-size: 16px;
  font-weight: 700;
  padding-top: 10px;
  border-top: 2px solid var(--text);
  margin-top: 4px;
}
.preview-total-label { color: var(--text-muted); }
.preview-notes {
  font-size: 11px;
  color: var(--text-muted);
  padding-top: 16px;
  border-top: 1px solid var(--border);
  line-height: 1.6;
}

.preview-actions { display: flex; gap: 8px; }

/* ── CONTRACTS ───────────────────────────── */
.contract-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.contract-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all .15s;
}
.contract-card:hover {
  border-color: var(--text);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.contract-icon { font-size: 28px; margin-bottom: 12px; }
.contract-name { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.contract-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* ── SMART NUDGE ─────────────────────────── */
.nudge-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.nudge-explainer {
  background: var(--amber-light);
  border: 1px solid #FCD34D;
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 13px;
  color: #78350F;
  line-height: 1.6;
}

.tone-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tone-option { cursor: pointer; }
.tone-option input { display: none; }

.tone-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  transition: all .15s;
}
.tone-option input:checked + .tone-card {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}
.tone-icon { font-size: 22px; margin-bottom: 6px; }
.tone-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.tone-desc { font-size: 11px; color: var(--text-faint); line-height: 1.4; }
.tone-option input:checked + .tone-card .tone-desc { color: rgba(255,255,255,.6); }

.nudge-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 300px;
  display: flex;
  flex-direction: column;
}

.nudge-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 30px;
  text-align: center;
  color: var(--text-muted);
}
.nudge-placeholder-icon { font-size: 32px; margin-bottom: 12px; }

.nudge-result {
  padding: 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.nudge-email-to {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: monospace;
}
.nudge-tone-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
}
.nudge-message {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  flex: 1;
  white-space: pre-wrap;
}
.nudge-copy-btn {
  align-self: flex-end;
}
.nudge-copied {
  font-size: 12px;
  color: var(--green);
  display: none;
}

/* ── BUTTONS ─────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary:hover { background: #92400E; }
.btn-primary:active { transform: scale(0.97); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--text-faint); color: var(--text); }

.full-width { width: 100%; }
.mt-8 { margin-top: 8px; }

/* ── MODALS ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md), 0 0 0 1px var(--border);
  overflow: hidden;
  animation: modalIn .2s ease;
}
.modal-lg { max-width: 680px; }

@keyframes modalIn {
  from { transform: scale(0.96) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── AUTH MODAL ─────────────────────────────── */
.auth-modal {
  max-width: 440px;
}
.auth-modal-inner {
  padding: 40px 36px 36px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}
.auth-brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.5px;
}
.auth-brand-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  margin-bottom: 20px;
  padding: 3px;
}
.auth-tab {
  flex: 1;
  padding: 9px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: #3C3C3C;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  margin-bottom: 16px;
}
.btn-google:hover {
  background: #FAFAFA;
  border-color: #C8C8C8;
  box-shadow: 0 2px 6px rgba(0,0,0,.1);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--text-faint);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-field {
  margin-bottom: 14px;
}
.auth-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: 0.3px;
}

.auth-terms {
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
  margin-top: 12px;
  line-height: 1.6;
}

.auth-error {
  background: #FEE2E2;
  color: #B91C1C;
  font-size: 13px;
  border-radius: 7px;
  padding: 9px 12px;
  margin-bottom: 14px;
  text-align: left;
}
.ejs-connected { display: flex; flex-direction: column; align-items: flex-start; }
.ejs-status {
  font-size: 13px;
  font-weight: 500;
  color: #15803D;
  background: #DCFCE7;
  border: 1px solid #BBF7D0;
  border-radius: 7px;
  padding: 9px 14px;
  width: 100%;
}
.ejs-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.ejs-step {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.ejs-step-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ejs-template-details {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 4px;
}
.ejs-template-details summary {
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
}
.ejs-template-code {
  font-family: monospace;
  font-size: 11px;
  padding: 12px;
  background: var(--bg);
  white-space: pre-wrap;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin: 0;
}
.settings-note {
  font-size: 12px;
  color: var(--text-faint);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  line-height: 1.6;
  margin-top: 4px;
}

/* Invoice detail */
.detail-invoice { font-size: 13px; }
.detail-section { margin-bottom: 20px; }
.detail-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.detail-value { font-size: 14px; color: var(--text); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-amount { font-size: 28px; font-weight: 700; font-family: 'Playfair Display', serif; }
.detail-items { width: 100%; border-collapse: collapse; }
.detail-items th, .detail-items td { padding: 8px; border-bottom: 1px solid var(--border); font-size: 13px; text-align: left; }
.detail-items th { font-weight: 600; color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.detail-items td:last-child, .detail-items th:last-child { text-align: right; }

/* Contract fields */
.contract-fields { display: flex; flex-direction: column; gap: 12px; }

/* ── AUTOPILOT ───────────────────────────── */
.ap-explainer {
  background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
  border: 1px solid #FCD34D;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 13px;
  color: #78350F;
  line-height: 1.6;
  margin-bottom: 28px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.ap-explainer-icon { font-size: 24px; flex-shrink: 0; margin-top: 2px; }

.ap-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 32px;
  margin-bottom: 40px;
}

.ap-schedule-options { display: flex; flex-direction: column; gap: 8px; }
.ap-schedule-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all .15s;
}
.ap-schedule-row:hover { border-color: var(--text-faint); }
.ap-schedule-row input[type=checkbox] { accent-color: var(--text); width: 15px; height: 15px; }
.ap-schedule-row em { color: var(--amber); font-style: normal; font-weight: 600; }

.ap-notif-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* Client score */
.ap-client-score {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.ap-score-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.ap-score-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.ap-score-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0;
}
.ap-score-bar {
  height: 100%;
  border-radius: 3px;
  transition: width .6s ease;
}
.ap-score-bar.great { background: var(--green); }
.ap-score-bar.ok { background: var(--amber); }
.ap-score-bar.bad { background: var(--red); }
.ap-score-meta { font-size: 11px; color: var(--text-muted); }
.ap-score-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 4px;
}
.ap-score-tag.great { background: var(--green-light); color: var(--green); }
.ap-score-tag.ok { background: var(--amber-light); color: #92400E; }
.ap-score-tag.bad { background: var(--red-light); color: var(--red); }

/* Timeline */
.ap-timeline-wrap { position: relative; }
.ap-timeline-empty {
  height: 100%;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.ap-timeline { display: flex; flex-direction: column; gap: 0; }

.ap-step {
  display: grid;
  grid-template-columns: 120px 28px 1fr;
  gap: 0 16px;
  align-items: flex-start;
  position: relative;
}

.ap-step-date {
  text-align: right;
  padding-top: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.3;
}
.ap-step-date .ap-date-day { color: var(--text); font-size: 13px; }

.ap-step-dot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.ap-step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 10px;
  z-index: 1;
  transition: all .2s;
}
.ap-step.active .ap-step-dot {
  background: var(--text);
  border-color: var(--text);
  box-shadow: 0 0 0 4px rgba(28,25,23,.08);
}
.ap-step.today .ap-step-dot {
  background: var(--amber);
  border-color: var(--amber);
  animation: pulse 2s infinite;
}
.ap-step.overdue .ap-step-dot {
  background: var(--red);
  border-color: var(--red);
}
.ap-step.sent .ap-step-dot { background: var(--green); border-color: var(--green); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,119,6,.4); }
  50% { box-shadow: 0 0 0 6px rgba(217,119,6,0); }
}

.ap-step-line {
  width: 2px;
  flex: 1;
  min-height: 24px;
  background: var(--border);
}
.ap-step:last-child .ap-step-line { display: none; }

.ap-step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: all .15s;
}
.ap-step.active .ap-step-card { border-color: var(--text); }
.ap-step.today .ap-step-card { border-color: var(--amber); background: var(--amber-light); }
.ap-step.overdue .ap-step-card { border-color: var(--red); background: var(--red-light); }
.ap-step.sent .ap-step-card { border-color: var(--green); background: var(--green-light); opacity: .7; }

.ap-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.ap-card-title { font-size: 13px; font-weight: 700; }
.ap-card-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.tag-early { background: var(--blue-light); color: var(--blue); }
.tag-due { background: var(--amber-light); color: #92400E; }
.tag-followup { background: #FEF3C7; color: #92400E; }
.tag-firm { background: var(--red-light); color: var(--red); }
.tag-final { background: #1C1917; color: #fff; }
.tag-sent { background: var(--green-light); color: var(--green); }

.ap-card-preview {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
  font-style: italic;
  max-height: 48px;
  overflow: hidden;
}
.ap-card-actions { display: flex; gap: 8px; }

.btn-sm {
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all .15s;
}
.btn-sm:hover { background: #333; }
.btn-sm.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-sm.ghost:hover { border-color: var(--text-faint); color: var(--text); }
.btn-sm.green { background: var(--green); }
.btn-sm.red { background: transparent; color: var(--red); border: 1px solid var(--red-light); }

/* Active autopilots list */
.ap-active-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.ap-active-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  animation: pulse 2s infinite;
}
.ap-active-info { flex: 1; }
.ap-active-name { font-weight: 600; font-size: 14px; }
.ap-active-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ap-active-next {
  font-size: 12px;
  color: var(--amber);
  font-weight: 600;
}

/* ── CLIENTS ─────────────────────────────── */
.client-list { display: flex; flex-direction: column; gap: 10px; }

.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 44px 1fr 160px 120px;
  gap: 16px;
  align-items: center;
}

.client-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.client-name { font-size: 15px; font-weight: 600; }
.client-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.client-bar-wrap { display: flex; flex-direction: column; gap: 4px; }
.client-bar-label { font-size: 11px; color: var(--text-faint); display: flex; justify-content: space-between; }
.client-bar-bg { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.client-bar-fill { height: 100%; border-radius: 3px; transition: width .6s ease; }

.client-score-block { text-align: right; }
.client-score-num { font-family: 'Playfair Display', serif; font-size: 28px; font-weight: 600; line-height: 1; }
.client-score-label { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* ── HIDDEN / UTIL ───────────────────────── */
.hidden { display: none !important; }

/* ── E-SIGNATURE ─────────────────────────── */
.contract-preview-text {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  padding: 24px 28px;
  max-height: 340px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  background: var(--bg);
}
.signature-section {
  padding: 24px 28px;
}
.signature-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.signature-blocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
}
.signature-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: var(--surface);
}
.sig-block-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.sig-input {
  font-size: 16px;
  font-style: italic;
  margin-bottom: 8px;
}
.sig-date {
  font-size: 11px;
  color: var(--text-faint);
}
.sig-legal {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 6px;
  line-height: 1.5;
}
.sig-agree-row {
  margin-top: 4px;
}
.sig-agree-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.sig-agree-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── RECURRING ───────────────────────────── */
.recurring-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.recurring-active-badge {
  background: #DCFCE7;
  color: #15803D;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid #BBF7D0;
}
.recurring-remove-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.recurring-remove-btn:hover {
  color: var(--red);
}

/* ── TIME TRACKER ────────────────────────── */
.timer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.timer-inputs {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.timer-inputs .form-input {
  flex: 1;
  min-width: 160px;
}
.timer-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.timer-display {
  font-family: 'Playfair Display', serif;
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -1px;
  color: var(--text);
  min-width: 200px;
  transition: color 0.2s;
}
.timer-display.timer-running {
  color: var(--accent);
}
.timer-btn {
  padding: 12px 32px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  min-width: 90px;
}
.timer-btn:hover { background: #92400E; }
.timer-btn:active { transform: scale(0.97); }
.timer-btn-stop {
  background: #DC2626;
}
.timer-btn-stop:hover { background: #B91C1C; }

.time-entry-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}
.time-entry-desc {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.time-entry-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.time-entry-duration {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  min-width: 90px;
  text-align: right;
}
.time-entry-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  min-width: 70px;
  text-align: right;
}
.time-entry-actions {
  display: flex;
  gap: 6px;
}

/* ── SEND TOAST ──────────────────────────── */
.send-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #1C1712;
  color: #fff;
  border-radius: 12px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.28);
  z-index: 999;
  min-width: 340px;
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { transform: translateX(-50%) translateY(12px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}
.send-toast-icon {
  width: 36px;
  height: 36px;
  background: #15803D;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.send-toast-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.send-toast-text strong {
  font-size: 13px;
  font-weight: 600;
}
.send-toast-text span {
  font-size: 12px;
  color: #B5A99E;
}
