:root {
  /* Palette — used as accents, not foundations */
  --coral: #F37D59;
  --terracotta: #DD5341;
  --teal: #68C7C1;
  --teal-deep: #2A6664;
  --brown: #2C1F17;
  --brown-mid: #5A4636;
  --brown-soft: #7A6552;
  --gold: #FACA78;
  --gold-soft: #F5E6BD;

  /* Foundation */
  --bg: #FBFAF6;
  --card-bg: #FFFFFF;
  --card-border: #ECE7DA;
  --text: var(--brown);
  --text-muted: #7A6E60;
  --text-dim: #B5AC9D;

  /* Interactive */
  --accent: var(--brown);
  --accent-text: #FBFAF6;
  --accent-hover: #1F1510;
  --link: var(--terracotta);
  --link-hover: #B7402F;

  /* States */
  --autopending-bg: #FCF7E8;
  --autopending-border: #EAD7A4;
  --badge-bg: #ECF7F6;
  --badge-text: var(--teal-deep);
  --badge-border: #C9E6E3;
  --subtle-bg: #F4EFE2;
  --subtle-text: var(--brown-mid);
  --subtle-border: #E5DEC9;
  --accent-badge-bg: var(--brown);
  --accent-badge-text: #FBFAF6;
  --accent-badge-border: var(--brown);
  --danger-bg: #FBEDE7;
  --danger-text: #9E3322;
  --danger-border: #ECC5B5;

  --shadow-sm: 0 1px 2px rgba(44, 31, 23, 0.04);
  --shadow-md: 0 4px 16px rgba(44, 31, 23, 0.07);
  --shadow-hero: 0 12px 40px rgba(44, 31, 23, 0.10);

  --serif: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
  max-width: 920px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header — generous, restrained */
.site-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3.75rem 0 2rem;
  margin-bottom: 2.5rem;
  gap: 2rem;
  border-bottom: 1px solid var(--subtle-border);
}
.brand {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  gap: 1.25rem;
}
.brand-logo {
  height: 240px;
  width: auto;
  display: block;
  object-fit: contain;
}
.brand-tagline {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--brown-mid);
  padding-left: 0.42em; /* compensate trailing letter-spacing */
  position: relative;
  display: inline-block;
  white-space: nowrap;
}
.brand-tagline::before,
.brand-tagline::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 32px;
  height: 1px;
  background: var(--brown-soft);
  opacity: 0.55;
}
.brand-tagline::before {
  right: 100%;
  margin-right: 0.7rem;
}
.brand-tagline::after {
  left: 100%;
  margin-left: calc(0.7rem - 0.42em);
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.header-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.header-nav a:hover { color: var(--text); }
.header-nav a.active {
  color: var(--text);
  border-bottom-color: var(--terracotta);
}
.actions.inline { margin: 0; flex: 0 0 auto; }

/* Section headers — large serif */
section { margin-bottom: 3rem; }
section h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.7rem;
  letter-spacing: 0.005em;
  margin: 0 0 1rem;
  color: var(--brown);
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1.125rem 1.25rem;
  margin-bottom: 0.875rem;
  box-shadow: var(--shadow-sm);
}
.card.autopending {
  border-color: var(--autopending-border);
  background: var(--autopending-bg);
  border-left: 3px solid var(--gold);
}

.meta {
  display: flex;
  gap: 0.875rem;
  flex-wrap: wrap;
  align-items: baseline;
  margin-bottom: 0.5rem;
}
.meta strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--text);
  word-break: break-word;
}
.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Suggestion + badges */
.suggestion {
  margin: 0.625rem 0;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: center;
}
.badge {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--badge-border);
  padding: 0.22rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge.subtle {
  background: var(--subtle-bg);
  color: var(--subtle-text);
  border-color: var(--subtle-border);
  font-weight: 400;
}
.badge.accent {
  background: var(--accent-badge-bg);
  color: var(--accent-badge-text);
  border-color: var(--accent-badge-border);
  font-variant-numeric: tabular-nums;
}

/* Attachments */
.attachments {
  margin: 0.625rem 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.attachments .thumb {
  width: 92px;
  height: 92px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: var(--subtle-bg);
  display: block;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.attachments .thumb:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--brown-soft);
}
.attachments .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attachments .file {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  background: var(--subtle-bg);
  color: var(--brown);
  border: 1px solid var(--subtle-border);
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  max-width: 240px;
  transition: background 0.15s ease;
}
.attachments .file:hover { background: var(--gold-soft); }
.attachments .file .fname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachments .file .ficon { font-size: 1rem; line-height: 1; opacity: 0.7; }
.attachments .file.pdf .ficon { opacity: 0.9; color: var(--terracotta); }

/* Action row */
.action-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.875rem;
}
.actions {
  display: inline-flex;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

/* Inputs + buttons */
input[type="text"], input[type="email"], input[type="password"], input[type="file"], select, button {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0.55rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus {
  border-color: var(--brown-mid);
  box-shadow: 0 0 0 3px rgba(44, 31, 23, 0.08);
}
select {
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}
button {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.75rem;
  padding: 0.65rem 1.1rem;
  white-space: nowrap;
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:active { transform: translateY(1px); }
button.ghost {
  background: var(--card-bg);
  color: var(--brown-mid);
  border-color: var(--card-border);
}
button.ghost:hover {
  background: var(--subtle-bg);
  color: var(--brown);
  border-color: var(--subtle-border);
}
button.small { padding: 0.4rem 0.75rem; font-size: 0.68rem; }
button.danger {
  background: var(--card-bg);
  color: var(--danger-text);
  border-color: var(--danger-border);
}
button.danger:hover {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: var(--danger-text);
}

/* Manual upload form */
.upload-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}
.upload-form input[type="text"],
.upload-form input[type="email"],
.upload-form input[type="file"] {
  flex: 1 1 200px;
  min-width: 0;
}

/* Recently-sent list rows */
.row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.875rem;
  align-items: baseline;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 0.88rem;
}
.row:last-child { border-bottom: none; }
.row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-target {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.row-by { font-size: 0.78rem; font-style: italic; color: var(--text-muted); }
.row-when { font-size: 0.78rem; color: var(--text-dim); }

/* Mapping rows */
.map-row {
  display: grid;
  grid-template-columns: 1fr auto 2fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--subtle-border);
}
.map-row:last-child { border-bottom: none; }
.map-source {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1rem;
  color: var(--text);
}
.map-arrow { color: var(--text-dim); }
.map-target select { width: 100%; }
@media (max-width: 640px) {
  .map-row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
    padding: 0.6rem 0;
  }
  .map-arrow { display: none; }
}

/* Sales page */
.sales-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.sales-tile {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  box-shadow: var(--shadow-sm);
}
.tile-label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.tile-value {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sales-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.sales-col h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--brown);
  margin: 0 0 0.5rem;
}
.sales-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  overflow: hidden;
}
.sales-table td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--card-border);
}
.sales-table tr:last-child td { border-bottom: none; }
.sales-table .num { text-align: right; white-space: nowrap; }
@media (max-width: 640px) {
  .sales-cols { grid-template-columns: 1fr; }
  .tile-value { font-size: 1.15rem; }
}

/* Line items table */
.lines-block {
  margin: 0.875rem 0 0.5rem;
  background: var(--subtle-bg);
  border: 1px solid var(--subtle-border);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
}
.lines-block summary {
  cursor: pointer;
  font-family: var(--serif);
  font-size: 1rem;
  color: var(--brown);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  user-select: none;
  padding: 0.1rem 0;
}
.lines-block[open] summary { margin-bottom: 0.5rem; }
.lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  background: var(--card-bg);
  border-radius: 4px;
  overflow: hidden;
}
.lines-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brown-mid);
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--card-border);
  background: var(--cream-light, #FAF7EE);
  white-space: nowrap;
}
.lines-table tbody td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--card-border);
  vertical-align: top;
}
.lines-table tbody tr:last-child td { border-bottom: none; }
.lines-table .num { text-align: right; white-space: nowrap; }
.lines-table tbody tr:hover { background: var(--subtle-bg); }

/* Body preview details */
details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
  user-select: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
pre {
  background: var(--subtle-bg);
  padding: 0.7rem 0.85rem;
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre-wrap;
  font-size: 0.83rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
  margin: 0.5rem 0 0;
  border: 1px solid var(--subtle-border);
}

/* Login page */
.login-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 2.5rem 2.25rem 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-hero);
  text-align: center;
}
.login-logo {
  max-width: 340px;
  width: 92%;
  height: auto;
  display: block;
  margin: 0 auto 1.25rem;
}
.login-tagline {
  margin: 0 auto 2rem;
  display: inline-block;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  text-align: left;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.login-form input {
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
}
.login-form button {
  padding: 0.85rem;
  font-size: 0.78rem;
  margin-top: 0.5rem;
}

.error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  margin: 0 0 1rem;
  font-size: 0.88rem;
  text-align: left;
}

/* Companies page */
.company-card { padding: 1.125rem 1.25rem; }
.company-card.inactive { opacity: 0.55; }
.company-head { margin-bottom: 0.5rem; }
.company-head strong {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--text);
}
.company-head code {
  background: var(--subtle-bg);
  padding: 0 0.4rem;
  border-radius: 3px;
  font-size: 0.78rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--brown-mid);
}
.edit-company { margin-top: 0.6rem; padding: 0.85rem; }
.cards-block {
  background: var(--subtle-bg);
  border: 1px solid var(--subtle-border);
  border-radius: 6px;
  padding: 0.85rem 0.95rem;
  margin: 0.875rem 0;
}
.cards-head { margin-bottom: 0.6rem; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brown-mid); font-weight: 600; }
.cards-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}
.card-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.2rem 0.2rem 0.2rem 0.85rem;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.card-pill .digits { font-weight: 600; }
.card-pill button.small {
  padding: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  line-height: 1;
  font-size: 1rem;
  background: var(--card-bg);
  color: var(--text-muted);
  border-color: var(--card-border);
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
}
.card-pill button.small:hover { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.add-card-form {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.add-card-form input[name="digits"] { width: 130px; flex: 0 0 130px; }
.add-card-form input[name="label"] { flex: 1 1 160px; min-width: 0; }
.add-card-form input[name="phone"] { flex: 1 1 160px; min-width: 0; }

.card-pill-wrap { display: inline-block; }
.card-pill-wrap > summary {
  list-style: none;
  cursor: pointer;
}
.card-pill-wrap > summary::-webkit-details-marker { display: none; }
.card-pill-edit {
  margin-top: 0.5rem;
  padding: 0.5rem 0.7rem;
  background: var(--cream-light, #FDF7E3);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.card-edit-form {
  display: inline-flex;
  gap: 0.4rem;
  flex: 1 1 220px;
  min-width: 0;
}
.card-edit-form input { flex: 1 1 auto; min-width: 0; }

.plaid-link-btn {
  background: #00A86B;
  color: #fff;
  border: 1px solid #00A86B;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.plaid-link-btn:hover { background: #008B58; }
.plaid-link-btn:disabled { opacity: 0.6; cursor: wait; }

/* QuickBooks connection status on company cards */
.qbo-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--subtle-border);
}
.qbo-connect-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #2CA01C;
  color: #fff;
  border: 1px solid #2CA01C;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.15s ease;
}
.qbo-connect-btn:hover { background: #228715; }

/* Users page */
.user-card { padding: 0.95rem 1.15rem; }
.user-times {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  flex-wrap: wrap;
  margin: 0.25rem 0 0.6rem;
  color: var(--text-dim);
}
.password-reset {
  display: inline-flex;
  gap: 0.4rem;
  flex: 1 1 auto;
  min-width: 0;
}
.password-reset input { flex: 1 1 auto; min-width: 0; padding: 0.5rem 0.65rem; }
.hide-mobile { display: inline; }

/* Mobile */
@media (max-width: 640px) {
  body { padding: 0 1rem 4rem; font-size: 14.5px; }
  .site-header { padding: 2.25rem 0 1.5rem; gap: 1.5rem; margin-bottom: 1.5rem; }
  .brand { gap: 0.9rem; }
  .brand-logo { height: 150px; }
  .brand-tagline { font-size: 0.78rem; letter-spacing: 0.35em; padding-left: 0.35em; }
  .brand-tagline::before, .brand-tagline::after { width: 20px; }
  .brand-tagline::before { margin-right: 0.5rem; }
  .brand-tagline::after { margin-left: calc(0.5rem - 0.35em); }
  .header-nav { gap: 1rem; font-size: 0.72rem; }
  .hide-mobile { display: none; }

  section { margin-bottom: 2rem; }
  section h2 { font-size: 1.4rem; }

  .card { padding: 0.95rem 1rem; border-radius: 7px; }
  .meta { gap: 0.3rem; flex-direction: column; align-items: flex-start; }
  .meta strong { font-size: 1.1rem; }

  .attachments .thumb { width: 100px; height: 100px; }
  .attachments .file { max-width: none; flex: 1 1 100%; }

  .action-row { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .actions { width: 100%; }
  .actions select, .actions button {
    width: 100%;
    padding: 0.75rem 0.85rem;
    font-size: 0.78rem;
  }

  .upload-form { flex-direction: column; align-items: stretch; padding: 0.85rem; }
  .upload-form input, .upload-form button {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.95rem;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 0.2rem;
    padding: 0.75rem 0;
  }
  .row-target { font-size: 1rem; }

  .password-reset { flex-direction: column; }
  .password-reset input, .password-reset button { width: 100%; }

  .add-card-form { flex-direction: column; }
  .add-card-form input[name="digits"],
  .add-card-form input[name="label"],
  .add-card-form button { width: 100%; flex: none; }

  .login-card { padding: 2rem 1.5rem 1.5rem; }
  .login-logo { max-width: 280px; }

  .lines-block { padding: 0.55rem 0.7rem; }
  .lines-table { font-size: 0.78rem; }
  .lines-table thead th { padding: 0.45rem 0.45rem; font-size: 0.62rem; }
  .lines-table tbody td { padding: 0.4rem 0.45rem; }
}

/* ── Dashboard redesign (June 2026) ───────────────────────────── */

/* "Needs you" hero tiles */
.hero-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin: 0 0 1.5rem;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.1rem 1.15rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(60, 40, 12, 0.10);
}
.tile-num {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2.1rem;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.tile-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
}
.tile-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.tile-ok    { background: #f3f7ee; border-color: #d6e2c3; }
.tile-ok    .tile-num { color: #4a7028; }
.tile-warn  { background: #fdf6e3; border-color: #ecd9a4; }
.tile-warn  .tile-num { color: #a06e0c; }
.tile-alert { background: #fbecea; border-color: #f0c6c0; }
.tile-alert .tile-num { color: #a83228; }
.tile-info  { background: #eef2f8; border-color: #c6d3e6; }
.tile-info  .tile-num { color: #2b4a72; }

/* Sparkline */
.spark-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.85rem 1.1rem 0.6rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.spark-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}
.spark-header h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1rem;
  color: var(--brown);
}
.spark-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
}
.spark-bar-wrap {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.spark-bar {
  width: 100%;
  background: linear-gradient(180deg, #8aaf5e 0%, #5e7e3a 100%);
  border-radius: 2px 2px 0 0;
  min-height: 1px;
  transition: opacity 0.15s ease;
}
.spark-bar-wrap:hover .spark-bar { opacity: 0.75; }
.spark-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  font-variant-numeric: tabular-nums;
}

/* Per-company cards on dashboard */
.dash-company-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.85rem;
}
.dash-company-card {
  display: block;
  padding: 1rem 1.15rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.dash-company-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(60, 40, 12, 0.10);
}
.cc-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}
.cc-emoji { font-size: 1.35rem; }
.cc-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.cc-name:hover { color: var(--brown); text-decoration: underline; }
.cc-yest, .cc-mtd {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.35rem 0;
  border-top: 1px dashed var(--card-border);
}
.cc-yest-label, .cc-mtd-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.cc-yest-val {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.cc-mtd-val {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  color: #4a7028;
}
.cc-mtd-days { margin-left: 0.5rem; }
.cc-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.55rem;
  font-size: 0.82rem;
}
.cc-links a {
  color: var(--text-muted);
  text-decoration: none;
}
.cc-links a:hover { color: var(--brown); text-decoration: underline; }

/* ── Draft P&L dashboard section ─────────────────────────────── */

.dpnl-section {
  margin: 1rem 0 1.5rem;
}
.dpnl-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

/* Holdings rollup — full-width banner */
.dpnl-rollup {
  background: linear-gradient(135deg, #f8f4ea 0%, #f0e8d6 100%);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.85rem;
}
.dpnl-rollup-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
.dpnl-rollup .dpnl-emoji { font-size: 1.3rem; }
.dpnl-rollup .dpnl-name {
  font-family: var(--serif, Cormorant Garamond, Georgia, serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--brown);
}
.dpnl-rollup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
}
.dpnl-stat {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}
.dpnl-stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.dpnl-stat-val {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}
.dpnl-stat-hero .dpnl-stat-val { font-size: 1.7rem; }
.dpnl-positive .dpnl-stat-val { color: #2e7d2e; }
.dpnl-negative .dpnl-stat-val { color: #a83228; }
.dpnl-warn {
  background: #fff4e6;
  border: 1px solid #f0d0a0;
}
.dpnl-warn .dpnl-stat-val { color: #8a4a0e; }

/* Per-company cards */
.dpnl-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.85rem;
}
.dpnl-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
  overflow: hidden;
}
.dpnl-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--brown);
  opacity: 0.5;
}
.dpnl-card-positive::before { background: #2e7d2e; }
.dpnl-card-negative::before { background: #a83228; }
.dpnl-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(60, 40, 12, 0.10);
}
.dpnl-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.dpnl-card-head .dpnl-emoji { font-size: 1.1rem; }
.dpnl-card-head .dpnl-name {
  font-weight: 600;
  font-size: 1rem;
}
.dpnl-card-net {
  text-align: center;
  margin: 0.4rem 0 0.85rem;
}
.dpnl-card-net-val {
  font-size: 1.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.dpnl-card-positive .dpnl-card-net-val { color: #2e7d2e; }
.dpnl-card-negative .dpnl-card-net-val { color: #a83228; }
.dpnl-card-net-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.dpnl-card-detail {
  border-top: 1px solid rgba(60, 40, 12, 0.08);
  padding-top: 0.65rem;
  margin-top: 0.2rem;
}
.dpnl-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.18rem 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}
.dpnl-warn-row {
  margin-top: 0.7rem;
  padding: 0.5rem 0.65rem;
  background: #fff4e6;
  border-left: 3px solid #c97a1f;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #8a4a0e;
}

@media (max-width: 600px) {
  .tile-num { font-size: 1.7rem; }
  .hero-tiles { grid-template-columns: repeat(2, 1fr); }
  .spark-row { height: 48px; }
  .dpnl-card-net-val { font-size: 1.5rem; }
  .dpnl-stat-hero .dpnl-stat-val { font-size: 1.4rem; }
}

/* ── Nav grouping (dropdowns + mobile hamburger) ──────────────── */

.nav-toggle {
  display: none;
  background: none;
  border: 0;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: 0.25rem 0.5rem;
}

.nav-spacer { flex: 1 1 auto; min-width: 0; }

.nav-group { position: relative; }
.nav-group-btn {
  background: none;
  border: 0;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  padding: 0 0 4px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.nav-group-btn:hover { color: var(--text); }
.nav-group.active > .nav-group-btn {
  color: var(--text);
  border-bottom-color: var(--terracotta);
}
.nav-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  min-width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(60, 40, 12, 0.14);
  padding: 0.4rem 0;
  z-index: 100;
}
.nav-group.open > .nav-menu { display: block; }
.nav-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  border-bottom: 0;
  font-size: 0.82rem;
}
.nav-menu a:hover { background: var(--subtle-bg); color: var(--brown); }
.nav-menu a.active {
  background: var(--subtle-bg);
  color: var(--brown);
  border-bottom: 0;
}

@media (max-width: 900px) {
  .nav-toggle { display: inline-block; order: 99; margin-left: auto; }
  .header-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding-top: 0.75rem;
  }
  .header-nav.open { display: flex; }
  .header-nav a, .nav-group-btn {
    padding: 0.55rem 0.25rem;
    border-bottom: 1px solid var(--subtle-border);
    text-align: left;
  }
  .nav-group { width: 100%; }
  .nav-group-btn { width: 100%; text-align: left; }
  .nav-menu {
    position: static;
    box-shadow: none;
    border: 0;
    padding: 0 0 0 1rem;
    background: transparent;
  }
  .nav-menu a { padding: 0.45rem 0.25rem; }
  .nav-spacer { display: none; }
}

/* ── Botkeeper AI chat widget ─────────────────────────────────── */

#botkeeper-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.05rem;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(135deg, #6b4226 0%, #8b5a36 100%);
  color: #fbf5e9;
  font: 600 0.85rem/1 var(--sans, system-ui);
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(70, 40, 12, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
#botkeeper-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(70, 40, 12, 0.34);
}
.fab-icon { font-size: 1.1rem; }
.fab-label { /* hidden on small screens */ }

#botkeeper-panel {
  position: fixed;
  bottom: 5rem;
  right: 1.25rem;
  width: 380px;
  max-width: calc(100vw - 2.5rem);
  height: min(560px, calc(100vh - 7rem));
  z-index: 201;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(60, 40, 12, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#botkeeper-panel[hidden] { display: none; }

.bk-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--card-border);
  background: linear-gradient(180deg, #fbf5e9 0%, #f6efdc 100%);
}
.bk-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--brown);
}
.bk-sub { margin-top: 0.1rem; }
.bk-x {
  border: 0;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 0.25rem;
}
.bk-x:hover { color: var(--text); }

.bk-thread {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.bk-msg {
  max-width: 88%;
  padding: 0.55rem 0.8rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.4;
  word-wrap: break-word;
}
.bk-msg a { color: inherit; text-decoration: underline; }
.bk-msg-bot {
  background: var(--subtle-bg);
  border: 1px solid var(--subtle-border);
  align-self: flex-start;
  color: var(--text);
}
.bk-msg-user {
  background: #6b4226;
  color: #fbf5e9;
  align-self: flex-end;
  border: 1px solid #5a3720;
}
.bk-msg-user a { color: #fff; }
.bk-typing { opacity: 0.6; font-style: italic; }

.bk-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem 0.85rem;
  border-top: 1px solid var(--card-border);
  background: var(--card-bg);
}
.bk-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.88rem;
  min-height: 36px;
  max-height: 120px;
  background: #fff;
  color: var(--text);
}
.bk-form textarea:focus {
  outline: 2px solid var(--terracotta);
  outline-offset: -1px;
  border-color: var(--terracotta);
}
.bk-form button {
  background: var(--brown);
  color: #fbf5e9;
  border: 0;
  border-radius: 8px;
  padding: 0 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.bk-form button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 600px) {
  .fab-label { display: none; }
  #botkeeper-fab { padding: 0.7rem 0.85rem; }
  #botkeeper-panel {
    bottom: 4.5rem; right: 0.5rem; left: 0.5rem;
    width: auto; max-width: none;
    height: min(70vh, calc(100vh - 6rem));
  }
}

/* ── Bot Portal page ──────────────────────────────────────────── */

.bot-portal {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.75rem;
  align-items: flex-start;
}
.bot-sidebar {
  position: sticky;
  top: 1rem;
  padding: 0.85rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.bot-sidebar-title {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin: 0 0 0.7rem 0.25rem;
}
.bot-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.bot-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s ease;
}
.bot-link:hover { background: var(--subtle-bg); }
.bot-link.active { background: var(--subtle-bg); }
.bot-link.active .bl-name { color: var(--brown); }
.bot-link.placeholder { opacity: 0.6; }
.bl-emoji { font-size: 1.3rem; line-height: 1; }
.bl-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.bl-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 0.96rem;
  color: var(--text);
}
.bl-role {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.bl-badge {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--subtle-bg);
  color: var(--text-muted);
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}
.bot-sidebar-foot { margin: 0.85rem 0.25rem 0; }

.bot-main { min-width: 0; }
.bot-header { margin-bottom: 1.25rem; }
.bot-h1 {
  font-family: var(--serif);
  margin: 0 0 0.15rem;
  font-size: 2rem;
  color: var(--brown);
}

.placeholder-card {
  background: var(--card-bg);
  border: 1px dashed var(--card-border);
  border-radius: 12px;
  padding: 1.4rem 1.5rem;
}
.placeholder-card h3 {
  font-family: var(--serif);
  margin: 0 0 0.5rem;
  color: var(--brown);
}
.persona-sketch {
  background: var(--subtle-bg);
  border: 1px solid var(--subtle-border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-family: var(--sans);
  font-size: 0.86rem;
  white-space: pre-wrap;
  color: var(--text);
}

.bot-chat-page {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.botpage-thread {
  min-height: 320px;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}
.botpage-form { display: flex; gap: 0.6rem; }
.botpage-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 56px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
}
.botpage-form button {
  background: var(--brown);
  color: #fbf5e9;
  border: 0;
  border-radius: 8px;
  padding: 0 1.2rem;
  font-weight: 600;
  cursor: pointer;
}
.bot-meta { margin-top: 1rem; }
.bot-meta-body { padding: 0.5rem 0 0; font-size: 0.85rem; }
.bot-meta-body p { margin: 0.35rem 0; }
.bot-meta-body code {
  background: var(--subtle-bg);
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  font-size: 0.78rem;
}

.bk-team-link {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 0.4rem;
}
.bk-team-link:hover { color: var(--brown); }

@media (max-width: 760px) {
  .bot-portal { grid-template-columns: 1fr; }
  .bot-sidebar { position: static; }
}

/* ── Cardholder label pill + AJAX save button states ─────────── */

.card-label-pill {
  background: var(--brown);
  color: #fbf5e9;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.card-pill .digits {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  color: var(--text);
}
form.ajax-save button.ok {
  background: #2c5e1a !important;
  color: #fff !important;
  border-color: #2c5e1a !important;
}
form.ajax-save button.err {
  background: var(--danger-bg, #fbede7) !important;
  color: var(--danger-text, #9e3322) !important;
  border-color: var(--danger-border, #ecc5b5) !important;
}
.card-edit-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin: 0.35rem 0;
  flex-wrap: wrap;
}
.card-edit-form input {
  flex: 1;
  min-width: 200px;
}

/* ── Attach receipt/invoice inline file button ──────────────── */

.upload-doc-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  background: var(--brown);
  color: #fbf5e9;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--brown);
  transition: opacity 0.12s ease;
  user-select: none;
}
.upload-doc-btn:hover { opacity: 0.9; }
.upload-doc-label { white-space: nowrap; }
form.ajax-upload-doc.uploading .upload-doc-btn {
  opacity: 0.7; pointer-events: none;
}
form.ajax-upload-doc.err .upload-doc-btn {
  background: var(--danger-bg, #fbede7);
  color: var(--danger-text, #9e3322);
  border-color: var(--danger-border, #ecc5b5);
}

/* Filter bar (used on /reports/undocumented and similar) */
.filter-bar select, .filter-bar input {
  min-width: 160px;
}
