:root {
  /* Palette — softer, warmer tones. Background has a tiny lift away from pure
     white so cards visually separate without needing strong borders. */
  --bg: #f7f6f4;
  --surface: #ffffff;
  --surface-2: #f3f1ee;
  --surface-3: #ebe7e1;
  --border: #ece8e2;
  --border-strong: #d8d2c8;

  --text: #2a2725;
  --muted: #8a8278;

  --primary: #6b6ee0;          /* softer indigo (was sharper #2f6feb) */
  --primary-700: #4f52c4;
  --primary-soft: #eeeefb;

  --ok: #5fa980;               /* sage instead of vivid green */
  --ok-soft: #ebf3ee;
  --danger: #d96a5f;           /* coral instead of red */
  --danger-soft: #f6e7e4;
  --warn: #c99257;             /* warm amber */
  --warn-soft: #f6ece0;
  --accent: #efe7f5;

  --radius:    12px;           /* was 8px — softer corners */
  --radius-sm: 8px;
  --radius-lg: 16px;

  /* Shadows — multi-layer, lower opacity for a more diffused look. */
  --shadow:     0 1px 2px rgba(60, 50, 30, .04), 0 4px 14px rgba(60, 50, 30, .05);
  --shadow-lg:  0 6px 24px rgba(60, 50, 30, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.splash { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.grow { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }
.right { margin-left: auto; }
.center { text-align: center; }

/* ---- app shell: vertical sidebar + content area ---- */
.app-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.app-body  { display: flex; flex-direction: column; min-width: 0; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  gap: 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.sidebar-close { display: none; background: transparent; border: 0; font-size: 18px; padding: 4px 8px; color: var(--muted); cursor: pointer; }
.brand { font-weight: 600; font-size: 16px; letter-spacing: -.1px; }
.sidebar-foot {
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 600;
  padding: 12px 12px 4px;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; padding-left: 8px; }
.nav-group a { font-size: 13px; }
.nav a {
  text-decoration: none; color: var(--muted);
  padding: 9px 12px; border-radius: var(--radius-sm); font-weight: 500;
  font-size: 13.5px;
  transition: background .12s ease, color .12s ease;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-700); }

.user-box { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.user-box .name { font-weight: 500; font-size: 13px; }
.user-box .role { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); text-transform: uppercase; }
/* Sidebar location switcher reuses base select styles; just stretch to full width. */
.loc-switcher select { width: 100%; }
.lang-switcher { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; align-self: flex-start; }
.lang-switcher button { border-radius: 0; border: 0; border-right: 1px solid var(--border); padding: 4px 8px; font-size: 11px; font-weight: 600; }
.lang-switcher button:last-child { border-right: 0; }

/* Mobile header — only visible on narrow screens */
.topbar-mobile {
  display: none; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 9;
}
.sidebar-toggle { background: transparent; border: 0; font-size: 22px; line-height: 1; padding: 4px 8px; cursor: pointer; }

.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20;
}

/* ---- main layout ---- */
.main { padding: 18px; max-width: 1400px; margin: 0 auto; width: 100%; min-width: 0; }

/* ---- responsive: tablet & phone ---- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .topbar-mobile { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 260px;
    z-index: 25; transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-block; }
  .sidebar-backdrop.show { display: block; }
  .main { padding: 14px; }
}
@media (min-width: 901px) {
  .topbar-mobile .brand { display: none; }
}
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 18px; margin: 18px 0 10px; }
h3 { font-size: 15px; margin: 10px 0 6px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.stat .value { font-size: 24px; font-weight: 600; letter-spacing: -.2px; }

/* ---- forms / inputs ---- */
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }

/* Base styles for every text/number input, textarea and select — wrapped in
 * a label or not. Native select arrow is hidden and replaced with a custom
 * SVG chevron so it looks the same in every browser. */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=datetime-local], input[type=tel],
input[type=search], input[type=url], input:not([type]),
select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px;
  transition: border-color .15s ease, box-shadow .15s ease;
  box-sizing: border-box; line-height: 1.3;
}
textarea { min-height: 72px; resize: vertical; }

select {
  /* Remove native chevron + draw a clean one via background-image.
   * Keep extra right padding so option text doesn't overlap the arrow. */
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%238a8278' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
select::-ms-expand { display: none; }    /* hide arrow in IE/Edge legacy */

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-2); color: var(--muted); cursor: not-allowed;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

button {
  font: inherit; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  padding: 8px 14px; border-radius: var(--radius-sm);
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
button:hover { background: var(--surface-2); }
button:active { transform: translateY(.5px); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-700); border-color: var(--primary-700); }
button.danger  { background: var(--surface); border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }
button.ghost   { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); background: var(--surface-2); }
button.sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.err { color: var(--danger); min-height: 18px; font-size: 13px; }
.ok  { color: var(--ok); font-size: 13px; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .4px; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; transition: background .12s ease; }
tr.clickable:hover td { background: var(--surface-2); }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }

/* ---- login ---- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, #eeeefb 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, #f6ece0 0%, transparent 50%),
              linear-gradient(180deg, #faf8f5 0%, #f7f6f4 100%);
}
.login { width: min(380px, 92vw); padding: 24px; }
.login h1 { font-size: 18px; margin: 0 0 14px; }
.login label { margin-bottom: 10px; }
.login button.primary { width: 100%; margin-top: 6px; }
.login .hint { margin-top: 10px; font-size: 12px; }
.loc-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.loc-list button { text-align: left; padding: 10px 12px; }

/* ---- modal ---- */
.modal-back {
  position: fixed; inset: 0; background: rgba(40,30,20,.35);
  backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 100;
  animation: fadein .15s ease-out;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(40,30,20,.18), 0 4px 12px rgba(40,30,20,.08);
  width: min(640px, 92vw); max-height: 88vh; overflow: auto;
  animation: scalein .18s ease-out;
}
.modal.wide { width: min(960px, 96vw); }
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-head .close { margin-left: auto; font-size: 20px; line-height: 1; padding: 2px 8px; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes scalein { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---- toast ---- */
#toast-root { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--text); color: #fff;
  padding: 12px 16px; border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(40,30,20,.16), 0 2px 6px rgba(40,30,20,.08);
  font-size: 13px; font-weight: 500;
  animation: slidein .22s cubic-bezier(.2,.7,.4,1);
}
.toast.err { background: var(--danger); }
.toast.ok  { background: var(--ok); }
@keyframes slidein { from { transform: translateX(12px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---- calendar ---- */
.cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-toolbar .date { font-weight: 600; min-width: 200px; text-align: center; }
.cal {
  display: grid;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; overflow-y: hidden; box-shadow: var(--shadow);
}
.cal-head { display: grid; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-head > div { padding: 8px 10px; font-weight: 600; font-size: 13px; border-right: 1px solid var(--border); }
.cal-head > div:last-child { border-right: 0; }
.cal-grid { display: grid; position: relative; }
.cal-col {
  border-right: 1px solid var(--border); position: relative;
  background-image: linear-gradient(to bottom, var(--surface-2) 1px, transparent 1px);
  background-size: 100% var(--row-h, 40px);
  background-position: 0 -1px;
}
.cal-col:last-child { border-right: 0; }
.cal-col.hours { background: var(--surface); border-right: 2px solid var(--border); background-image: none; }
.cal-hour-label { font-size: 11px; color: var(--muted); padding: 2px 6px; border-bottom: 1px dashed var(--border); display: flex; align-items: flex-start; }
.cal-slot { position: absolute; left: 4px; right: 4px; }
.cal-appt {
  position: absolute; left: 4px; right: 4px;
  background: var(--primary-soft); border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); padding: 5px 8px; font-size: 12px;
  overflow: hidden; cursor: pointer;
  box-shadow: 0 1px 3px rgba(60,50,30,.06);
  transition: box-shadow .15s ease;
}
.cal-appt:hover { box-shadow: 0 2px 8px rgba(60,50,30,.10); }
.cal-appt .t { font-weight: 600; }
.cal-appt .c { color: var(--text); }
.cal-appt .s { color: var(--muted); font-size: 11px; }
.cal-appt.status-done      { background: var(--ok-soft);     border-left-color: var(--ok); }
.cal-appt.status-cancelled { background: var(--danger-soft); border-left-color: var(--danger); opacity: .6; text-decoration: line-through; }
.cal-appt.status-no_show   { background: var(--warn-soft);   border-left-color: var(--warn); }

/* misc */
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; background: var(--surface-2); color: var(--muted); font-weight: 500; }
.tag.role-director { background: #efe7f5; color: #7d5a96; }
.tag.role-admin    { background: var(--primary-soft); color: var(--primary-700); }
.tag.role-staff    { background: var(--ok-soft); color: var(--ok); }
.tag.ok            { background: var(--ok-soft); color: var(--ok); }
.tag.danger        { background: var(--danger-soft); color: var(--danger); }
.tag.warn          { background: var(--warn-soft); color: var(--warn); }
.tag.info          { background: var(--primary-soft); color: var(--primary-700); }
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input { flex: 1; }

.empty { padding: 32px; text-align: center; color: var(--muted); }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.builder-row { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; margin-bottom: 6px; }
.builder-row select, .builder-row input { width: 100%; }

/* ---- month grid ---- */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.month-head {
  padding: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
  color: var(--muted); background: var(--surface-2); text-align: center;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.month-head:last-child { border-right: 0; }
.month-cell {
  min-height: 110px; padding: 6px 6px 8px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.month-cell:hover { background: var(--surface-2); }
.month-cell.other-month { background: #fafbfc; }
.month-cell.other-month .month-cell-head .d { color: var(--muted); }
.month-cell.today { background: var(--warn-soft); }
.month-cell.today .month-cell-head .d { background: var(--primary); color: #fff; }
.month-cell-head { display: flex; align-items: center; justify-content: space-between; }
.month-cell-head .d {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; font-weight: 600; font-size: 12px;
}
.month-cell-head .cnt {
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent); color: var(--primary-700); font-weight: 600;
}
.month-cell-list { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.month-item {
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
  background: var(--primary-soft); border-left: 2px solid var(--primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.month-item .t { font-weight: 600; }
.month-item.status-done      { background: var(--ok-soft);     border-left-color: var(--ok); }
.month-item.status-cancelled { background: var(--danger-soft); border-left-color: var(--danger); opacity: .65; text-decoration: line-through; }
.month-item.status-no_show   { background: var(--warn-soft);   border-left-color: var(--warn); }
.month-more { font-size: 11px; color: var(--muted); padding: 0 5px; }

.mode-switch { display: inline-flex; gap: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.mode-switch button { border-radius: 0; border: 0; border-right: 1px solid var(--border); }
.mode-switch button:last-child { border-right: 0; }

.cal-appt-ghost { box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.cal-appt { user-select: none; }

/* ---- report wizard ---- */
.wiz-q { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.wiz-label { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
.wiz-sublabel { font-size: 12px; color: var(--muted); margin-top: 8px; margin-bottom: 4px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}
.pill:hover { background: var(--surface-2); }
.pill.on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.pill.on:hover { background: var(--primary-700); }

/* ---- template editor with live preview ---- */
.tpl-edit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start;
}
.tpl-edit-left, .tpl-edit-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tpl-edit-right .preview-subject-wrap {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 8px; display: flex; align-items: baseline; flex-wrap: wrap;
}
.tpl-edit-right .preview-subject { font-weight: 600; font-size: 14px; word-break: break-word; }
.tpl-edit-right .preview-frame {
  width: 100%; min-height: 320px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
}
@media (max-width: 980px) {
  .tpl-edit-grid { grid-template-columns: 1fr; }
  .tpl-edit-right .preview-frame { min-height: 220px; }
}

/* ---- leads (open-lines style inbox) ---- */
.leads-layout { display: grid; grid-template-columns: 360px 1fr; gap: 14px; align-items: start; }
.leads-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 220px); overflow-y: auto; }
.lead-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; cursor: pointer; transition: background .12s ease, border-color .12s ease;
}
.lead-card:hover { background: var(--surface-2); }
.lead-card.active { border-color: var(--primary); background: var(--primary-soft); }
.lead-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; flex-wrap: wrap; }
.lead-card-name { font-weight: 600; font-size: 13.5px; }
.lead-card-last { margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-source-badge {
  font-size: 11px; background: var(--surface-2); color: var(--text);
  padding: 2px 8px; border-radius: 999px; font-weight: 500;
}
.lead-chat-label {
  font-size: 11px; padding: 2px 6px; border-radius: 4px;
  background: var(--accent); color: var(--primary-700);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.leads-detail { min-height: 320px; }
.lead-thread { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; max-height: 50vh; overflow-y: auto; padding-right: 4px; }
.lead-comment { padding: 8px 12px; border-radius: 10px; max-width: 78%; }
.lead-comment.in  { background: var(--surface-2); align-self: flex-start; }
.lead-comment.out { background: var(--primary-soft); align-self: flex-end; border: 1px solid var(--primary); }
.lead-comment.note { background: var(--warn-soft); align-self: stretch; max-width: 100%; border-left: 3px solid var(--warn); }
.lead-comment-meta { font-size: 10.5px; margin-bottom: 3px; }
.lead-comment-text { white-space: pre-wrap; word-break: break-word; }
.lead-comment-status { font-size: 11px; margin-top: 2px; }
.lead-comment-status.err { color: var(--danger); }
.lead-reply { display: flex; flex-direction: column; gap: 4px; }

@media (max-width: 900px) {
  .leads-layout { grid-template-columns: 1fr; }
  .leads-list { max-height: none; }
  .lead-comment { max-width: 92%; }
}

/* ---- help page ---- */
.help-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.help-toc {
  position: sticky; top: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
  max-height: calc(100vh - 36px); overflow-y: auto;
  min-width: 0;
}
.help-toc-title { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.help-toc-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--primary-700); font-weight: 600;
  margin-top: 12px; padding: 4px 6px;
  border-top: 1px solid var(--border);
}
.help-toc ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.help-toc a { text-decoration: none; color: var(--muted); font-size: 13px; padding: 4px 6px; border-radius: 4px; display: block; }
.help-toc a:hover { background: var(--surface-2); color: var(--text); }
.help-module-divider {
  margin: 32px -28px 16px;
  padding: 14px 28px;
  background: var(--primary-soft);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.help-module-divider h2 {
  margin: 0; color: var(--primary-700); font-size: 18px;
  border: 0; padding: 0;
}
.help-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; box-shadow: var(--shadow); min-width: 0; }
.help-body pre { background: var(--surface-2); padding: 10px 12px; border-radius: 6px; overflow-x: auto; font-size: 12px; line-height: 1.4; }
.help-body pre code { background: transparent; padding: 0; font-size: inherit; }
.help-body section { margin-bottom: 28px; scroll-margin-top: 18px; }
.help-body section:last-child { margin-bottom: 0; }
.help-body h2 { margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.help-body h3 { margin: 16px 0 8px; }
.help-body p, .help-body ul, .help-body ol { margin: 8px 0; }
.help-body ul, .help-body ol { padding-left: 22px; }
.help-body li { margin: 4px 0; }
.help-body code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; font-family: ui-monospace, "SF Mono", Consolas, Menlo, monospace; }
.help-body .warn { background: var(--warn-soft); border-left: 3px solid var(--warn); padding: 8px 12px; border-radius: 0 6px 6px 0; }
.help-banner {
  background: var(--primary-soft); border-radius: 6px; padding: 10px 14px;
  margin-bottom: 16px; font-size: 13px;
}

/* ---- responsive: phone (collapse 2-col grids, stack builder rows) ---- */
@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
  .builder-row { grid-template-columns: 1fr; gap: 6px; }
  .builder-row > button { justify-self: end; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }
  .kv dd { margin-bottom: 6px; }

  /* Dashboard 2-col grid (inline style in dashboard.js) → 1-col on phone via class */
  .dash-grid { grid-template-columns: 1fr !important; }

  /* Modal — tighter horizontal padding so content has more room */
  .modal { width: min(640px, 96vw); }
  .modal-head, .modal-body, .modal-foot { padding-left: 14px; padding-right: 14px; }

  /* Page headers — wrap toolbar buttons under the title */
  .page-head { flex-wrap: wrap; }
  h1 { font-size: 19px; }
  h2 { font-size: 16px; }

  /* Cards inside cal/dashboard padding tighter */
  .card { padding: 14px; }

  /* Calendar toolbar: smaller date label so it wraps less */
  .cal-toolbar .date { min-width: auto; flex: 1; text-align: center; }

  /* Help: stack TOC above content */
  .help-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .help-toc { position: static; max-height: none; }
  .help-body { padding: 16px; }
  /* Cancel the desktop full-bleed divider — there's no padding to bleed into. */
  .help-module-divider { margin: 24px 0 12px; padding: 12px 16px; }

  /* Wrap horizontal flex rows on phone — tab bars / toolbars / button groups
     have many items in a .row; without wrap they push the page wider than
     the viewport. */
  .row { flex-wrap: wrap; }
}

/* License banner — sits at the top of .app-body. Colour varies by severity. */
.license-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
}
.license-banner a { font-weight: 600; }
.license-banner-expiring_soon, .license-banner-grace,
.license-banner-server_unreachable {
  background: var(--warn-soft); color: #6e4a17; border-bottom-color: var(--warn);
}
.license-banner-expired, .license-banner-revoked,
.license-banner-not_found, .license-banner-not_configured {
  background: var(--danger-soft); color: #8a3a31; border-bottom-color: var(--danger);
}
/* Reuse tag for status badges in the License settings tab */
.tag-ok     { background: var(--ok-soft);     color: #2d5a3b; }
.tag-warn   { background: var(--warn-soft);   color: #6e4a17; }
.tag-danger { background: var(--danger-soft); color: #8a3a31; }
