/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --blue:       #3d6b8a;
  --blue-light: #e8f0f5;
  --blue-dark:  #2c5270;
  --green:      #16a34a;
  --green-light:#f0fdf4;
  --amber:      #d97706;
  --amber-light:#fffbeb;
  --red:        #dc2626;
  --red-light:  #fef2f2;
  --error:      #dc2626;
  --slate:      #5b7d92;
  --slate-light:#eef3f6;
  --border:     #d7e2e8;
  --bg:         #eef3f6;
  --card:       #ffffff;
  --card-alpha: rgba(255,255,255,.88);
  --text:       #1e2f38;
  --text-muted: #44586b;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(15,35,48,.12), 0 1px 2px rgba(15,35,48,.08);
  --shadow-md:  0 4px 6px rgba(15,35,48,.1), 0 2px 4px rgba(15,35,48,.07);
  --bg-image:   url('img/bg.png');
  --bg-scrim:   rgba(238,243,246,.55);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; }
html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; color: var(--text); font-size: 15px; }
body {
  overflow-x: hidden;
  background-color: var(--bg);
  background-image: linear-gradient(var(--bg-scrim), var(--bg-scrim)), var(--bg-image);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}
button { cursor: pointer; font: inherit; color: inherit; }
input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Top Nav ───────────────────────────────────────────────────────────────── */
.topnav {
  background: var(--blue);
  color: #fff;
  padding: 0 1rem;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
  flex-wrap: wrap;
}
.topnav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.topnav-logo { height: 28px; width: 28px; object-fit: contain; border-radius: 4px; }
.topnav-spacer { flex: 1; min-width: 0; }
.topnav-user { font-size: .85rem; opacity: .85; white-space: nowrap; }
.topnav-actions { display: flex; align-items: center; gap: .35rem; }

/* ── Health bar ────────────────────────────────────────────────────────────── */
.health-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 1rem;
  height: 28px;
  background: var(--card-alpha);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  font-size: .72rem;
  font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  color: var(--text-muted);
  overflow-x: auto;
  white-space: nowrap;
}
.health-stat { padding: 0 .75rem; }
.health-sep  { width: 1px; height: 14px; background: var(--border); flex-shrink: 0; }

.view-tabs { display: flex; gap: .25rem; }
.view-tab {
  padding: .35rem .75rem;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,.35);
  background: transparent;
  color: rgba(255,255,255,.85);
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s;
}
.view-tab:hover { background: rgba(255,255,255,.15); }
.view-tab.active { background: #fff; color: var(--blue); border-color: #fff; }

.btn-ghost-white {
  padding: .35rem .75rem;
  border-radius: 6px;
  border: 1.5px solid rgba(255,255,255,.35);
  background: transparent;
  color: rgba(255,255,255,.85);
  font-size: .85rem;
  transition: all .15s;
}
.btn-ghost-white:hover { background: rgba(255,255,255,.15); }

/* ── Follow-up notification ────────────────────────────────────────────────── */
.followup-notify-wrap { position: relative; }
.followup-badge {
  position: absolute;
  top: 1px; right: 1px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: #ef4444;
  color: #fff;
  border-radius: 99px;
  font-size: .62rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}
.followup-dropdown {
  position: fixed;
  max-height: min(440px, calc(100vh - 80px));
  overflow-y: auto;
  background: var(--card-alpha);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 1100;
}
.followup-dropdown-header {
  padding: .6rem 1rem;
  font-weight: 600;
  font-size: .82rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--slate-light);
  border-radius: var(--radius) var(--radius) 0 0;
}
.followup-item {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
}
.followup-item:last-child { border-bottom: none; }
.followup-item-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .5rem;
  margin-bottom: .25rem;
}
.followup-item-title { font-weight: 600; font-size: .875rem; }
.followup-item-date  { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.followup-item-note  { font-size: .8rem; color: var(--text-muted); margin-bottom: .35rem; }
.followup-item-actions { display: flex; gap: .4rem; }

/* ── Page content ──────────────────────────────────────────────────────────── */
.page { flex: 1; padding: 1.25rem 1rem; max-width: 1100px; width: 100%; margin: 0 auto; }

.app-footer { text-align: center; padding: .75rem 1rem 1.25rem; font-size: .75rem; color: var(--text-muted); }
.app-footer a { color: var(--text-muted); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* ── Calendar header ───────────────────────────────────────────────────────── */
.cal-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.cal-title { font-size: 1.2rem; font-weight: 700; min-width: 180px; }
.cal-legend { display: flex; gap: .85rem; flex-wrap: wrap; margin-bottom: .75rem; }
.cal-legend-item { display: flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--text-muted); }
.cal-legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.cal-legend-swatch.status-pending   { background: var(--amber); }
.cal-legend-swatch.status-confirmed { background: var(--green); }
.cal-legend-swatch.status-cancelled { background: var(--red); }
.cal-legend-swatch.status-completed { background: var(--slate); }
.btn-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: all .15s;
}
.btn-icon:hover { background: var(--slate-light); }
.btn-today {
  padding: .35rem .85rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: .85rem;
  font-weight: 500;
  transition: all .15s;
}
.btn-today:hover { background: var(--slate-light); }

/* ── Month grid ────────────────────────────────────────────────────────────── */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-alpha);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.month-dow {
  padding: .5rem .25rem;
  text-align: center;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--slate-light);
  border-bottom: 1.5px solid var(--border);
}
.month-cell {
  min-height: 90px;
  padding: .4rem .35rem .3rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  position: relative;
}
.month-cell:nth-child(7n) { border-right: none; }
.month-cell:hover { background: var(--blue-light); }
.month-cell.other-month .day-num { color: #c8d0dc; }
.month-cell.today .day-num {
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
}
.month-cell.selected { background: var(--blue-light); }
.day-num { font-size: .85rem; font-weight: 600; margin-bottom: .25rem; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; }
.day-bookings { display: flex; flex-direction: column; gap: 2px; }
.day-chip {
  font-size: .7rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--blue-light);
  color: var(--blue-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.day-chip.status-confirmed  { background: var(--green-light); color: var(--green); }
.day-chip.status-completed  { background: var(--slate-light); color: var(--slate); }
.day-chip.status-cancelled  { background: var(--red-light); color: var(--red); text-decoration: line-through; }
.day-chip.status-pending    { background: var(--amber-light); color: var(--amber); }
.day-more { font-size: .7rem; color: var(--text-muted); padding-left: 2px; }

/* ── Week view ─────────────────────────────────────────────────────────────── */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .5rem;
}
.week-col {
  background: var(--card-alpha);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .12s, border-color .12s;
}
.week-col:hover { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-light); }
.week-col-header {
  padding: .5rem;
  text-align: center;
  background: var(--slate-light);
  border-bottom: 1.5px solid var(--border);
}
.week-col:hover .week-col-header { background: var(--blue-light); }
.week-col-header.today { background: var(--blue); color: #fff; }
.week-dow { font-size: .72rem; font-weight: 600; color: var(--text-muted); }
.week-col-header.today .week-dow { color: rgba(255,255,255,.8); }
.week-date { font-size: 1.1rem; font-weight: 700; }
.week-bookings { padding: .4rem; display: flex; flex-direction: column; gap: 4px; min-height: 60px; }
.week-chip {
  font-size: .72rem;
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--blue-light);
  color: var(--blue-dark);
  cursor: pointer;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity .15s;
}
.week-chip:hover { opacity: .8; }
.week-chip.status-confirmed { background: var(--green-light); color: var(--green); }
.week-chip.status-completed { background: var(--slate-light); color: var(--slate); }
.week-chip.status-cancelled { background: var(--red-light); color: var(--red); text-decoration: line-through; }
.week-chip.status-pending   { background: var(--amber-light); color: var(--amber); }
.week-add { font-size: .75rem; color: var(--text-muted); padding: 0 .4rem .4rem; }
.week-add button { background: none; border: none; color: var(--blue); font-size: .75rem; padding: 0; cursor: pointer; }
.week-add button:hover { text-decoration: underline; }

/* ── Day view ──────────────────────────────────────────────────────────────── */
.day-view-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.day-view-title { font-size: 1.2rem; font-weight: 700; }
/* ── Day time grid ─────────────────────────────────────────────────────────── */
.day-time-grid {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card-alpha);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.time-slot {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}
.time-slot:last-child { border-bottom: none; }
.time-label {
  width: 58px;
  min-width: 58px;
  padding: .55rem .45rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  border-right: 1px solid var(--border);
  background: var(--slate-light);
  line-height: 1.2;
  user-select: none;
}
.time-slot-bookings {
  flex: 1;
  padding: .35rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  min-width: 0;
}
.time-slot--empty { opacity: .55; }
.time-slot--empty .time-slot-bookings { background: repeating-linear-gradient(135deg, transparent, transparent 6px, rgba(0,0,0,.015) 6px, rgba(0,0,0,.015) 12px); }
.time-slot--now .time-label { color: var(--blue); font-weight: 700; background: var(--blue-light); }
.time-slot--now { border-left: 3px solid var(--blue); }
.time-slot--unscheduled .time-label { color: var(--text-muted); font-style: italic; }
.day-closed-notice {
  font-size: .82rem;
  color: var(--amber);
  background: var(--amber-light);
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
  padding: .4rem .75rem;
  margin-bottom: .65rem;
}

.booking-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow);
}
.booking-card:hover { border-color: var(--blue); box-shadow: var(--shadow-md); }
.booking-card--assigned { border: 2px solid var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.booking-card--assigned:hover { box-shadow: 0 0 0 3px rgba(59,130,246,.25), var(--shadow-md); }

/* ── Line items table ─────────────────────────────────────────────────────── */
.line-items-table { border-collapse: collapse; font-size: .85rem; }
.line-items-table th { text-align: left; padding: .3rem .5rem; font-weight: 600; font-size: .78rem; color: var(--text-muted); border-bottom: 1.5px solid var(--border); }
.line-items-table td { padding: .3rem .5rem; border-bottom: 1px solid var(--border); }
.line-items-table tfoot td { border-top: 1.5px solid var(--border); border-bottom: none; }
.li-editor-table input { background: var(--card); color: var(--text); border: 1.5px solid var(--border); border-radius: 4px; padding: .25rem .4rem; font-family: inherit; font-size: .85rem; }
.li-editor-table input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
.booking-info { min-width: 0; }
.booking-title { font-weight: 600; font-size: .9rem; margin-bottom: .15rem; }
.booking-time-tag {
  font-size: .72rem;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
  border-radius: 4px;
  padding: 1px 5px;
}
.booking-meta { font-size: .78rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.status-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.status-pending   { background: var(--amber-light); color: var(--amber); }
.status-confirmed { background: var(--green-light); color: var(--green); }
.status-completed { background: var(--slate-light); color: var(--slate); }
.status-cancelled { background: var(--red-light); color: var(--red); }
.conflict-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  background: var(--amber-light);
  color: var(--amber);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.empty-state p { font-size: .9rem; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius);
  border: none;
  font-weight: 600;
  font-size: .875rem;
  transition: all .15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--slate-light); }
.btn-danger { background: var(--red-light); color: var(--red); border: 1.5px solid #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(37,99,235,.4);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  z-index: 50;
}
.btn-fab:hover { background: var(--blue-dark); transform: scale(1.05); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  overflow: hidden;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card-alpha);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -4px 24px rgba(0,0,0,.15);
  animation: slideUp .2s ease;
  overflow: hidden;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
  padding: 1rem 1.25rem .75rem;
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0; /* always visible - never squished by tall body content */
}
.modal-title { font-weight: 700; font-size: 1rem; flex: 1; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--slate-light);
  color: var(--text-muted);
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 1rem 1.25rem; }
.modal-footer {
  padding: .75rem 1.25rem;
  border-top: 1.5px solid var(--border);
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  flex-shrink: 0; /* always visible */
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: .85rem; position: relative; }

/* Autocomplete dropdown */
.ac-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--card);
  border: 1.5px solid var(--blue);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
  max-height: 180px;
  overflow-y: auto;
  z-index: 10;
  list-style: none;
  margin: 0; padding: .2rem 0;
}
.ac-list li {
  padding: .45rem .75rem;
  font-size: .875rem;
  cursor: pointer;
  color: var(--text);
}
.ac-list li { display: flex; flex-direction: column; }
.ac-list li:hover, .ac-list li.ac-active { background: var(--slate-light); }
.ac-list li:hover .ac-name, .ac-list li.ac-active .ac-name { color: var(--blue); }
.ac-name { font-weight: 500; }
.ac-hints { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .3rem; color: var(--text); }
label .req { color: var(--red); margin-left: 2px; }
input[data-secret] { -webkit-text-security: disc; text-security: disc; }
input[data-secret]::placeholder { -webkit-text-security: none; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font-size: .875rem;
  transition: border-color .15s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea { resize: vertical; min-height: 72px; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }
.btn-link { background: none; border: none; padding: 0; color: var(--primary); font: inherit; font-size: inherit; cursor: pointer; text-decoration: underline; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
.checkbox-label input[type="checkbox"] { width: auto; }
.conflict-warning {
  background: var(--amber-light);
  border: 1.5px solid #fcd34d;
  border-radius: var(--radius);
  padding: .6rem .85rem;
  font-size: .8rem;
  color: var(--amber);
  margin-bottom: .75rem;
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}

.draft-banner {
  background: var(--blue-light);
  border: 1.5px solid var(--blue);
  border-radius: var(--radius);
  padding: .5rem .85rem;
  font-size: .82rem;
  color: var(--blue-dark);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* ── Admin panel ───────────────────────────────────────────────────────────── */
.admin-tabs { display: flex; gap: .25rem; margin-bottom: 1.25rem; border-bottom: 2px solid var(--border); flex-wrap: wrap; }
.admin-tab {
  padding: .5rem 1rem;
  border: none;
  background: none;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}
.admin-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.admin-tab:hover { color: var(--text); }

/* ── Settings sub-tabs ─────────────────────────────────────────────────────── */
/* Admin > Modules: module list beside the chosen module's settings */
.mod-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.mod-list { display: flex; flex-direction: column; gap: 2px; background: var(--card-alpha, var(--card)); border: 1px solid var(--border); border-radius: 10px; padding: .4rem; position: sticky; top: 1rem; }
.mod-item { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left; background: none; border: none; border-radius: 7px; padding: .45rem .7rem; font: inherit; font-size: .88rem; color: var(--text); cursor: pointer; }
.mod-item--child { padding-left: 1.6rem; font-size: .84rem; }
.mod-section { display: flex; flex-direction: column; gap: 2px; }
.mod-section-label { font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); padding: .7rem .7rem .2rem; }
.data-table .mod-section-row th { background: var(--blue-light); color: var(--text); font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; padding: .5rem .85rem; border-bottom: 1px solid var(--border); }
.data-table tr.mod-section-row:hover th { background: var(--blue-light); }
.data-table td.mod-row-child { padding-left: 1.85rem; }
.mod-item:hover { background: var(--slate-light, rgba(0,0,0,.05)); }
.mod-item.active { background: var(--blue); color: #fff; }
.mod-item-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.mod-dot--on { background: var(--green); }
.mod-dot--setup { background: var(--amber); }
.mod-dot--off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-muted); }
.mod-item.active .mod-dot { box-shadow: 0 0 0 2px #fff; }
.mod-picker { display: none; }
.mod-picker select { width: 100%; }
.mod-main { min-width: 0; }
.mod-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.mod-title { margin: 0 0 .3rem; font-size: 1.2rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.mod-desc, .mod-meta, .mod-note { margin: 0; font-size: .85rem; line-height: 1.45; color: var(--text-muted); }
.mod-meta { margin-top: .15rem; font-size: .8rem; }
.mod-note { margin-top: .5rem; color: var(--text); font-weight: 500; }
.mod-head .btn { flex-shrink: 0; }
@media (max-width: 760px) {
  .mod-layout { grid-template-columns: 1fr; gap: 1rem; }
  .mod-list { display: none; }
  .mod-picker { display: block; }
}
.settings-subtabs { display: flex; gap: .35rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.settings-subtab {
  padding: .4rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--card-alpha);
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all .15s;
}
.settings-subtab.active { color: #fff; background: var(--blue); border-color: var(--blue); }
.settings-subtab:hover:not(.active) { color: var(--text); background: var(--slate-light); }

.section-header { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; margin-top: 1.5rem; }
.section-title { font-size: 1rem; font-weight: 700; flex: 1; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
}
.data-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: var(--card-alpha);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: .875rem;
}
.data-table th {
  background: var(--slate-light);
  padding: .6rem .85rem;
  text-align: left;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.data-table td { padding: .65rem .85rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--blue-light); }
/* Kept a table cell (display: flex on a td drops it out of the row: no
   border, no vertical centring); buttons are spaced with a margin instead. */
td.actions { white-space: nowrap; }
td.actions > * + * { margin-left: .35rem; }
.drag-handle { cursor: grab; color: var(--text-muted); font-size: 1rem; padding: 0 .3rem; user-select: none; }

.override-note { font-size: .68rem; font-weight: 600; color: var(--amber, #b45309); background: #fef3c7; border-radius: 3px; padding: 1px 4px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-col-header .override-note { font-size: .65rem; }
.data-table tr.row-muted td { color: var(--text-muted); opacity: .65; }
.log-entity-link { color: var(--blue); text-decoration: none; font-weight: 500; }
.log-entity-link:hover { text-decoration: underline; }

.month-cell.day-closed { opacity: 0.45; background: repeating-linear-gradient(135deg, transparent, transparent 4px, rgba(0,0,0,.04) 4px, rgba(0,0,0,.04) 8px); }
.month-cell.day-closed .day-chip { opacity: 0.7; }
.week-col.day-closed { opacity: 0.5; background: repeating-linear-gradient(135deg, transparent, transparent 4px, rgba(0,0,0,.03) 4px, rgba(0,0,0,.03) 8px); }

.day-toggles { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .25rem; }
.day-toggle { display: flex; align-items: center; gap: .3rem; padding: .3rem .6rem; border: 1.5px solid var(--border); border-radius: 6px; cursor: pointer; font-size: .85rem; user-select: none; }
.day-toggle input { accent-color: var(--primary); }
tr.dragging { opacity: 0.4; }
tr[data-field-id] { cursor: default; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 600; }
.badge-admin { background: var(--blue-light); color: var(--blue); }
.badge-user  { background: var(--slate-light); color: var(--slate); }
.badge-req   { background: var(--red-light); color: var(--red); }
.badge-opt   { background: var(--slate-light); color: var(--slate); }
.badge-cal    { background: #d1fae5; color: #065f46; }
.badge-system { background: #ede9fe; color: #5b21b6; }
.badge-invoiced { background: var(--green-light); color: var(--green); text-decoration: none; white-space: nowrap; }
a.badge-invoiced:hover { text-decoration: underline; }

/* Records already on an invoice (time entries, booking line items) */
.lock-note { border-left: 3px solid var(--green); background: color-mix(in srgb, var(--green) 10%, transparent); padding: .5rem .75rem; border-radius: 6px; margin: 0 0 .75rem; font-size: .88rem; }

/* Reports */
.rep-table th .rep-th-label { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: .72rem; color: var(--text-muted); }
.rep-table .num, .rep-lines .num, .data-table td.num, .data-table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rep-table tr.rep-current td { background: color-mix(in srgb, var(--blue) 8%, transparent); }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.rep-card { background: var(--card-alpha); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: 12px; padding: .75rem 1rem; }
.rep-card h3, .rep-sub { margin: 0 0 .5rem; font-size: .95rem; }
.rep-sub { margin-top: 1rem; }
.rep-lines { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rep-lines td { padding: .3rem 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.rep-lines tr:last-child td { border-bottom: none; }
@media print { .rep-card { backdrop-filter: none; background: #fff; } }

/* Timesheets: ticking time to invoice */
.ts-invoice-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem .75rem; flex-wrap: wrap; margin: .25rem 0 .5rem; }
.ts-invoice-bar .form-hint { margin: 0; }
.data-table .ts-pick { width: 2rem; text-align: center; }
.ts-pick input { width: 1.05rem; height: 1.05rem; margin: 0; vertical-align: middle; }

.chip-field  { opacity: .75; font-size: .75em; }

/* ── WYSIWYG email template editor ────────────────────────────────────────── */
.wysiwyg-toolbar {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-wrap: wrap;
  padding: .35rem .5rem;
  background: var(--slate-light);
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.wysiwyg-toolbar button[data-cmd] {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 4px;
  padding: .2rem .55rem;
  cursor: pointer;
  font-size: .82rem;
  min-width: 30px;
  line-height: 1.4;
  color: var(--text);
}
.wysiwyg-toolbar button[data-cmd]:hover { background: var(--slate-light); }
.wysiwyg-toolbar select { font-size: .8rem; padding: .2rem .3rem; border-radius: 4px; border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; }
.wysiwyg-editor {
  border: 1.5px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1rem 1.1rem;
  min-height: 180px;
  background: var(--card);
  color: var(--text);
  font-family: sans-serif;
  font-size: .9rem;
  line-height: 1.65;
  outline: none;
  overflow-y: auto;
}
.wysiwyg-editor:focus { border-color: var(--primary); }
.toolbar-sep { width: 1px; height: 18px; background: var(--border); margin: 0 .15rem; flex-shrink: 0; }

/* ── Multiselect field ─────────────────────────────────────────────────────── */
.multiselect-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .5rem .6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.multiselect-group .checkbox-label {
  font-size: .9rem;
  margin: 0;
}

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--card-alpha);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-md);
  border: 1.5px solid var(--border);
}
.login-brand { text-align: center; margin-bottom: 1.75rem; }
.login-logo { font-size: 2rem; margin-bottom: .4rem; }
.login-brand h1 { font-size: 1.4rem; font-weight: 700; }
.login-brand p { font-size: .85rem; color: var(--text-muted); margin-top: .2rem; }
.success-msg {
  background: var(--green-light, #dcfce7);
  color: var(--green, #15803d);
  border: 1.5px solid #86efac;
  border-radius: var(--radius);
  padding: .6rem .85rem;
  font-size: .85rem;
  margin-bottom: 1rem;
}
.login-code-links { display: flex; justify-content: space-between; gap: 1rem; margin-top: .9rem; font-size: .85rem; }
.login-code-links .btn-link:only-child { margin-left: auto; }
/* Security window: two-step sign-in */
.sec-section + .sec-section { border-top: 1px solid var(--border); margin-top: 1.25rem; padding-top: 1.1rem; }
.sec-section h4 { margin: 0 0 .5rem; }
.sec-qr { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin: .75rem 0; }
.sec-qr svg { width: 172px; height: 172px; border-radius: 6px; flex: none; }
.sec-secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; word-break: break-all; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .4rem .55rem; display: inline-block; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem 1rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .7rem .9rem; margin: .6rem 0; }
.sec-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.sec-actions input { max-width: 14rem; }
.error-msg {
  background: var(--red-light);
  color: var(--red);
  border: 1.5px solid #fca5a5;
  border-radius: var(--radius);
  padding: .6rem .85rem;
  font-size: .85rem;
  margin-bottom: 1rem;
}

/* ── Toast ─────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 5rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  z-index: 500;
  pointer-events: none;
}
.toast {
  padding: .6rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: fadeIn .2s ease;
  pointer-events: all;
  max-width: 280px;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast-success { background: #166534; color: #fff; }
.toast-error   { background: var(--red); color: #fff; }

/* ── Change password view ──────────────────────────────────────────────────── */
.change-pw-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.change-pw-card {
  background: var(--card-alpha);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-md);
  border: 1.5px solid var(--border);
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
/* Laptop widths: a little tighter so every module's menu item fits on one row */
@media (min-width: 701px) and (max-width: 1440px) {
  .topnav { gap: .5rem; }
  .view-tabs { gap: .2rem; }
  .view-tab { padding: .32rem .55rem; font-size: .82rem; }
}
@media (min-width: 701px) and (max-width: 1300px) {
  .topnav-user { display: none; }
  .topnav-brand { font-size: 1rem; }
}
@media (max-width: 700px) {
  /* Nav: CSS Grid - brand+actions on row 1, tabs on row 2.
     Grid is more reliable than flex-wrap ordering for preventing overflow. */
  .topnav {
    display: grid;
    grid-template-areas: "brand actions" "tabs tabs";
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    padding: .45rem .75rem .3rem;
    gap: .2rem .4rem;
    min-height: auto;
    width: 100%;
    box-sizing: border-box;
  }
  .topnav-brand {
    grid-area: brand;
    font-size: .95rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topnav-spacer { display: none; }
  .topnav-user   { display: none; }
  .topnav-actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    gap: .25rem;
  }
  .view-tabs {
    grid-area: tabs;
    display: flex;
    flex-wrap: wrap;
    padding-bottom: .2rem;
  }
  /* Wraps onto a second row when there are more sections than fit */
  .view-tabs .view-tab { flex: 1 0 auto; text-align: center; padding: .32rem .45rem; font-size: .8rem; }

  /* Icon-only action buttons */
  #nav-logout, #nav-admin, #nav-cpw {
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    flex-shrink: 0;
  }
  #nav-logout::after { content: '↩'; font-size: .95rem; }
  #nav-admin::after  { content: '⚙'; font-size: .95rem; }
  #nav-cpw::after    { content: '🔒'; font-size: .85rem; }

  /* Calendar */
  .week-grid { grid-template-columns: 1fr; }
  .week-col { display: flex; gap: .5rem; }
  .week-col-header { min-width: 70px; border-bottom: none; border-right: 1.5px solid var(--border); }
  .week-bookings { flex-direction: row; flex-wrap: wrap; }
  .month-cell { min-height: 60px; }
  .day-chip { display: none; }
  .day-num-with-dot::after {
    content: '•';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--blue);
    font-size: .9rem;
  }

  /* Forms */
  .form-row { grid-template-columns: 1fr; }

  /* Modal - explicit width cap + x-scroll prevention */
  .modal {
    max-height: 96vh;
    max-height: 96dvh;
    max-width: 100vw;
    border-radius: 12px 12px 0 0;
  }
  .modal-body  { padding: .85rem 1rem; overflow-x: hidden; }
  .modal-footer { padding: .6rem 1rem; }

  /* Admin */
  .data-table { font-size: .8rem; }
  .data-table th, .data-table td { padding: .45rem .55rem; }
  .page { padding: .85rem .75rem; }
}

@media (max-width: 480px) {
  .topnav-brand .topnav-name { display: none; }
  .month-dow { font-size: .65rem; padding: .35rem .1rem; }
  .month-cell { padding: .25rem .15rem; }
  .day-num { font-size: .75rem; width: 22px; height: 22px; }
  .cal-header { gap: .35rem; }
  .cal-title { font-size: 1rem; min-width: 0; }

  /* Follow-up dropdown: larger touch targets on phones */
  .followup-item { padding: .85rem 1rem; }
  .followup-item-actions { gap: .5rem; margin-top: .25rem; }
  .followup-item-actions .btn { min-height: 36px; padding: .4rem .75rem; }
  .followup-dropdown-header { padding: .75rem 1rem; font-size: .85rem; }
}

/* Prevent any single form element from escaping its container */
input, select, textarea { max-width: 100%; }

/* ── Dark mode ─────────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:         #0f172a;
  --card:       #1e293b;
  --card-alpha: rgba(30,41,59,.82);
  --text:       #e2e8f0;
  --text-muted: #94a3b8;
  --border:     #334155;
  --slate-light:#263248;
  --blue-light: #1e3a5f;
  --green-light:#0a2e18;
  --amber-light:#1c0f02;
  --red-light:  #1c0505;
  --shadow:     0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md:  0 4px 6px rgba(0,0,0,.4), 0 2px 4px rgba(0,0,0,.25);
  --bg-scrim:   rgba(15,23,42,.72);
}

/* Status chips -- need explicit bg+text since light-variant vars are now very dark */
[data-theme="dark"] .day-chip                  { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .day-chip.status-confirmed { background: #0a2e18; color: #86efac; }
[data-theme="dark"] .day-chip.status-completed { background: #263248; color: #94a3b8; }
[data-theme="dark"] .day-chip.status-cancelled { background: #2d0909; color: #fca5a5; }
[data-theme="dark"] .day-chip.status-pending   { background: #1c0f02; color: #fcd34d; }

[data-theme="dark"] .week-chip                  { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .week-chip.status-confirmed { background: #0a2e18; color: #86efac; }
[data-theme="dark"] .week-chip.status-completed { background: #263248; color: #94a3b8; }
[data-theme="dark"] .week-chip.status-cancelled { background: #2d0909; color: #fca5a5; }
[data-theme="dark"] .week-chip.status-pending   { background: #1c0f02; color: #fcd34d; }

[data-theme="dark"] .status-pending   { background: #1c0f02; color: #fcd34d; }
[data-theme="dark"] .status-confirmed { background: #0a2e18; color: #86efac; }
[data-theme="dark"] .status-completed { background: #263248; color: #94a3b8; }
[data-theme="dark"] .status-cancelled { background: #2d0909; color: #fca5a5; }

[data-theme="dark"] .booking-time-tag { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .conflict-badge   { background: #1c0f02; color: #fcd34d; }

/* Badges */
[data-theme="dark"] .badge-admin  { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .badge-user   { background: #263248; color: #94a3b8; }
[data-theme="dark"] .badge-req    { background: #2d0909; color: #fca5a5; }
[data-theme="dark"] .badge-opt    { background: #263248; color: #94a3b8; }
[data-theme="dark"] .badge-cal    { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-system { background: #2e1065; color: #c4b5fd; }

/* Hardcoded border/bg overrides */
[data-theme="dark"] .override-note      { background: #1c0f02; color: #fcd34d; }
[data-theme="dark"] .day-closed-notice  { border-color: #92400e; }
[data-theme="dark"] .conflict-warning   { border-color: #92400e; }
[data-theme="dark"] .error-msg          { border-color: #7f1d1d; }
[data-theme="dark"] .followup-dropdown  { box-shadow: 0 8px 24px rgba(0,0,0,.4); }
[data-theme="dark"] .followup-dropdown-header { background: var(--slate-light); }
[data-theme="dark"] .modal-overlay      { background: rgba(0,0,0,.7); }
[data-theme="dark"] .btn-danger:hover   { background: #7f1d1d; }

/* Calendar cell overrides */
[data-theme="dark"] .month-cell.other-month .day-num { color: #334155; }
[data-theme="dark"] .month-cell:hover,
[data-theme="dark"] .month-cell.selected { background: #1a2d45; }
[data-theme="dark"] .month-cell.day-closed {
  background: repeating-linear-gradient(135deg, transparent, transparent 4px, rgba(255,255,255,.02) 4px, rgba(255,255,255,.02) 8px);
}
[data-theme="dark"] .week-col.day-closed {
  background: repeating-linear-gradient(135deg, transparent, transparent 4px, rgba(255,255,255,.02) 4px, rgba(255,255,255,.02) 8px);
}
[data-theme="dark"] .time-slot--empty .time-slot-bookings {
  background: repeating-linear-gradient(135deg, transparent, transparent 6px, rgba(255,255,255,.02) 6px, rgba(255,255,255,.02) 12px);
}

/* Misc */
[data-theme="dark"] .data-table tr:hover td { background: #1a2d45; }

/* Legend swatches: use lighter pastels so small boxes are visible on dark bg */
[data-theme="dark"] .cal-legend-swatch.status-pending   { background: #fcd34d; }
[data-theme="dark"] .cal-legend-swatch.status-confirmed { background: #86efac; }
[data-theme="dark"] .cal-legend-swatch.status-cancelled { background: #fca5a5; }
[data-theme="dark"] .cal-legend-swatch.status-completed { background: #cbd5e1; }

/* ── Segmented control (calendar view switch, period filters) ─────────────── */
.seg { display: inline-flex; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--card); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-btn { flex-shrink: 0; white-space: nowrap; }
.seg-btn { padding: .35rem .8rem; border: 0; background: transparent; color: var(--text-muted); font-size: .85rem; font-weight: 500; }
.seg-btn + .seg-btn { border-left: 1.5px solid var(--border); }
.seg-btn:hover { background: var(--blue-light); color: var(--text); }
.seg-btn.active { background: var(--blue); color: #fff; }
.cal-header .seg, .day-view-header .seg { margin-left: auto; }

/* ── Home dashboard ────────────────────────────────────────────────────────── */
.home-head { margin: 1.25rem 0 1rem; }
.home-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.home-date { margin: .2rem 0 0; color: var(--text-muted); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.home-card {
  display: flex; flex-direction: column; gap: .6rem;
  padding: 1.1rem 1.15rem;
  background: var(--card-alpha);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .15s, transform .15s, border-color .15s;
}
.home-card:hover, .home-card:focus-visible { box-shadow: var(--shadow-md); border-color: var(--blue); transform: translateY(-1px); outline: none; }
.home-card-head { display: flex; align-items: center; gap: .55rem; }
.home-card-icon { font-size: 1.4rem; line-height: 1; }
.home-card-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.home-card-desc { margin: 0; font-size: .85rem; color: var(--text-muted); }
.home-card-stats { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-top: auto; padding-top: .25rem; }
.home-stat { display: flex; flex-direction: column; min-width: 60px; }
.home-stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.home-stat-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.home-stat--warn .home-stat-value { color: var(--amber); }
.home-stat--good .home-stat-value { color: var(--green); }
.home-card-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.home-card-timer { display: flex; align-items: center; gap: .45rem; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--green); }

/* ── Timesheets ────────────────────────────────────────────────────────────── */
.timer-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex-shrink: 0; animation: timer-pulse 1.4s ease-in-out infinite; }
@keyframes timer-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .timer-dot { animation: none; } }
.ts-timer {
  display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap;
  padding: 1rem 1.1rem; margin-bottom: 1rem;
  background: var(--card-alpha);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.ts-timer--running { align-items: center; border-color: var(--green); }
.ts-timer input, .ts-timer select, .ts-filters select {
  padding: .45rem .6rem; border: 1.5px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); min-width: 0;
}
.ts-field { display: flex; flex-direction: column; gap: .3rem; min-width: 200px; }
.ts-field label { font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.ts-field--grow, .ts-timer--running input { flex: 1; min-width: 180px; }
.ts-timer-clock { display: flex; align-items: center; gap: .5rem; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ts-timer-info { display: flex; flex-direction: column; }
/* Running timer: a bar along the bottom of every page */
.timer-bar {
  position: fixed; left: 50%; bottom: .75rem; transform: translateX(-50%); z-index: 900;
  width: min(960px, calc(100% - 1.5rem)); box-sizing: border-box;
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .75rem; border-radius: 12px;
  background: var(--card); border: 1.5px solid var(--green); box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.timer-bar-clock { display: flex; align-items: center; gap: .45rem; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timer-bar-who { display: flex; flex-direction: column; min-width: 0; max-width: 14rem; line-height: 1.2; }
.timer-bar-who strong, .timer-bar-who .form-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0; }
.timer-bar input { flex: 1; min-width: 0; padding: .4rem .6rem; border: 1.5px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); }
.timer-bar-saved { margin: 0; min-width: 2.6rem; }
body.has-timer-bar { padding-bottom: 5rem; }
body.has-timer-bar .btn-fab { bottom: 5.5rem; }
.ts-running-note { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 1rem; padding: .6rem .85rem; border-radius: 10px; background: color-mix(in srgb, var(--green) 10%, transparent); border-left: 3px solid var(--green); font-size: .9rem; }
@media (max-width: 700px) {
  .timer-bar { flex-wrap: wrap; gap: .4rem .6rem; bottom: .5rem; width: calc(100% - 1rem); }
  .timer-bar input { flex-basis: 100%; order: 3; }
  .timer-bar-who { flex: 1; max-width: none; }
  .timer-bar-saved { display: none; }
  body.has-timer-bar { padding-bottom: 8rem; }
  body.has-timer-bar .btn-fab { bottom: 8.5rem; }
}
@media print { .timer-bar { display: none !important; } }

.ts-filters { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.ts-total { margin-left: auto; }
.ts-form-times { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

@media (max-width: 700px) {
  .home-title { font-size: 1.25rem; }
  .cal-header .seg, .day-view-header .seg { margin-left: 0; }
  .ts-timer { flex-direction: column; align-items: stretch; }
  .ts-field { min-width: 0; }
  .ts-total { margin-left: 0; }
  .ts-form-times { grid-template-columns: 1fr; }
  .seg { max-width: 100%; overflow-x: auto; }
  .seg-btn { padding: .35rem .6rem; white-space: nowrap; }
}
.ts-filters select { width: auto; max-width: 100%; }

/* ── Timesheet report ──────────────────────────────────────────────────────── */
.ts-report-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.ts-report-head > span:first-child { color: var(--text-muted); }
.ts-report-head .btn { margin-left: auto; }
.ts-report-customer { margin-bottom: 1.25rem; }
.ts-report-title { font-size: 1rem; font-weight: 700; margin: 0 0 .4rem; }
.ts-report-table { min-width: 420px; }
.ts-report-table tfoot td { border-top: 2px solid var(--border); }

@media print {
  .topnav, .health-bar, .app-footer, .btn-fab, .ts-timer, .ts-filters, .section-header .btn,
  #ts-print, .form-hint, #toast-container { display: none !important; }
  body { background: #fff !important; }
  .data-table { background: #fff !important; backdrop-filter: none !important; }
}

/* ── Admin > API reference (rendered from /api/v1/openapi.json) ─────────────── */
.checkbox-label { display: flex; align-items: center; gap: .5rem; margin: .25rem 0; font-size: .9rem; }
.api-scope-list { padding-left: 1.5rem; }
.api-tag { margin-top: 1rem; }
.api-tag .section-header { flex-wrap: wrap; gap: .5rem; }
.api-base { font-size: .8rem; color: var(--text-muted); overflow-wrap: anywhere; }
.api-op { border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius); margin: .5rem 0; background: var(--card-alpha); }
.api-op > summary { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; cursor: pointer; list-style: none; flex-wrap: wrap; }
.api-op > summary::-webkit-details-marker { display: none; }
.api-op[open] > summary { border-bottom: 1px solid var(--border); }
.api-method { font: 700 .72rem/1 monospace; padding: .3rem .45rem; border-radius: 4px; color: #fff; min-width: 3.6rem; text-align: center; }
.api-op-get    { border-left-color: var(--blue); }   .api-op-get    .api-method { background: var(--blue); }
.api-op-post   { border-left-color: var(--green); }  .api-op-post   .api-method { background: var(--green); }
.api-op-put    { border-left-color: var(--amber); }  .api-op-put    .api-method { background: var(--amber); }
.api-op-delete { border-left-color: var(--red); }    .api-op-delete .api-method { background: var(--red); }
.api-path { font-size: .88rem; font-weight: 600; overflow-wrap: anywhere; }
.api-summary { color: var(--text-muted); font-size: .85rem; }
.api-op-body { padding: .5rem .9rem .9rem; min-width: 0; }
.api-op-body h4 { margin: 1rem 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.api-desc { margin: .25rem 0; font-size: .9rem; }
.api-props { font-size: .82rem; }
.api-props td { vertical-align: top; }
.api-type { font-family: monospace; font-size: .78rem; color: var(--text-muted); }
.api-req { font-size: .7rem; color: var(--red); }
.api-code { background: var(--slate-light); color: var(--text); padding: .6rem .8rem; border-radius: var(--radius); font-size: .78rem; overflow-x: auto; margin: .4rem 0; max-height: 22rem; }
.api-response { margin: .4rem 0 .6rem; font-size: .85rem; }
.api-status { font: 700 .75rem/1 monospace; padding: .2rem .4rem; border-radius: 4px; background: var(--slate-light); }
.api-status-2 { background: var(--green-light); color: var(--green); }
.api-status-4, .api-status-5 { background: var(--red-light); color: var(--red); }
.api-try { display: grid; gap: .5rem; }
.api-try-field { display: grid; gap: .2rem; font-size: .82rem; max-width: 26rem; }
.api-try-field em { color: var(--text-muted); font-style: normal; font-size: .75rem; }
.api-try-key { margin: .5rem 0 1rem; }
.api-try-body { font-family: monospace; font-size: .8rem; width: 100%; }
.api-try-warn { margin-left: .5rem; color: var(--amber); }
.api-try-result { min-width: 0; }

/* ── Assets ──────────────────────────────────────────────────────────────── */
.asset-table { min-width: 560px; }
.asset-row { cursor: pointer; }
.asset-row:focus-visible td { background: var(--blue-light); outline: none; }
.asset-thumb-col { width: 56px; padding-right: 0 !important; }
.asset-thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; display: block; background: var(--blue-light); }
.asset-thumb--empty { display: flex; align-items: center; justify-content: center; font-size: 1.2rem; opacity: .55; }
.asset-thumb--lg { width: 96px; height: 96px; }
.asset-photo-link { display: block; margin-bottom: .75rem; }
.asset-photo { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin: 0 auto; object-fit: contain; }
.asset-photo-edit { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.asset-photo-edit > div { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; min-width: 0; }
.asset-photo-edit input[type=file] { max-width: 100%; }
.asset-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.asset-dl { margin: 0 0 .5rem; }
.asset-dl-row { display: grid; grid-template-columns: 9.5rem 1fr; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.asset-dl-row dt { color: var(--text-muted); font-weight: 600; }
.asset-dl-row dd { margin: 0; overflow-wrap: anywhere; }
.asset-subhead { margin: 1rem 0 .4rem; font-size: .95rem; }
.asset-history { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.asset-history li { padding: .3rem 0; border-bottom: 1px solid var(--border); }
.asset-history .form-hint { display: block; margin: 0; }
.asset-gain { color: var(--green); }
.asset-loss { color: var(--red); }
.asset-range { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text-muted); }
.asset-range input { width: auto; }
.asset-note { margin: 0 0 .75rem; }
#asset-search { width: 220px; max-width: 100%; }
.api-try-image { display: block; max-width: 240px; margin-top: .5rem; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (max-width: 560px) {
  .asset-form-grid { grid-template-columns: 1fr; }
  .asset-dl-row { grid-template-columns: 1fr; gap: 0; }
  #asset-search { width: 100%; }
  .asset-table { min-width: 0; }
  .asset-col-date { display: none; }
}
@media print {
  #ad-print, .asset-range, .seg { display: none !important; }
}

/* ── Invoices ────────────────────────────────────────────────────────────── */
.modal.modal--wide { max-width: 860px; }
.inv-table { min-width: 640px; }
#inv-search { width: 240px; max-width: 100%; }
.inv-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.inv-title { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.inv-billto { font-size: .9rem; text-align: right; }
.inv-totals { margin: .75rem 0 .75rem auto; border-collapse: collapse; min-width: 240px; font-size: .9rem; }
.inv-totals td { padding: .2rem .5rem; text-align: right; }
.inv-totals td:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.inv-totals-strong td { font-weight: 700; border-top: 1px solid var(--border); }
.inv-notes { font-size: .9rem; margin: .5rem 0; }
.inv-payment { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.inv-lines-head, .inv-line { display: grid; grid-template-columns: 1fr 80px 110px 100px 36px; gap: .5rem; align-items: start; }
.inv-lines-head { margin-top: .75rem; font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .3rem; }
.inv-lines-head span:nth-child(n+2):nth-child(-n+4) { text-align: right; }
.inv-line { margin-bottom: .5rem; }
.inv-line textarea { min-height: 38px; resize: none; overflow: hidden; }
.inv-line input { text-align: right; }
.inv-line-amount { padding-top: .55rem; text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }
.inv-line .btn { margin-top: .2rem; }
/* A line's stock item (invoices, quotes, booking line items) */
.stock-link { grid-column: 1 / -1; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .82rem; margin-top: -.2rem; }
.stock-link:empty { display: none; }
.stock-link select { max-width: 100%; font-size: .85rem; padding: .3rem .4rem; }
td .stock-link { margin-top: .25rem; }
.stock-chip { background: var(--blue-light); color: var(--blue); border-radius: 99px; padding: 1px 9px; font-weight: 600; }
.stock-chip--short { background: var(--red-light); color: var(--red); }

/* Expenses editor: one card per line (description, category, quantity, amount, GST, asset) */
.exp-line { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem .25rem; margin-bottom: .6rem; background: var(--card-alpha, var(--card)); }
.exp-line-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) 70px 120px 120px 36px; gap: .5rem; align-items: end; }
.exp-line-grid .form-group { margin-bottom: .5rem; }
.exp-line-remove { margin-bottom: .55rem; }
.exp-asset { margin-bottom: .5rem; display: grid; gap: .4rem; }
.exp-asset select, .exp-asset input { max-width: 100%; }
.exp-asset-results { display: grid; gap: .25rem; margin-top: .3rem; max-height: 200px; overflow-y: auto; }
.exp-asset-pick { text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: .35rem .5rem; cursor: pointer; display: flex; flex-direction: column; font: inherit; }
.exp-asset-pick:hover, .exp-asset-pick:focus { border-color: var(--blue); }
.exp-asset-pick .form-hint { margin: 0; }
@media (max-width: 760px) {
  .exp-line-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .exp-line-desc, .exp-line-grid .form-group:nth-child(2) { grid-column: 1 / -1; }
  .exp-line-remove { justify-self: end; }
  .exp-col-what, .exp-col-gst { display: none; }
}
/* Rich text notes: editor and display (the same small set the PDF prints) */
.rich { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.rich-bar { display: flex; flex-wrap: wrap; gap: .2rem; padding: .3rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.rich-btn { border: 1px solid transparent; background: none; color: var(--text); border-radius: 6px; padding: .25rem .55rem; font-size: .85rem; cursor: pointer; min-width: 32px; }
.rich-btn:hover { background: var(--card); border-color: var(--border); }
.rich-btn.active { background: var(--blue-light); border-color: var(--blue); }
.rich-sep { width: 1px; background: var(--border); margin: .15rem .2rem; }
.rich-link { display: flex; gap: .4rem; padding: .4rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rich-link input { flex: 1; min-width: 180px; }
.rich-area { min-height: 110px; max-height: 360px; overflow-y: auto; padding: .6rem .75rem; outline: none; font-size: .92rem; line-height: 1.45; }
.rich-area:focus { box-shadow: inset 0 0 0 2px var(--blue-light); }
.rich-area:empty::before { content: 'Terms, scope, what is included...'; color: var(--text-muted); }
.rich-area p, .rich-view p { margin: 0 0 .5rem; }
.rich-area h3, .rich-view h3 { font-size: 1.02rem; margin: .6rem 0 .35rem; }
.rich-area ul, .rich-area ol, .rich-view ul, .rich-view ol { margin: 0 0 .5rem; padding-left: 1.4rem; }
.rich-area a, .rich-view a { color: var(--blue); }
.rich-view > :last-child { margin-bottom: 0; }
.rich-link.hidden, .inv-internal .btn.hidden { display: none; }
.modal--wide .modal-footer { flex-wrap: wrap; }
.modal--wide .modal-footer .btn { white-space: nowrap; }
.inv-internal { margin: .75rem 0; padding: .6rem .75rem; border: 1px dashed var(--border); border-radius: var(--radius); }
.inv-internal label { font-size: .85rem; font-weight: 600; display: block; margin-bottom: .3rem; }
.inv-internal textarea { width: 100%; }
.inv-internal .btn { margin-top: .4rem; }
.inv-settings-card { padding: 1rem; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-alpha); }
.settings-subhead { margin: 0 0 .35rem; font-size: 1rem; font-weight: 600; }
.enh-choose { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: -.5rem 0 1rem; }
.enh-list { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-alpha); }
.enh-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding: .6rem .85rem; border-bottom: 1px solid var(--border); }
.enh-row:last-child { border-bottom: 0; }
.enh-row-main { min-width: 0; overflow-wrap: anywhere; }
.enh-row-side { display: flex; gap: .4rem; }
.enh-row-side select { width: auto; max-width: 100%; }
@media (max-width: 640px) {
  .inv-lines-head { display: none; }
  .inv-line { grid-template-columns: 1fr 1fr 36px; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
  .inv-line textarea { grid-column: 1 / -1; }
  .inv-line-amount { grid-column: 1 / 3; padding-top: 0; }
  .inv-line .btn { grid-row: 2; grid-column: 3; }
  .inv-billto { text-align: left; }
  #inv-search { width: 100%; }
  .inv-col-date { display: none; }
  .inv-table { min-width: 0; }
}

/* ── Recurring billing ───────────────────────────────────────────────────── */
.copy-box { display: flex; gap: .4rem; align-items: center; }
.copy-box input { flex: 1; min-width: 0; font-size: .8rem; }
.bill-runbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.bill-runbar .form-hint { flex: 1; min-width: 220px; }
.wh-notes { margin-bottom: .75rem; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-alpha); font-size: .85rem; }
.wh-notes > div + div, .bill-problems > div + div { margin-top: .35rem; }
.bill-problems { margin-bottom: .75rem; padding: .6rem .8rem; border: 1px solid var(--red); border-radius: var(--radius); background: var(--red-light); color: var(--red); font-size: .85rem; }
.pay-options { display: grid; gap: .6rem; }
.pay-option { padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); }
.pay-option .copy-box { margin-top: .4rem; }
.pay-method-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.pay-method-row:first-of-type { border-top: 0; }
.whmcs-bar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; margin: .4rem 0 .6rem; }
.whmcs-bar span { display: block; height: 100%; background: var(--blue); transition: width .3s; }
.whmcs-counts { margin: .25rem 0 .5rem 1.1rem; padding: 0; font-size: .9rem; }
.whmcs-ok { margin: .75rem 0 0; padding: .6rem .8rem; border: 1px solid var(--green); border-radius: var(--radius); background: var(--green-light); font-size: .88rem; }
.setup-notice { margin: 0 0 1rem; padding: .75rem 1rem; border: 1px solid var(--blue); border-radius: var(--radius); background: var(--card-alpha); display: flex; flex-wrap: wrap; gap: .25rem .5rem; align-items: baseline; }

/* Services (products module) */
.svc-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.svc-renew { display: inline-flex; gap: .3rem; align-items: center; }
.svc-renew select { width: auto; }
.svc-expiring { font-weight: 600; }
.whmcs-steps { margin: .5rem 0 .5rem 1.2rem; padding: 0; font-size: .88rem; }
.whmcs-steps li { margin-bottom: .6rem; }
.whmcs-perms { margin: .5rem 0; font-size: .85rem; }

/* WHMCS import: what the API credential can read; transactions totals */
.whmcs-readonly { border-left: 3px solid var(--warning, #d97706); background: color-mix(in srgb, var(--warning, #d97706) 10%, transparent); padding: .6rem .8rem; border-radius: 6px; margin-bottom: .75rem; font-size: .9rem; }
.whmcs-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; }
.whmcs-totals div { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; background: var(--card-alpha, var(--card)); }
.whmcs-totals span { display: block; font-size: .8rem; color: var(--text-muted); }
.whmcs-totals strong { font-size: 1.1rem; }
.inv-refund strong { color: var(--error); }
.pf-pricing summary { cursor: pointer; font-weight: 600; margin: .5rem 0; }
.pf-pricing input { width: 6.5rem; }

/* Fold-out help sections on setup pages */
.help-box { border: 1px solid var(--border); border-radius: 8px; margin: .5rem 0; background: var(--card-alpha, var(--card)); }
.help-box > summary { cursor: pointer; padding: .5rem .75rem; font-weight: 600; color: var(--blue); list-style: none; }
.help-box > summary::-webkit-details-marker { display: none; }
.help-box > summary::before { content: '\25B8'; display: inline-block; margin-right: .4rem; transition: transform .15s; }
.help-box[open] > summary::before { transform: rotate(90deg); }
.help-box[open] > summary { border-bottom: 1px solid var(--border); }
.help-box-body { padding: .5rem .75rem .75rem; font-size: .9rem; }
.help-box-body p:first-child { margin-top: 0; }

/* On/off switches for things that run or send by themselves */
.pause-card { border-left: 4px solid var(--success, #16a34a); }
.pause-card.is-paused { border-left-color: var(--warning, #d97706); }
.pause-row { display: flex; gap: .75rem 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pause-row > div { flex: 1 1 240px; }
.pause-notice { border-color: var(--warning, #d97706); align-items: center; }

/* Payment reminder schedule rows (Admin > Modules > Invoicing > Payment reminders) */
.rem-step { display: grid; grid-template-columns: 5rem minmax(9rem, 12rem) auto auto; gap: .4rem .6rem; align-items: center; padding: .5rem 0; border-top: 1px solid var(--border); }
.rem-step:first-child { border-top: 0; }
.rem-step .rem-days, .rem-step .rem-when { width: 100%; }
.rem-step .rem-warn { margin: 0; white-space: nowrap; }
.rem-step .rem-remove { justify-self: end; }
.rem-step .rem-message { grid-column: 1 / -1; width: 100%; font-size: .88rem; min-height: 2.4rem; height: 2.4rem; resize: vertical; }
@media (max-width: 560px) {
  .rem-step { grid-template-columns: 4.5rem 1fr; }
  .rem-step .rem-warn { grid-column: 1; }
  .rem-step .rem-remove { grid-column: 2; }
}

/* Assets CSV import */
.asset-head-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.ai-modes { border: 0; padding: 0; margin: 0 0 1rem; }
.ai-modes legend { font-weight: 600; margin-bottom: .4rem; }
.ai-mode { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .5rem; font-weight: normal; }
.ai-mode input { margin-top: .25rem; }
.ai-summary { margin: .5rem 0; font-weight: 500; }
.ai-row-error td { background: var(--red-light); }
.ai-remove { margin-top: .75rem; }
.data-table.ai-table { min-width: 0; }
.ai-table td { white-space: normal; overflow-wrap: break-word; }
.ai-table td:first-child { width: 3.5rem; }

/* Store (Services > Orders, Admin > Modules > Store) */
.store-note { background: var(--blue-light); border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.store-note ul { margin: 6px 0 0; padding-left: 18px; }
.store-group { margin-bottom: 12px; }
.store-group-head { font-weight: 600; }
.store-group-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; }
.store-group-row .checkbox-label { margin: 0; }
.store-retired { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.store-retired summary { cursor: pointer; font-weight: 600; }
.store-products { display: grid; gap: 4px; padding-left: 24px; }
.store-product { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; justify-content: space-between; }
.store-product-link { flex-basis: 100%; padding-left: 26px; font-size: .8rem; overflow-wrap: anywhere; }
.store-product .checkbox-label { flex: 1; min-width: 0; margin: 0; }

/* Customer window: action toolbar and linked records */
.cust-tools { display: flex; flex-wrap: wrap; gap: .4rem; margin: -.15rem 0 1rem; padding-bottom: .85rem; border-bottom: 1px solid var(--border); }
.cust-tools .btn { white-space: nowrap; }
.cust-links ul { list-style: none; margin: .25rem 0 0; padding: 0; font-size: .9rem; }
.cust-link { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.cust-link:last-child { border-bottom: none; }
.cust-link-main { min-width: 0; overflow-wrap: anywhere; }
.cust-link-meta { color: var(--text-muted); font-size: .82rem; white-space: nowrap; }
.cust-link .badge { flex-shrink: 0; }
.cust-links details { margin-top: .35rem; }
.cust-links summary { cursor: pointer; color: var(--blue); font-size: .85rem; }

/* Customers: search with the Active / Inactive / All choice beside it */
.cust-filter { display: flex; gap: .5rem; max-width: 560px; margin-bottom: 1rem; }
.cust-filter input { flex: 1; min-width: 0; }
.cust-filter select { flex: 0 0 auto; width: auto; }
.cust-inactive { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: .6rem .8rem; margin-bottom: 1rem; border-radius: 8px; background: var(--slate-light); color: var(--slate); font-size: .88rem; }
.cust-check { display: flex; gap: .4rem; align-items: center; margin: .25rem 0 .5rem; font-size: .9rem; }

/* Role editor (Admin > Users > Roles) */
.perm-head { margin: 1rem 0 .4rem; font-size: .9rem; }
.perm-grid { display: flex; flex-direction: column; border: 1.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.perm-row { display: flex; align-items: center; gap: .75rem; padding: .5rem .75rem; border-top: 1px solid var(--border); }
.perm-row:first-child { border-top: 0; }
.perm-row--child .perm-name { padding-left: 1.1rem; }
.perm-name { flex: 1; min-width: 0; }
.perm-name label { font-weight: 600; font-size: .88rem; }
.perm-name .form-hint { margin: .15rem 0 0; }
.perm-row select { width: 8rem; flex: none; }
.role-summary { font-size: .82rem; color: var(--text-muted); }
@media (max-width: 600px) {
  .perm-row { flex-wrap: wrap; }
  .perm-row select { width: 100%; }
}

/* Product form: order fields */
.ofield { border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-bottom: 8px; display: grid; gap: 6px; }
.ofield-main { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; align-items: center; }
.ofield-req { margin: 0; white-space: nowrap; }
@media (max-width: 560px) { .ofield-main { grid-template-columns: minmax(0, 1fr) auto; } .ofield-main > input[data-of="label"] { grid-column: 1 / -1; } }
.addon-for { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; margin: 4px 0 8px; }
.addon-for-group .checkbox-label { display: flex; margin: 4px 0; }

/* Admin > Jobs: one card per scheduled job */
.job-list { display: grid; gap: .75rem; }
.job-card { background: var(--card-alpha); border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem; }
.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; }
.job-owner { font-size: .78rem; color: var(--text-muted); margin-left: .35rem; }
.job-desc { font-size: .85rem; color: var(--text-muted); margin: .35rem 0 .6rem; }
.job-facts { font-size: .86rem; display: grid; gap: .25rem; overflow-wrap: anywhere; }
.job-k { display: inline-block; min-width: 6.5rem; color: var(--text-muted); font-size: .8rem; }
.job-note { color: var(--text-muted); font-style: italic; }
.job-bad { color: var(--red); }
.job-actions { display: flex; gap: .5rem; margin-top: .7rem; flex-wrap: wrap; }
.job-history { margin-top: .75rem; }
.job-list { grid-template-columns: minmax(0, 1fr); }
.job-card { min-width: 0; }

/* Admin > About */
.about-facts { display: grid; gap: .3rem; font-size: .9rem; }
.changelog { max-width: 52rem; font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.changelog .cl-version { margin: 1.5rem 0 .4rem; padding-bottom: .3rem; border-bottom: 1px solid var(--border); font-size: 1.05rem; }
.changelog .cl-version:first-child { margin-top: .25rem; }
.changelog .cl-section { margin: .9rem 0 .3rem; font-size: .92rem; color: var(--text-muted); }
.changelog ul { margin: 0 0 .5rem 1.2rem; padding: 0; }
.changelog li { margin: .2rem 0; }
.changelog p { margin: .4rem 0; }
.changelog code { font-size: .85em; background: var(--card); border: 1px solid var(--border); border-radius: 4px; padding: 0 .25em; }
.job-hour { display: inline-flex; align-items: center; gap: .4rem; margin-left: auto; font-size: .82rem; color: var(--text-muted); }
.job-hour select { width: auto; padding: .25rem .5rem; }

/* Support tickets */
.sup-count { font-weight: 700; margin-left: .15rem; }
.sup-table tr.clickable { cursor: pointer; }
.sup-table tr.clickable:hover td { background: var(--blue-light); }
.sup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.sup-fields { display: flex; flex-wrap: wrap; gap: .5rem .9rem; margin-bottom: .75rem; font-size: .85rem; color: var(--text-muted); }
.sup-fields label { display: flex; flex-direction: column; gap: .2rem; }
.sup-fields select { width: auto; min-width: 9rem; }
.sup-link-cust { margin-bottom: .75rem; }
.sup-link-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .25rem; }
.sup-link-row input, .sup-link-row select { flex: 1 1 12rem; min-width: 0; width: auto; }
.sup-thread { display: grid; gap: .6rem; margin: .5rem 0 1rem; max-height: 50vh; overflow-y: auto; padding-right: .25rem; }
.sup-msg { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; background: var(--card); max-width: 92%; min-width: 0; }
.sup-them { justify-self: start; }
.sup-us { justify-self: end; background: var(--blue-light); }
.sup-note { justify-self: stretch; max-width: none; background: #fef9c3; border-color: #fde68a; color: #422006; }
[data-theme="dark"] .sup-note { background: #3a3212; border-color: #6b5a1a; color: #fde68a; }
.sup-msg-head { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; font-size: .85rem; margin-bottom: .25rem; }
.sup-msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; }
.sup-reply-opts { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; margin-top: .4rem; font-size: .88rem; }
.sup-reply-opts select { width: auto; }
.sup-settings { margin-bottom: 1.5rem; }
.sup-settings .data-table input { width: 100%; min-width: 8rem; }
.ti-custs { margin: .25rem 0 .5rem 1.1rem; padding: 0; font-size: .92rem; }

/* Prepaid hours (customer window) */
.pp-plan { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .6rem; background: var(--card); }
.pp-plan.pp-ended { opacity: .7; }
.pp-head { display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: baseline; }
.pp-bar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; margin: .5rem 0 .25rem; }
.pp-bar span { display: block; height: 100%; background: var(--blue); }
.pp-nums { display: flex; justify-content: space-between; font-size: .85rem; }
.pp-actions { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.pp-types { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .35rem; }
