/* ====================================================================
   Wulfric CRM — design system
   ==================================================================== */

/* Hosted-demo ribbon (only rendered when the server runs --demo) */
.demo-ribbon {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(20, 24, 34, .92);
  color: #e8e8e4;
  font-size: 12.5px;
  letter-spacing: .02em;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .14);
  white-space: nowrap;
}
.demo-ribbon a { color: #7ee8c8; text-decoration: none; }
.demo-ribbon a:hover { text-decoration: underline; }

:root {
  --font: "Space Grotesk", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;

  /* Wulfric light — moonlight paper */
  --bg: #f1efe8;
  --bg-soft: #e9e6dd;
  --card: #fdfcf9;
  --card-soft: #f6f4ee;
  --ink: #1d1f28;
  --ink-soft: #5c5f68;
  --ink-faint: #90918c;
  --line: #e2dfd4;
  --line-strong: #ccc8bb;

  --primary: #0c7a61;
  --primary-soft: #ddefe8;
  --primary-ink: #0a5d4a;
  --accent: #7ee8c8;
  --accent-deep: #2bbd96;
  --danger: #b3402f;
  --danger-soft: #f7e4e0;
  --info: #5d4fc7;
  --info-soft: #e9e6fa;

  /* sidebar wears the void in both themes — that's the brand */
  --sidebar-bg: #05060a;
  --sidebar-ink: #a9a79e;
  --sidebar-ink-strong: #e9e6dd;
  --sidebar-active: rgba(126, 232, 200, 0.12);

  --tier-a-bg: #f3e7c4; --tier-a-ink: #8a6414;
  --tier-b-bg: #d8efe7; --tier-b-ink: #0c6b54;
  --tier-c-bg: #e6e2f8; --tier-c-ink: #5246a8;
  --tier-d-bg: #e8e6e0; --tier-d-ink: #6b6f68;

  --overdue: #b3402f;
  --due: #c9952e;

  --shadow-sm: 0 1px 2px rgba(29, 31, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(29, 31, 40, 0.08);
  --shadow-lg: 0 12px 40px rgba(29, 31, 40, 0.18);

  --radius: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  /* Wulfric dark — deep space */
  --bg: #07080d;
  --bg-soft: #0b0d14;
  --card: #10131d;
  --card-soft: #151926;
  --ink: #e9e6dd;
  --ink-soft: #a7a59c;
  --ink-faint: #6e6d66;
  --line: #1c1f2a;
  --line-strong: #2a2e3d;

  --primary: #128a6e;
  --primary-soft: #11302a;
  --primary-ink: #7ee8c8;
  --danger: #e07b68;
  --danger-soft: #3a2420;
  --info: #8b7cf6;
  --info-soft: #221e3a;

  --sidebar-bg: #05060a;
  --sidebar-ink: #a9a79e;

  --tier-a-bg: #33301a; --tier-a-ink: #e3c878;
  --tier-b-bg: #112e27; --tier-b-ink: #7ee8c8;
  --tier-c-bg: #1e1b36; --tier-c-ink: #b0a4fa;
  --tier-d-bg: #23252e; --tier-d-ink: #9b9a92;

  --overdue: #f0857a;
  --due: #ddb765;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
svg { display: block; }
button { font-family: inherit; }
::placeholder { color: var(--ink-faint); }

/* ---------- layout ---------- */

#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand-name { font-size: 19px; font-weight: 700; color: var(--sidebar-ink-strong); letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; opacity: 0.75; margin-top: -2px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-ink);
  font-weight: 500;
  font-size: 14px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--accent);
}
.nav-item.active .nav-icon svg { stroke: var(--accent); }
.nav-icon svg { width: 18px; height: 18px; stroke: var(--sidebar-ink); }

.sidebar-add { margin-top: 18px; width: 100%; justify-content: center; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.theme-toggle {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--sidebar-ink);
  padding: 8px 12px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.06); }
.theme-toggle svg { width: 15px; height: 15px; stroke: var(--sidebar-ink); }
.sidebar-tip { font-size: 11px; opacity: 0.55; line-height: 1.5; padding: 0 4px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 40;
}
.topbar-date { color: var(--ink-soft); font-size: 13.5px; white-space: nowrap; }

.search-wrap { position: relative; flex: 1; max-width: 480px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search-icon svg { width: 15px; height: 15px; stroke: var(--ink-faint); }
.search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 380px; overflow-y: auto;
  z-index: 60;
}
.search-result {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 14px; cursor: pointer;
}
.search-result:hover, .search-result.selected { background: var(--bg-soft); }
.search-result-meta { font-size: 12px; color: var(--ink-soft); }
.search-empty { padding: 14px; color: var(--ink-soft); font-size: 13.5px; text-align: center; }

.view { padding: 26px 32px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.view-title { font-size: 24px; }
.view-sub { color: var(--ink-soft); font-size: 14px; margin-top: 3px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: filter 0.12s, background 0.12s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { filter: brightness(1.05); }
.btn:active { filter: brightness(0.95); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary svg { stroke: #fff; }
.btn-accent { background: var(--accent); color: #06241c; }
.btn-accent svg { stroke: #06241c; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line-strong); }
.btn-ghost svg { stroke: var(--ink-soft); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: none; background: transparent; cursor: pointer;
}
.icon-btn svg { width: 15px; height: 15px; stroke: var(--ink-soft); }
.icon-btn:hover { background: var(--bg-soft); }
.icon-btn:hover svg { stroke: var(--ink); }

/* ---------- cards & stats ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-head h3 svg { width: 16px; height: 16px; stroke: var(--primary); }
.card-head .count-pill { margin-left: 2px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { padding: 15px 18px; cursor: default; }
.stat-card.clickable { cursor: pointer; transition: box-shadow 0.15s, transform 0.15s; }
.stat-card.clickable:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-num { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat-num.warn { color: var(--overdue); }
.stat-num.due { color: var(--accent-deep); }
.stat-label { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-col { display: flex; flex-direction: column; gap: 18px; }

/* ---------- badges, chips, avatars ---------- */

.tier-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 6px;
  font-size: 11.5px; font-weight: 700;
}
.tier-A { background: var(--tier-a-bg); color: var(--tier-a-ink); }
.tier-B { background: var(--tier-b-bg); color: var(--tier-b-ink); }
.tier-C { background: var(--tier-c-bg); color: var(--tier-c-ink); }
.tier-D { background: var(--tier-d-bg); color: var(--tier-d-ink); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: var(--bg-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.chip.tag { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }

.count-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--bg-soft); color: var(--ink-soft);
  font-size: 11.5px; font-weight: 700;
}
.count-pill.warn { background: var(--danger-soft); color: var(--overdue); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 13px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }

/* ---------- filter bar / segmented ---------- */

.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.seg button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

select.select, input.input, textarea.textarea {
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
}
select.select:focus, input.input:focus, textarea.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea.textarea { resize: vertical; min-height: 70px; }

/* ---------- contact list ---------- */

.contact-list { display: flex; flex-direction: column; }
.contact-row {
  display: grid;
  grid-template-columns: 44px minmax(160px, 1.4fr) 1fr 0.9fr 0.9fr auto;
  align-items: center; gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s;
}
.contact-row:last-child { border-bottom: none; }
.contact-row:hover { background: var(--card-soft); }
.contact-name { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.contact-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-sub { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.contact-cell { font-size: 13px; color: var(--ink-soft); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); }
.followup-cell.overdue { color: var(--overdue); font-weight: 600; }
.followup-cell.today { color: var(--due); font-weight: 600; }

@media (max-width: 900px) {
  .contact-row { grid-template-columns: 44px 1.4fr 1fr auto; }
  .contact-row .hide-narrow { display: none; }
}

/* ---------- agenda / due list items ---------- */

.agenda-item {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.agenda-item:last-child { border-bottom: none; }
.agenda-main { flex: 1; min-width: 0; cursor: pointer; }
.agenda-title { font-weight: 600; font-size: 14px; }
.agenda-title:hover { color: var(--primary); }
.agenda-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
.agenda-sub .overdue-text { color: var(--overdue); font-weight: 600; }
.agenda-sub .due-text { color: var(--due); font-weight: 600; }
.agenda-actions { display: flex; gap: 6px; flex-shrink: 0; }

.date-bubble {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-soft);
  flex-shrink: 0; line-height: 1.05;
}
.date-bubble .db-mon { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--ink-faint); letter-spacing: 0.06em; }
.date-bubble .db-day { font-size: 17px; font-weight: 700; }
.date-bubble.today { background: var(--accent); }
.date-bubble.today .db-mon, .date-bubble.today .db-day { color: #3d2f0a; }

.celebration-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.celebration-icon svg { width: 18px; height: 18px; }
.celebration-icon.birthday { background: var(--info-soft); }
.celebration-icon.birthday svg { stroke: var(--info); }
.celebration-icon.anniversary { background: var(--tier-a-bg); }
.celebration-icon.anniversary svg { stroke: var(--tier-a-ink); }
.celebration-icon.event { background: var(--primary-soft); }
.celebration-icon.event svg { stroke: var(--primary-ink); }

/* ---------- contact detail ---------- */

.detail-head {
  display: flex; align-items: flex-start; gap: 18px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.detail-head-main { flex: 1; min-width: 240px; }
.detail-name { font-size: 25px; font-weight: 700; display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.detail-meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; flex-wrap: wrap; color: var(--ink-soft); font-size: 13px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }

.fact-list { display: flex; flex-direction: column; }
.fact {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 9px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.fact:last-child { border-bottom: none; }
.fact svg { width: 15px; height: 15px; stroke: var(--ink-faint); margin-top: 2px; flex-shrink: 0; }
.fact-label { width: 92px; flex-shrink: 0; color: var(--ink-faint); font-size: 12px; padding-top: 1px; }
.fact-value { flex: 1; min-width: 0; word-break: break-word; }
.fact-value .copyable { cursor: pointer; border-bottom: 1px dashed var(--line-strong); }
.fact-value .copyable:hover { color: var(--primary); border-color: var(--primary); }

.next-followup-card { padding: 16px 20px; }
.nf-status { font-size: 13px; color: var(--ink-soft); margin-bottom: 10px; }
.nf-date { font-size: 19px; font-weight: 700; }
.nf-date.overdue { color: var(--overdue); }
.nf-date.today { color: var(--due); }
.nf-actions { display: flex; gap: 8px; margin-top: 13px; flex-wrap: wrap; }

/* ---------- timeline ---------- */

.timeline { padding: 6px 0; }
.timeline-item { display: flex; gap: 13px; padding: 11px 20px; position: relative; }
.timeline-item:not(:last-child)::before {
  content: ""; position: absolute;
  left: 35px; top: 44px; bottom: -8px;
  width: 2px; background: var(--line);
}
.touch-icon {
  width: 31px; height: 31px; border-radius: 50%;
  background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; z-index: 1;
}
.touch-icon svg { width: 14px; height: 14px; stroke: var(--primary-ink); }
.timeline-body { flex: 1; min-width: 0; }
.timeline-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.touch-type { font-weight: 650; font-size: 13.5px; }
.touch-date { font-size: 12px; color: var(--ink-faint); }
.touch-note { margin-top: 2px; font-size: 13.5px; color: var(--ink-soft); white-space: pre-wrap; word-break: break-word; }
.timeline-item .icon-btn { opacity: 0; transition: opacity 0.12s; }
.timeline-item:hover .icon-btn { opacity: 1; }

.quicknote-row { display: flex; gap: 9px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.quicknote-row input { flex: 1; }

/* ---------- upcoming ---------- */

.month-block { margin-bottom: 26px; }
.month-label {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin: 0 0 9px 4px;
}

/* ---------- forms / modal ---------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 22, 18, 0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 20px;
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px;
  animation: modalIn 0.18s ease-out;
}
.modal.modal-sm { max-width: 460px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 17px 22px 0;
}
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 18px 22px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 0 22px 20px;
}
.modal-foot .spacer { margin-right: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 14px; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: span 1; } }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field .hint { font-size: 11px; color: var(--ink-faint); }
.field input, .field select, .field textarea { width: 100%; }

.form-section {
  grid-column: span 2;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px; margin-top: 8px;
}
@media (max-width: 560px) { .form-section { grid-column: span 1; } }

.type-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.type-pick {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.type-pick svg { width: 14px; height: 14px; stroke: var(--ink-soft); }
.type-pick.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-ink);
}
.type-pick.active svg { stroke: var(--primary-ink); }

/* ---------- toast ---------- */

#toastRoot {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 200; pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease-out;
}
[data-theme="dark"] .toast { background: #e7e5de; color: #1a201c; }
.toast.toast-error { background: var(--danger); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- empty states ---------- */

.empty {
  text-align: center;
  padding: 44px 24px;
  color: var(--ink-soft);
}
.empty svg { width: 38px; height: 38px; stroke: var(--ink-faint); margin: 0 auto 12px; }
.empty h3 { font-size: 16px; color: var(--ink); margin-bottom: 5px; }
.empty p { margin: 0 0 16px; font-size: 13.5px; }
.empty .btn { margin: 0 4px; }

.welcome-hero {
  text-align: center;
  padding: 64px 30px;
}
.welcome-hero h2 { font-size: 26px; margin-bottom: 9px; }
.welcome-hero p { color: var(--ink-soft); max-width: 520px; margin: 0 auto 24px; font-size: 15px; }
.welcome-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- settings ---------- */

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: none; }
.settings-row-text { flex: 1; }
.settings-row-title { font-weight: 600; font-size: 13.5px; }
.settings-row-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
.cadence-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cadence-grid .field input { text-align: center; }

.import-preview { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 12px; }
.import-preview table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.import-preview th, .import-preview td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.import-preview th { background: var(--bg-soft); position: sticky; top: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); }

.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 12px; }
.map-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.map-row .col-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.map-row select { width: 150px; }

.danger-zone { border-color: var(--danger); }
.danger-zone .card-head { border-color: var(--danger-soft); }
.danger-zone .card-head h3 svg { stroke: var(--danger); }

/* ---------- misc ---------- */

.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 12.5px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-soft);
  font-size: 11px; font-weight: 600;
  font-family: inherit;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 760px) {
  /* sidebar becomes an app-style bottom tab bar */
  #app { flex-direction: column; }
  .sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    padding: 0;
    border-top: 1px solid var(--line-strong);
    z-index: 50;
  }
  .brand, .sidebar-tip, .sidebar-foot { display: none; }
  .nav { flex-direction: row; flex: 1; gap: 0; }
  .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    padding: 9px 2px;
    font-size: 10px;
    line-height: 1.1;
    border-radius: 0;
    text-align: center;
  }
  .nav-item .nav-icon svg { width: 21px; height: 21px; }

  /* Add Contact becomes a floating action button */
  .sidebar-add {
    position: fixed;
    bottom: 70px; right: 16px;
    width: 54px; height: 54px;
    margin: 0; padding: 0;
    border-radius: 50%;
    justify-content: center;
    font-size: 0;
    z-index: 51;
    box-shadow: var(--shadow-lg);
  }
  .sidebar-add svg { width: 22px; height: 22px; }

  /* content + chrome clear the fixed bottom bar */
  .main { min-height: auto; }
  .view { padding: 16px 14px 96px; }
  .topbar { padding: 12px 14px; }
  .topbar-date { display: none; }

  /* demo badge would sit on top of the tab bar */
  .demo-ribbon { display: none; }
}

@media print {
  .sidebar, .topbar, .btn, .icon-btn { display: none !important; }
  .view { padding: 0; max-width: none; }
  body { background: #fff; }
}

/* ---------- Wulfric brand layer ---------- */
.brand-name { font-family: var(--font-display); font-weight: 550; letter-spacing: 0; }
.view-title { font-family: var(--font-display); font-weight: 500; letter-spacing: 0; }
