:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
  background: #f7f9fc;
  font-synthesis: none;
  --navy: #1e3a8a;
  --navy-dark: #10245c;
  --sky: #0ea5e9;
  --sky-light: #e0f2fe;
  --ink: #0f172a;
  --muted: #5b677a;
  --line: #dbe4ef;
  --surface: #ffffff;
  --soft: #f7f9fc;
  --success: #0f9f6e;
  --warning: #d97706;
  --danger: #c24141;
  --shadow: 0 24px 70px rgba(15,23,42,.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--soft); color: var(--ink); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { margin: 0; display: inline-flex; align-items: center; width: fit-content; color: var(--navy); background: var(--sky-light); border: 1px solid #bae6fd; border-radius: 999px; padding: 7px 10px; font-size: .72rem; font-weight: 800; letter-spacing: .01em; text-transform: uppercase; }
.brand-mark { width: 42px; height: 32px; flex: 0 0 auto; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1.2fr) minmax(360px,.8fr); grid-template-rows: auto 1fr; gap: 40px 80px; padding: clamp(28px,5vw,72px); background: radial-gradient(circle at 82% 8%, rgba(14,165,233,.16), transparent 30rem), linear-gradient(180deg,#fff 0%,#f3f8ff 100%); }
.auth-brand { grid-column: 1 / -1; display: flex; align-items: center; gap: 11px; font-weight: 900; font-size: 20px; letter-spacing: -.035em; color: var(--navy); }
.auth-copy { align-self: center; max-width: 680px; }
.auth-copy h1 { margin: 18px 0 22px; font-size: clamp(3rem,7vw,6rem); line-height: .94; letter-spacing: -.06em; color: var(--ink); }
.auth-copy p:last-child { color: var(--muted); font-size: 1.14rem; line-height: 1.7; max-width: 560px; }
.auth-card { align-self: center; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 30px; box-shadow: var(--shadow); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: #f1f5f9; border-radius: 12px; margin-bottom: 24px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 10px; border-radius: 9px; font-weight: 700; }
.tab.active { background: var(--surface); color: var(--navy); box-shadow: 0 2px 10px rgba(15,23,42,.08); }
.stack { display: grid; gap: 15px; }
label { display: grid; gap: 7px; color: #334155; font-size: .86rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #cfd9e5; background: #fff; color: var(--ink); border-radius: 11px; padding: 12px 13px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--sky); box-shadow: 0 0 0 4px rgba(14,165,233,.12); }
textarea { resize: vertical; }
.primary, .secondary, .danger-button, .icon-button { border: 0; border-radius: 11px; padding: 11px 15px; font-weight: 800; }
.primary { color: #fff; background: var(--navy); box-shadow: 0 10px 22px rgba(30,58,138,.16); }
.primary:hover { background: var(--navy-dark); }
.secondary { color: var(--navy); background: #fff; border: 1px solid var(--line); }
.danger-button { background: #fff1f1; color: var(--danger); }
.small { padding: 9px 12px; font-size: .88rem; }
.hint { margin: -5px 0 0; color: var(--muted); font-size: .8rem; }
.app { min-height: 100vh; display: grid; grid-template-columns: 230px 1fr; background: var(--soft); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; background: var(--navy-dark); color: #dce8ff; display: flex; flex-direction: column; box-shadow: 10px 0 32px rgba(15,23,42,.06); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 28px; color: #fff; font-weight: 900; letter-spacing: -.025em; }
.sidebar .brand-mark { width: 37px; height: 28px; filter: drop-shadow(0 5px 10px rgba(0,0,0,.12)); }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { width: 100%; border: 0; background: transparent; color: #c9d8ff; padding: 11px 12px; border-radius: 9px; text-align: left; font-weight: 700; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; box-shadow: inset 3px 0 var(--sky); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 8px; }
.plan-chip { margin: 0 10px 8px; width: fit-content; padding: 6px 9px; border-radius: 999px; background: rgba(14,165,233,.18); color: #cdefff; font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.workspace { min-width: 0; padding: 34px clamp(20px,4vw,58px) 64px; }
.workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.workspace-header h2 { margin: 8px 0 0; font-size: 2rem; letter-spacing: -.04em; color: var(--ink); }
.account-summary { display: grid; text-align: right; gap: 2px; }
.account-summary span:first-child { font-weight: 800; color: var(--ink); }
.account-summary span:last-child { color: var(--muted); font-size: .83rem; }
.view { display: none; }
.view.active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: 0 10px 26px rgba(15,23,42,.035); }
.metric span { color: var(--muted); font-size: .8rem; font-weight: 650; }
.metric strong { display: block; margin-top: 10px; font-size: 1.8rem; letter-spacing: -.04em; color: var(--ink); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 12px 34px rgba(15,23,42,.04); }
.billing-panel { margin-bottom: 18px; }
.billing-content { padding: 16px 20px 20px; color: var(--muted); line-height: 1.6; }
.billing-content p { margin: 0; }
.billing-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
button:disabled { cursor: not-allowed; opacity: .58; }
.panel-head { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 7px 0 0; font-size: 1.18rem; color: var(--ink); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 700px; }
th, td { padding: 14px 18px; border-bottom: 1px solid #eef2f7; text-align: left; font-size: .88rem; }
th { color: #64748b; background: #fbfcfe; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; }
td { color: #334155; }
tbody tr:hover td { background: #fbfdff; }
tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-button { border: 1px solid var(--line); background: #fff; color: var(--navy); padding: 6px 9px; border-radius: 8px; font-size: .78rem; font-weight: 750; }
.row-button:hover { border-color: #a9c4e9; background: #f6faff; }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; background: #f1f5f9; color: #536078; font-size: .75rem; font-weight: 750; text-transform: capitalize; }
.status.paid, .status.completed { color: var(--success); background: #e9f9f3; }
.status.overdue, .status.void, .status.cancelled { color: var(--danger); background: #fff1f1; }
.status.part_paid { color: var(--warning); background: #fff7e8; }
.status.sent, .status.active { color: var(--navy); background: var(--sky-light); }
.empty { padding: 34px 20px; color: var(--muted); text-align: center; }
.invoice-list { display: grid; }
.invoice-list-item { display: grid; grid-template-columns: 1.1fr 1fr auto auto; gap: 16px; align-items: center; padding: 15px 20px; border-bottom: 1px solid #eef2f7; }
.invoice-list-item:last-child { border-bottom: 0; }
.invoice-list-item span { color: var(--muted); font-size: .84rem; }
dialog { width: min(620px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 18px; padding: 0; background: #fff; color: var(--ink); box-shadow: 0 30px 100px rgba(15,23,42,.24); }
dialog::backdrop { background: rgba(15,23,42,.5); backdrop-filter: blur(3px); }
.dialog-form { padding: 24px; display: grid; gap: 15px; }
.dialog-form.compact { max-width: 440px; margin: auto; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.dialog-head h3 { margin: 0; font-size: 1.25rem; color: var(--ink); }
.icon-button { background: transparent; color: #64748b; font-size: 1.5rem; padding: 2px 7px; box-shadow: none; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three-col { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.toast { position: fixed; z-index: 100; right: 22px; top: 22px; max-width: 420px; padding: 12px 15px; border-radius: 11px; background: var(--navy-dark); color: #fff; border: 1px solid rgba(14,165,233,.32); box-shadow: 0 16px 50px rgba(15,23,42,.28); transform: translateY(-16px); opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #7f1d1d; border-color: rgba(255,255,255,.18); }
.inline-select { min-width: 110px; padding: 7px 8px; }
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; grid-template-rows: auto auto auto; gap: 26px; }
  .auth-copy { align-self: end; }
  .app { grid-template-columns: 76px 1fr; }
  .sidebar { padding-inline: 10px; }
  .sidebar-brand span:last-child { display: none; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .nav-item { font-size: .68rem; text-align: center; padding: 12px 4px; overflow-wrap: anywhere; }
  .plan-chip { display: none; }
  .metric-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 640px) {
  .auth-shell { padding: 24px 16px 40px; }
  .auth-copy h1 { font-size: 3.2rem; }
  .app { display: block; }
  .sidebar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; top: auto; height: auto; padding: 7px; flex-direction: row; background: rgba(16,36,92,.97); border-top: 1px solid rgba(255,255,255,.12); }
  .sidebar-brand, .sidebar-bottom { display: none; }
  .sidebar nav { width: 100%; display: flex; overflow-x: auto; scrollbar-width: none; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 78px; font-size: .67rem !important; text-align: center; padding: 10px 4px; }
  .nav-item.active { box-shadow: inset 0 -2px var(--sky); }
  .workspace { padding: 22px 14px 90px; }
  .workspace-header { align-items: flex-start; }
  .account-summary { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .panel-head { padding: 15px; }
}

.text-button {
  border: 0;
  padding: 4px 0;
  background: transparent;
  color: var(--navy);
  font-weight: 750;
  text-align: left;
  box-shadow: none;
}
.text-button:hover { text-decoration: underline; }
.verification-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #bae6fd;
  border-radius: 14px;
  background: var(--sky-light);
  color: var(--navy-dark);
}
.verification-banner > div { display: grid; gap: 3px; }
.verification-banner span { color: #40506a; font-size: .84rem; }
.dialog-copy { margin: 0; color: var(--muted); line-height: 1.6; }
@media (max-width: 640px) {
  .verification-banner { align-items: flex-start; flex-direction: column; }
}

.today-panel { margin-bottom: 18px; }
.today-list { display: grid; }
.today-item {
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid #eef2f7;
}
.today-item:last-child { border-bottom: 0; }
.today-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--sky-light);
  color: var(--navy);
  font-weight: 900;
}
.today-copy { min-width: 0; display: grid; gap: 3px; }
.today-copy strong { color: var(--ink); }
.today-copy span { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.today-item.due .today-icon { background: #fff1f1; color: var(--danger); }
.today-actions { display: flex; gap: 6px; }
.report-filter {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.report-filter label { min-width: 160px; }
.report-metrics { padding: 20px; margin: 0; }
.report-note { margin: 0; padding: 0 20px 20px; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.smart-grid { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,.95fr); gap: 18px; }
.smart-form, .settings-form { display: grid; gap: 15px; padding: 20px; }
.smart-result-panel { min-height: 100%; }
.smart-result {
  width: calc(100% - 40px);
  margin: 20px;
  min-height: 270px;
  line-height: 1.65;
  background: #fbfdff;
}
.usage-chip {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--sky-light);
  color: var(--navy);
  font-size: .75rem;
  font-weight: 800;
}
.settings-panel { max-width: 840px; }
@media (max-width: 900px) {
  .smart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .today-item { grid-template-columns: auto minmax(0,1fr); }
  .today-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .report-filter { align-items: stretch; flex-direction: column; }
  .report-filter label { min-width: 0; }
  .report-metrics { grid-template-columns: 1fr 1fr; }
}

.check-row {
  display:flex;
  align-items:flex-start;
  gap:9px;
}
.check-row input {
  width:auto;
  margin-top:3px;
}
.document-items-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.document-items {
  display:grid;
  gap:10px;
}
.document-item-row {
  display:grid;
  grid-template-columns:minmax(0,1fr) 92px 130px auto;
  gap:10px;
  align-items:end;
  padding:12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fbfdff;
}
.document-item-row label {
  min-width:0;
}
.document-item-action {
  display:flex;
  align-items:flex-end;
  padding-bottom:1px;
}
@media (max-width: 720px) {
  .document-item-row {
    grid-template-columns:1fr 1fr;
  }
  .document-description {
    grid-column:1 / -1;
  }
  .document-item-action {
    align-self:end;
    justify-content:flex-end;
  }
}

.auth-legal {
  margin:18px 0 0;
  color:var(--muted);
  font-size:.78rem;
  text-align:center;
}
.auth-legal a,
.account-tools a { color:var(--navy); }
.account-tools {
  display:grid;
  gap:14px;
  margin:0 20px 20px;
  padding:20px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fbfdff;
}
.account-tools h4 { margin:0 0 5px; color:var(--ink); }
.account-tools p { margin:0; color:var(--muted); line-height:1.55; }
.account-tools-actions { display:flex; flex-wrap:wrap; gap:8px; }

/* Visible keyboard focus without relying on color alone. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid #0369a1;
  outline-offset: 3px;
}
@media (max-width: 640px) {
  .sidebar nav { scrollbar-width: auto; }
  .sidebar nav::-webkit-scrollbar { display: block; height: 4px; }
  .nav-item { min-height: 44px; }
  .document-item-row { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}


/* Consistent inset space for record controls (clients, jobs, quotes and invoices). */
.record-filters {
  display: grid;
  gap: 14px;
  padding: 18px 20px 22px;
  border-bottom: 1px solid var(--line);
}
.record-filters .two-col { min-width: 0; }
.record-filters label { min-width: 0; }
.record-filters input, .record-filters select { min-width: 0; }
.panel-head > div { min-width: 0; }
.panel-head h3 { overflow-wrap: anywhere; }
.metric { min-width: 0; }
.metric > strong { overflow-wrap: anywhere; }

/* Compact, accessible, seven-day KPI bar charts. Only observed days render bars. */
.metric-trend {
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid #edf2f8;
}
.metric-trend-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
}
.metric-trend-change { color: var(--navy); font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-bars {
  margin-top: 9px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(5px, .75vw, 12px);
  align-items: end;
  height: 53px;
}
.metric-bar-slot {
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
}
.metric-bar {
  width: min(100%, 22px);
  border-radius: 5px 5px 2px 2px;
  min-height: 3px;
  background: #94c9ea;
}
.metric-bar.current { background: var(--navy); }
.metric-bar.unrecorded {
  height: 2px;
  min-height: 2px;
  background: #e2e8f0;
  border-radius: 2px;
}
.metric-trend-dates {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: .65rem;
  padding-top: 5px;
}
@media (max-width: 640px) {
  .record-filters { padding: 16px; gap: 12px; }
  .metric { padding: 15px; }
  .metric-bars { gap: 5px; }
  .metric-trend-heading { flex-wrap: wrap; }
}


/* Free-plan sidebar upgrade: same flow as the dashboard's Pro CTA. */
.sidebar-upgrade {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 20px);
  margin: 0 10px 8px;
  border: 1px solid rgba(125,211,252,.65);
  border-radius: 10px;
  padding: 10px 12px;
  color: #0c275f;
  background: #e0f2fe;
  font-size: .86rem;
  font-weight: 800;
  text-align: left;
}
.sidebar-upgrade:hover { background: #fff; }
.sidebar-upgrade:focus-visible { outline: 3px solid #7dd3fc; outline-offset: 3px; }
.sidebar-upgrade[disabled] { cursor: wait; }
@media (min-width: 641px) and (max-width: 900px) {
  .sidebar-upgrade { width: 100%; margin: 0; padding: 9px 5px; font-size: .7rem; justify-content: center; }
  .sidebar-upgrade span { display: none; }
}

.settings-section-title { margin: 6px 0 2px; }
.settings-section-title h4, .brand-logo-settings h4 { margin: 0 0 6px; font-size: 1rem; color: var(--ink); }
.settings-section-title p, .brand-logo-settings p { margin: 0; color: var(--muted); line-height: 1.5; font-size: .85rem; }
.settings-section-title:not(:first-child) { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 12px; }
.brand-logo-settings { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #f8fbff; }
.brand-logo-settings label { min-width: 0; }
.brand-logo-settings input { max-width: 100%; padding: 10px; }
.logo-preview { max-width: 180px; max-height: 90px; object-fit: contain; }
.brand-logo-settings button { justify-self: start; }
