/* =========================================================
   Home And Life LLC — Internal App Stylesheet
   Shared styles for all /app pages.
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  --cream: #F7F3EE;
  --warm-white: #FDFAF7;
  --sage: #7A9E87;
  --sage-dark: #4E7260;
  --sage-light: #C4D8CB;
  --charcoal: #2C2C2C;
  --mid: #6B6B6B;
  --light: #A8A8A8;
  --border: #E4DDD5;
  --accent: #B5824A;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(44, 44, 44, 0.04);
  --shadow-md: 0 4px 16px rgba(44, 44, 44, 0.06);
  --sidebar-w: 250px;
  --header-h: 64px;

  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--charcoal);
  background: var(--warm-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5 {
  font-family: var(--font-heading);
  font-weight: 500;
  color: var(--charcoal);
  margin: 0 0 0.5em 0;
  line-height: 1.2;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.35rem; }
p  { margin: 0 0 1em 0; color: var(--mid); }
a  { color: var(--sage-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App layout ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--cream);
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
}
.sidebar-brand {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 4px;
}
.sidebar-tag {
  font-size: 0.75rem;
  color: var(--light);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 32px;
}
.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}
.sidebar-nav li { margin-bottom: 4px; }
.sidebar-nav a {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--charcoal);
  font-size: 0.95rem;
  transition: background 0.15s ease;
}
.sidebar-nav a:hover {
  background: var(--sage-light);
  text-decoration: none;
}
.sidebar-nav a.active {
  background: var(--sage-dark);
  color: var(--warm-white);
}
.sidebar-user {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin-top: 18px;
  font-size: 0.85rem;
}
.sidebar-user .name {
  font-weight: 600;
  color: var(--charcoal);
  display: block;
}
.sidebar-user .role {
  color: var(--mid);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Mobile toggle */
.menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  background: var(--warm-white);
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--charcoal);
  position: relative;
}
.menu-toggle span::before,
.menu-toggle span::after {
  content: '';
  position: absolute;
  left: 0;
}
.menu-toggle span::before { top: -6px; }
.menu-toggle span::after  { top: 6px; }

/* Main content area */
.main {
  flex: 1;
  padding: 36px 44px;
  max-width: 100%;
  min-width: 0;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header .subtitle {
  color: var(--mid);
  margin-top: 4px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 18px; }
.card-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  margin: 0 0 14px 0;
}

/* Stat cards grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.stat-card .label {
  font-size: 0.78rem;
  color: var(--mid);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.stat-card .value {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  color: var(--charcoal);
  line-height: 1;
}
.stat-card .hint {
  font-size: 0.8rem;
  color: var(--light);
  margin-top: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--sage-dark);
  color: var(--warm-white);
  text-decoration: none;
  line-height: 1;
}
.btn:hover { background: var(--charcoal); text-decoration: none; }
.btn-secondary {
  background: transparent;
  color: var(--charcoal);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--cream);
  color: var(--charcoal);
}
.btn-accent {
  background: var(--accent);
  color: var(--warm-white);
}
.btn-accent:hover { background: #a0703d; }
.btn-danger {
  background: transparent;
  color: #a6433a;
  border-color: #e1c7c3;
}
.btn-danger:hover { background: #fbeeec; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--charcoal);
  margin-bottom: 6px;
}
label .req { color: var(--accent); margin-left: 2px; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--charcoal);
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(122, 158, 135, 0.18);
}
textarea { resize: vertical; min-height: 100px; }

.checkbox,
.radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--charcoal);
  margin-bottom: 8px;
  cursor: pointer;
}
.checkbox input,
.radio input {
  margin-top: 3px;
  accent-color: var(--sage-dark);
}

.form-error {
  color: #a6433a;
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 1.2em;
}
.form-help {
  font-size: 0.8rem;
  color: var(--mid);
  margin-top: 4px;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--warm-white);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data thead th {
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mid);
  font-weight: 600;
  padding: 14px 18px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
}
table.data tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--charcoal);
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--cream); }
table.data tbody tr.expand-row td {
  background: var(--cream);
  padding: 18px 22px;
}

/* Status badges */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge-active   { background: var(--sage-light); color: var(--sage-dark); }
.badge-inactive { background: #eee; color: var(--mid); }
.badge-pending  { background: #f5e8d5; color: var(--accent); }

/* ---------- Activity feed ---------- */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--charcoal);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.activity-list li:last-child { border-bottom: none; }
.activity-list .time {
  color: var(--light);
  font-size: 0.8rem;
  white-space: nowrap;
}
.empty-state {
  text-align: center;
  color: var(--light);
  padding: 30px 10px;
  font-size: 0.92rem;
}

/* ---------- Toolbar / filters ---------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar .filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 44, 44, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--warm-white);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: var(--shadow-md);
}
.modal h2 { margin-top: 0; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--charcoal);
  color: var(--warm-white);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Login page ---------- */
.auth-page {
  min-height: 100vh;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-box {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
}
.auth-box .brand {
  text-align: center;
  font-family: var(--font-heading);
  font-size: 1.75rem;
  margin-bottom: 4px;
}
.auth-box .brand-tag {
  text-align: center;
  font-size: 0.75rem;
  color: var(--light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 28px;
}
.auth-box h2 {
  text-align: center;
  font-size: 1.35rem;
  margin-bottom: 22px;
}
.auth-footer {
  text-align: center;
  margin-top: 22px;
  font-size: 0.82rem;
  color: var(--light);
}

/* ---------- Utilities ---------- */
.flex        { display: flex; }
.flex-between{ display: flex; justify-content: space-between; align-items: center; }
.gap-sm      { gap: 8px; }
.gap-md      { gap: 16px; }
.mt-0        { margin-top: 0; }
.mt-sm       { margin-top: 8px; }
.mt-md       { margin-top: 16px; }
.mt-lg       { margin-top: 32px; }
.mb-0        { margin-bottom: 0; }
.mb-sm       { margin-bottom: 8px; }
.mb-md       { margin-bottom: 16px; }
.text-muted  { color: var(--mid); }
.text-center { text-align: center; }
.hidden      { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: flex; }
  .main { padding: 72px 20px 32px 20px; }
  .form-row { grid-template-columns: 1fr; }
  h1 { font-size: 1.75rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

@media print {
  .sidebar, .menu-toggle, .btn, .toolbar { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { border: none; box-shadow: none; }
}

/* =========================================================
   Section 5 — Security, Forms, Audit, Compliance UI
   ========================================================= */

/* ---------- Confidential footer bar ---------- */
.hal-confidential-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--charcoal);
  color: var(--cream);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 6px 12px;
  z-index: 80;
  font-family: var(--font-body);
}
/* give pages a little bottom breathing room so the footer doesn't cover content */
.main { padding-bottom: 60px; }

/* ---------- Compliance notices ---------- */
.compliance-banner {
  border: 1px solid #e6d3a8;
  background: #fbf5e6;
  color: #6b5a24;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  line-height: 1.45;
  margin-bottom: 18px;
}
.compliance-banner.strong {
  background: #fbe9d6;
  border-color: #e8c490;
  color: #744a1a;
}

/* ---------- Lock badges + sensitive badges ---------- */
.badge-locked {
  background: #fbe4e0;
  color: #a6433a;
  border: 1px solid #f0c1b9;
}
.badge-unlocked {
  background: var(--sage-light);
  color: var(--sage-dark);
}
.badge-sensitive {
  background: #fbe4e0;
  color: #a6433a;
  border: 1px solid #f0c1b9;
  font-weight: 600;
}
.badge-draft {
  background: #eee;
  color: var(--mid);
}

.lock-btn {
  background: transparent;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.92rem;
}
.lock-btn:hover { background: var(--cream); }
.lock-btn.locked { color: #a6433a; border-color: #f0c1b9; }

/* ---------- Passcode entry screen ---------- */
.passcode-backdrop {
  position: fixed; inset: 0;
  background: rgba(44,44,44,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 600;
  padding: 20px;
}
.passcode-card {
  background: var(--warm-white);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-md);
}
.passcode-card h2 {
  margin: 0 0 8px;
  font-family: var(--font-heading);
}
.passcode-card .doc-name {
  font-size: 0.85rem;
  color: var(--mid);
  margin-bottom: 18px;
}
.passcode-card .attempts-hint {
  color: #a6433a;
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 1.2em;
}
.lockout-countdown {
  text-align: center;
  font-family: var(--font-heading);
  font-size: 2rem;
  color: #a6433a;
  margin: 16px 0;
  letter-spacing: 0.05em;
}
.override-link {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  color: var(--mid);
  margin-top: 14px;
  cursor: pointer;
  text-decoration: underline;
}
.override-link:hover { color: var(--charcoal); }

/* ---------- Inactivity warning modal ---------- */
.hal-inactivity-modal .modal {
  border-top: 4px solid var(--accent);
}

/* ---------- Forms page: template cards/table ---------- */
.form-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.template-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.template-card h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin: 0;
}
.template-card .meta {
  font-size: 0.8rem;
  color: var(--mid);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.template-card .actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

/* ---------- Form editor ---------- */
.editor-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  min-height: calc(100vh - 130px);
}
.editor-toolbar {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  height: fit-content;
  position: sticky;
  top: 20px;
}
.editor-toolbar h4 {
  font-family: var(--font-heading);
  font-size: 1rem;
  margin: 0 0 10px;
}
.field-type-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--warm-white);
  cursor: pointer;
  font-size: 0.9rem;
  margin-bottom: 6px;
  text-align: left;
  font-family: var(--font-body);
}
.field-type-btn:hover { background: var(--sage-light); }
.field-type-btn.active {
  background: var(--sage-dark);
  color: var(--warm-white);
  border-color: var(--sage-dark);
}

.editor-canvas-wrap {
  position: relative;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow: auto;
}
.editor-pdf-stage {
  position: relative;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
  background: #fff;
  cursor: crosshair;
}
.editor-pdf-stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Placed field boxes */
.field-box {
  position: absolute;
  border: 2px solid;
  border-radius: 3px;
  background: rgba(255,255,255,0.7);
  min-width: 30px;
  min-height: 24px;
  cursor: move;
  font-size: 10px;
  color: var(--charcoal);
  box-sizing: border-box;
}
.field-box .label {
  padding: 2px 4px;
  font-family: var(--font-body);
  font-weight: 500;
  pointer-events: none;
}
.field-box .actions {
  position: absolute;
  top: -12px;
  right: -4px;
  display: flex;
  gap: 3px;
}
.field-box .actions button {
  border: none;
  background: var(--charcoal);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.field-box .resize-handle {
  position: absolute;
  bottom: -5px; right: -5px;
  width: 12px; height: 12px;
  background: var(--charcoal);
  border: 2px solid white;
  border-radius: 2px;
  cursor: nwse-resize;
}
.field-box.selected { box-shadow: 0 0 0 3px rgba(122,158,135,0.25); }

/* Field type color coding */
.field-text      { border-color: #4B7FB5; background: rgba(75,127,181,0.1); }
.field-name      { border-color: var(--sage-dark); background: rgba(78,114,96,0.1); }
.field-signature { border-color: #7A5AA8; background: rgba(122,90,168,0.1); }
.field-date      { border-color: var(--accent); background: rgba(181,130,74,0.12); }
.field-checkbox  { border-color: var(--mid); background: rgba(107,107,107,0.08); }
.field-initials  { border-color: #2F8F88; background: rgba(47,143,136,0.1); }
.field-sensitive { border-color: #a6433a; background: rgba(166,67,58,0.12); }

/* Field edit popover */
.field-popover {
  position: absolute;
  z-index: 50;
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  width: 260px;
  box-shadow: var(--shadow-md);
}
.field-popover label { font-size: 0.78rem; }

/* ---------- Fill form experience ---------- */
.fill-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 12px 80px;
  min-height: 100vh;
}
.fill-header {
  padding: 16px 4px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.fill-header .brand {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--charcoal);
}
.fill-header .form-name {
  font-size: 1rem;
  color: var(--mid);
  margin-top: 4px;
}
.fill-progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 4px;
}
.fill-progress > span {
  display: block;
  height: 100%;
  background: var(--sage-dark);
  transition: width 0.25s ease;
}
.fill-stage {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow-md);
  margin: 0 auto;
}
.fill-stage canvas {
  display: block;
  width: 100%;
  height: auto;
}
/* Overlay inputs over PDF */
.fill-input {
  position: absolute;
  box-sizing: border-box;
  font-family: var(--font-body);
  font-size: 14px;
  padding: 4px;
  border: 2px dashed var(--sage);
  background: rgba(255,255,255,0.9);
  min-height: 32px;
}
.fill-input.invalid { border-color: #a6433a; background: rgba(166,67,58,0.1); }
.fill-input-sig {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.9);
  border: 2px dashed #7A5AA8;
  color: #7A5AA8;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  font-size: 12px;
}
.fill-input-sig img { max-width: 100%; max-height: 100%; }
.fill-input-check {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.9);
  border: 2px solid var(--mid);
  cursor: pointer;
  font-size: 20px;
  color: var(--sage-dark);
  min-width: 44px;
  min-height: 44px;
}
.fill-input-check.checked::before { content: '✓'; }

.fill-footer-nav {
  position: sticky;
  bottom: 30px;
  background: var(--warm-white);
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  z-index: 60;
}

/* In-person mode makes touch targets larger */
.fill-shell.inperson .fill-input         { font-size: 18px; min-height: 44px; padding: 10px; }
.fill-shell.inperson .fill-input-sig     { font-size: 16px; }
.fill-shell.inperson .fill-input-check   { min-width: 56px; min-height: 56px; font-size: 26px; }

/* ---------- Signature canvas overlay ---------- */
.sig-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,44,44,0.92);
  z-index: 800;
  display: flex;
  flex-direction: column;
  padding: 20px;
}
.sig-overlay .title {
  text-align: center;
  color: white;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  margin-bottom: 8px;
}
.sig-overlay .hint {
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  margin-bottom: 14px;
}
.sig-overlay .canvas-wrap {
  flex: 1;
  background: white;
  border-radius: var(--radius);
  position: relative;
}
.sig-overlay canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}
.sig-overlay .actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding-top: 14px;
}
.sig-overlay .actions .btn { min-width: 120px; }

/* ---------- Confirmation full-screen (in-person) ---------- */
.fill-complete {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  background: var(--cream);
}
.fill-complete h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  margin-bottom: 8px;
}
.fill-complete .dim {
  margin-top: 60px;
  color: var(--light);
  font-size: 0.85rem;
}

/* ---------- Audit log page ---------- */
.audit-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 14px;
}
.audit-filters .form-group { margin-bottom: 0; }

table.data.audit tbody td {
  font-size: 0.85rem;
  vertical-align: top;
}
table.data.audit .action-cell {
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--charcoal);
}

/* ---------- Misc ---------- */
.hal-sig-thumb {
  max-width: 120px;
  max-height: 48px;
  border: 1px solid var(--border);
  border-radius: 3px;
}
.inline-flex { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 800px) {
  .editor-shell { grid-template-columns: 1fr; }
  .editor-toolbar { position: static; display: flex; flex-wrap: wrap; gap: 6px; }
  .field-type-btn { width: auto; flex: 1 1 45%; }
}

/* =========================================================
   Section 6 — Revenue, Agreements, Staff Linking
   ========================================================= */

/* ---- Segmented filter (Active | Inactive | All) ---- */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--warm-white);
}
.segmented button {
  appearance: none;
  border: none;
  background: transparent;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--mid);
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { background: var(--cream); color: var(--charcoal); }
.segmented button[aria-pressed="true"] {
  background: var(--sage-dark);
  color: var(--warm-white);
}

/* ---- Warning pills (card badges + alert rows) ---- */
.warning-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 500;
  border: 1px solid transparent;
}
.warning-pill.red {
  background: #fbe4e0; color: #a6433a; border-color: #f0c1b9;
}
.warning-pill.yellow {
  background: #fbf1d8; color: #8a6619; border-color: #ecd59a;
}
.warning-pill.muted {
  background: #eee; color: var(--mid);
}

/* ---- Avatar initials (staff on client cards) ---- */
.assigned-staff {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--mid);
}
.avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sage-light);
  color: var(--sage-dark);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
}

/* ---- Tab strip (Info | Revenue | Forms inside client detail) ---- */
.tab-strip {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 16px;
}
.tab-strip button {
  appearance: none;
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--mid);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-strip button:hover { color: var(--charcoal); }
.tab-strip button[aria-selected="true"] {
  color: var(--charcoal);
  border-bottom-color: var(--sage-dark);
  font-weight: 600;
}

/* ---- Units progress bar ---- */
.progress {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--sage-dark);
  transition: width 0.25s ease;
}
.progress.warn > span { background: var(--accent); }
.progress.danger > span { background: #a6433a; }

/* ---- Profit margin chip ---- */
.margin-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
}
.margin-chip.green  { background: #e3f1e4; color: #33633d; border-color: #b9d9c0; }
.margin-chip.yellow { background: #fbf1d8; color: #8a6619; border-color: #ecd59a; }
.margin-chip.red    { background: #fbe4e0; color: #a6433a; border-color: #f0c1b9; }

/* ---- Dashboard alert row ---- */
.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.9rem;
}
.alert-row:last-child { border-bottom: none; }
.alert-row:hover { background: var(--cream); }
.alert-row .alert-icon {
  font-size: 1rem;
  min-width: 20px;
  text-align: center;
}

/* ---- Revenue tab spacing ---- */
.rev-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.rev-card h4 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin: 0 0 10px;
}
.rev-stat {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 0.92rem;
}
.rev-stat strong { color: var(--charcoal); font-weight: 600; }
.rev-helper {
  font-size: 0.78rem;
  color: var(--light);
  margin-top: -2px;
  margin-bottom: 8px;
}

/* ---- Assign-staff rows inside add/edit employee modal ---- */
.assign-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: start;
  margin-bottom: 8px;
}
.assign-row .chk-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.82rem;
}
.assign-row .remove-x {
  background: transparent;
  border: 1px solid var(--border);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--mid);
}
.assign-row .remove-x:hover { color: #a6433a; border-color: #f0c1b9; }

@media (max-width: 700px) {
  .assign-row { grid-template-columns: 1fr; }
}

/* =========================================================
   Section 6 — Standalone Revenue page
   ========================================================= */

.summary-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  margin: -36px -44px 24px; /* bleed to page edges over .main padding */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.summary-bar .stat-card {
  background: var(--warm-white);
  padding: 14px 16px;
  margin: 0;
}
.summary-bar .stat-card .value {
  font-size: 1.65rem;
}

@media (max-width: 900px) {
  .summary-bar { margin: -72px -20px 20px; padding: 12px; }
}

.rev-client-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.rev-client-card .rev-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  flex-wrap: wrap;
}
.rev-client-card .rev-header:hover { background: var(--cream); }
.rev-client-card .rev-name {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--charcoal);
}
.rev-client-card .rev-quickstat {
  margin-left: auto;
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 0.9rem;
}
.rev-chevron {
  display: inline-block;
  width: 16px;
  height: 16px;
  position: relative;
  transition: transform 0.2s ease;
  color: var(--mid);
}
.rev-chevron::before {
  content: '▸';
  display: block;
  font-size: 14px;
}
.rev-client-card.open .rev-chevron { transform: rotate(90deg); }

.rev-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--border);
  display: none;
}
.rev-client-card.open .rev-body { display: block; }

.rev-section + .rev-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.rev-section h4 {
  font-family: var(--font-heading);
  font-size: 1rem;
  margin: 12px 0 8px;
  color: var(--charcoal);
}

/* Summary grid inside financial section */
.rev-totals {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 18px;
  max-width: 520px;
  font-size: 0.93rem;
}
.rev-totals .rev-line-divider {
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--border);
  margin: 4px 0;
}
.rev-totals strong { font-weight: 600; color: var(--charcoal); }
.rev-totals .val { text-align: right; font-variant-numeric: tabular-nums; }

.margin-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.margin-dot.green  { background: #3a8546; }
.margin-dot.yellow { background: #c99a31; }
.margin-dot.red    { background: #a6433a; }
