/* Forma OS — Application shell styles. Everything derives from tokens.css. */
@import './styles/tokens.css';

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body, #app { height: 100%; }

body {
  font-family: var(--font-body);
  font-weight: var(--font-weight-body);
  color: var(--text);
  background: var(--bg);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-heading);
  line-height: var(--leading-tight);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-hi); }

/* ── Controls ──────────────────────────────────────────────────────────── */
button, .btn {
  font-family: var(--font-ui);
  font-weight: var(--font-weight-ui);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  padding: 0.65rem var(--space-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-radius: var(--radius-sm);
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:active, .btn:active { background: var(--accent-active); }
button:disabled { opacity: 0.55; cursor: default; }
button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
button.secondary:hover { background: var(--surface); }
button.quiet {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: var(--space-xs) var(--space-sm);
}
button.quiet:hover { color: var(--text); background: var(--surface); }

label {
  font-family: var(--font-ui);
  font-weight: var(--font-weight-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin: var(--space-md) 0 var(--space-xs);
}

input, textarea, select {
  font-family: var(--font-body);
  font-weight: var(--font-weight-body);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg);
  border: 1px solid #D8DCE0;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  width: 100%;
  max-width: 26rem;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
input[type="checkbox"] { width: auto; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: var(--space-lg);
}
.login-card {
  background: var(--bg);
  width: 100%;
  max-width: 26rem;
  padding: var(--space-2xl) var(--space-2xl) var(--space-xl);
  border-top: 3px solid var(--accent);
  box-shadow: var(--shadow-lg);
}
.login-card .wordmark {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  color: var(--accent);
  letter-spacing: 0.01em;
}
.login-card .sub {
  font-family: var(--font-ui);
  font-weight: var(--font-weight-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: var(--space-xs) 0 var(--space-lg);
}
.login-card input { max-width: none; }
.login-card button { width: 100%; margin-top: var(--space-lg); padding: 0.8rem; }
.login-card .err {
  min-height: 1.25rem;
  margin-top: var(--space-md);
  color: #8B1E1E;
  font-size: var(--text-sm);
}

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

.rail {
  /* Light, slim, open — the sidebar recedes; the work is the interface. */
  background: var(--bg);
  color: var(--text);
  width: 208px;
  flex-shrink: 0;
  padding: var(--space-lg) 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}
.rail .wordmark {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--accent);
  padding: 0 var(--space-lg);
}
.rail .tag {
  font-family: var(--font-ui);
  font-weight: var(--font-weight-ui);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: var(--space-xs) var(--space-lg) var(--space-lg);
}
.rail nav { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--space-sm); }
.rail nav a {
  font-family: var(--font-ui);
  font-weight: var(--font-weight-ui);
  font-size: var(--text-sm);
  color: var(--muted);
  padding: 0.45rem var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.rail nav a:hover { color: var(--text); background: var(--surface); }
.rail nav a.active {
  color: var(--accent);
  background: rgba(6, 28, 82, 0.06);
  box-shadow: inset 2px 0 0 var(--accent);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-2xl);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.topbar h1 { font-size: var(--text-3xl); letter-spacing: -0.01em; }
.topbar .who {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-xs);
}
.topbar .logout {
  background: transparent;
  color: var(--muted);
  border: 1px solid #D8DCE0;
  padding: var(--space-xs) var(--space-md);
}
.topbar .logout:hover { color: var(--text); background: var(--surface); }

.view-content { padding: var(--space-xl) var(--space-2xl) var(--space-2xl); flex: 1; }

/* ── Cards & content ───────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--space-lg); }
.cards.single { grid-template-columns: 1fr; }
.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-top: 2px solid var(--accent);
  box-shadow: var(--shadow-sm);
  padding: var(--space-lg) var(--space-xl);
}
.card h3 {
  font-size: var(--text-lg);
  margin: 0 0 var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--line);
}

.chip {
  display: inline-block;
  font-family: var(--font-ui);
  font-weight: var(--font-weight-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  padding: 0.15rem 0.6rem;
  background: var(--surface);
  color: var(--text);
}
.chip.accent { background: var(--accent); color: var(--on-accent); }
.chip.highlight { background: var(--forma-highlight); color: var(--color-white); }
.chip.muted { color: var(--muted); }

table.list { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
table.list th {
  font-family: var(--font-ui);
  font-weight: var(--font-weight-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: var(--space-sm);
  border-bottom: 1px solid #D8DCE0;
}
table.list td { padding: var(--space-sm); border-bottom: 1px solid var(--line); vertical-align: middle; }

.surface { background: var(--surface); }
.muted { color: var(--muted); }
.highlight { color: var(--forma-highlight); }
.inline-err { color: #8B1E1E; font-size: var(--text-sm); margin-top: var(--space-sm); }

/* ── Responsive ────────────────────────────────────────────────────────── */
.rail-toggle { display: none; }
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .rail {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    flex-wrap: wrap;
  }
  .rail .wordmark { font-size: var(--text-lg); padding: 0 var(--space-sm); }
  .rail .tag { display: none; }
  .rail nav { flex-direction: row; flex-wrap: wrap; }
  .rail { border-right: none; border-bottom: 1px solid var(--line); }
  .rail nav a { padding: var(--space-sm) var(--space-md); box-shadow: none; }
  .rail nav a.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .topbar, .view-content { padding-left: var(--space-lg); padding-right: var(--space-lg); }
  .cards { grid-template-columns: 1fr; }
}

/* ── Onboarding: welcome, spotlight tour, getting-started ─────────────── */
#onboarding-layer { position: fixed; inset: 0; z-index: 900; }
.tour-dim { position: absolute; inset: 0; background: rgba(6, 28, 82, 0.45); backdrop-filter: blur(2px); }
.tour-welcome {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--bg); padding: var(--space-xl); width: min(26rem, calc(100vw - 2rem));
  border-top: 3px solid var(--accent); box-shadow: var(--shadow-lg); text-align: center;
}
.tour-welcome .wordmark { font-family: var(--font-heading); font-size: var(--text-2xl); margin-bottom: var(--space-md); }
.tour-spot {
  position: absolute; box-shadow: 0 0 0 9999px rgba(6, 28, 82, 0.45);
  outline: 2px solid var(--forma-highlight); transition: all var(--transition-base);
  pointer-events: none;
}
.tour-card {
  position: absolute; background: var(--bg); width: min(22rem, calc(100vw - 2rem));
  padding: var(--space-lg); border-top: 3px solid var(--forma-highlight); box-shadow: var(--shadow-lg);
}
.tour-card h3 { font-family: var(--font-heading); font-weight: var(--font-weight-heading); margin: 0 0 var(--space-sm); }
.tour-card p { margin: 0 0 var(--space-md); color: var(--text); line-height: var(--leading-normal); }
.tour-progress {
  font-family: var(--font-ui); font-weight: var(--font-weight-ui); font-size: var(--text-xs);
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: var(--space-sm);
}
.tour-actions { display: flex; align-items: center; gap: var(--space-sm); }
.tour-spacer { flex: 1; }
.tour-actions button { font-family: var(--font-ui); font-weight: var(--font-weight-ui); cursor: pointer; padding: var(--space-sm) var(--space-md); }
.tour-next { background: var(--accent); color: var(--on-accent); border: none; }
.tour-next:hover { background: var(--accent-hover); }
.tour-back, .tour-skip { background: none; border: 1px solid var(--line); color: var(--muted); }
.tour-skip { border: none; }
.tour-welcome .tour-actions { justify-content: center; }
@media (max-width: 860px) {
  .tour-card { left: 1rem !important; right: 1rem; bottom: 1rem; top: auto !important; width: auto; }
}

/* Getting-started checklist */
#getting-started:not(:empty) { margin-bottom: var(--space-lg); }
.getting-started .gs-items { display: flex; flex-direction: column; }
.gs-item {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm) 0; border-bottom: 1px solid var(--line);
}
.gs-item:last-child { border-bottom: none; }
.gs-item[data-go] { cursor: pointer; }
.gs-item[data-go]:hover .gs-label { color: var(--accent); }
.gs-item.done .gs-label { color: var(--muted); text-decoration: line-through; }
.gs-mark { font-family: var(--font-ui); color: var(--forma-highlight); width: 1.25rem; }
.gs-arrow { margin-left: auto; color: var(--muted); }

/* ── Shared states: loading, empty, error, toast ──────────────────────── */
.view-loading {
  display: flex; align-items: center; gap: var(--space-sm);
  color: var(--muted); padding: var(--space-2xl) 0; justify-content: center;
  font-family: var(--font-ui); font-weight: var(--font-weight-ui); font-size: var(--text-sm);
}
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state {
  text-align: center; padding: var(--space-2xl) var(--space-lg);
  border: 1px dashed #D8DCE0; background: var(--bg);
}
.empty-state .empty-title { font-family: var(--font-heading); font-size: var(--text-xl); margin-bottom: var(--space-sm); }
.empty-state .empty-hint { color: var(--muted); max-width: 30rem; margin: 0 auto var(--space-md); }
.empty-state.error { border-color: #C99; }
.empty-state.error .empty-title { color: #8B1E1E; }
.table-empty { text-align: center; padding: var(--space-xl) !important; }
.toast {
  position: fixed; bottom: var(--space-lg); left: 50%; transform: translate(-50%, 1rem);
  background: var(--color-charcoal); color: var(--color-white);
  font-family: var(--font-ui); font-weight: var(--font-weight-ui); font-size: var(--text-sm);
  padding: var(--space-sm) var(--space-lg); box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity var(--transition-base), transform var(--transition-base);
  z-index: 950; max-width: calc(100vw - 2rem);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8B1E1E; }

/* ── Slide-over panel ─────────────────────────────────────────────────── */
.panel-layer { position: fixed; inset: 0; z-index: 800; }
.panel-backdrop {
  position: absolute; inset: 0; background: rgba(6, 28, 82, 0.35);
  opacity: 0; transition: opacity var(--transition-base);
}
.panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(34rem, 100vw); background: var(--bg);
  box-shadow: var(--shadow-lg); border-left: 3px solid var(--accent);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform var(--transition-base);
}
.panel-layer.open .panel-backdrop { opacity: 1; }
.panel-layer.open .panel { transform: translateX(0); }
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: var(--space-lg) var(--space-xl); border-bottom: 1px solid var(--line);
}
.panel-title { font-family: var(--font-heading); font-size: var(--text-2xl); }
.panel-subtitle { font-size: var(--text-sm); margin-top: 2px; }
.panel-x { font-size: var(--text-xl); line-height: 1; }
.panel-body { flex: 1; overflow-y: auto; padding: var(--space-lg) var(--space-xl) var(--space-2xl); }
.panel-actions { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-lg); flex-wrap: wrap; }
.panel-actions-spacer { flex: 1; }
.panel-section { margin-bottom: var(--space-xl); }
.panel-section h3 {
  font-size: var(--text-lg); margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm); border-bottom: 1px solid var(--line);
}
.panel-savebar { display: flex; align-items: center; gap: var(--space-md); margin-top: var(--space-md); }
.save-status { font-size: var(--text-sm); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-md); }
.field label { margin-top: var(--space-sm); }
.field input, .field select, .field textarea { max-width: none; }
.field input:disabled { background: var(--surface); color: var(--muted); }
.field-wide { grid-column: 1 / -1; }
.note-item { padding: var(--space-sm) var(--space-md); background: var(--surface); margin-bottom: var(--space-sm); }
.note-meta { font-size: var(--text-xs); margin-bottom: 2px; }
.activity-item { padding: var(--space-sm) 0; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: none; }
.activity-when { font-size: var(--text-xs); }
@media (max-width: 860px) {
  .panel { width: 100vw; border-left: none; }
  .field-grid { grid-template-columns: 1fr; }
}

/* ── Pipeline board ───────────────────────────────────────────────────── */
.board-bar { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-lg); flex-wrap: wrap; }
.board-bar input[type="search"] { max-width: 22rem; }
.board-bar select { width: auto; }
.board-count { font-size: var(--text-sm); white-space: nowrap; }
.pipeline-board { display: flex; gap: var(--space-md); overflow-x: auto; padding-bottom: var(--space-md); align-items: flex-start; }
.pipeline-col { min-width: 260px; flex: 0 0 260px; background: var(--surface); padding: var(--space-md); }
.pipeline-col-head {
  font-family: var(--font-ui); font-weight: var(--font-weight-ui); font-size: var(--text-sm);
  margin-bottom: var(--space-md);
}
.pipeline-col-body { display: flex; flex-direction: column; gap: var(--space-sm); }
.pipeline-col-empty { text-align: center; padding: var(--space-sm) 0; }
.pipeline-card {
  background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: var(--space-sm) var(--space-md); cursor: pointer;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.pipeline-card:hover { box-shadow: var(--shadow-md); border-left-color: var(--forma-highlight); }
.pc-number { font-family: var(--font-ui); font-weight: var(--font-weight-ui); font-size: var(--text-sm); }
.pc-name { font-size: var(--text-sm); }
.pc-type { font-size: var(--text-xs); }

/* ── Clients: search + duplicate warning ──────────────────────────────── */
.page-bar { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-md); }
.page-bar-sub { font-family: var(--font-ui); font-weight: var(--font-weight-ui); font-size: var(--text-sm); color: var(--muted); margin-right: auto; }
.bar-search { max-width: 18rem; }
.table-wrap { overflow-x: auto; }
.table-wrap td { overflow-wrap: anywhere; }
tr.row-link { cursor: pointer; transition: background var(--transition-fast); }
tr.row-link:hover { background: var(--surface); }
.dup-warning {
  margin: var(--space-md) 0; padding: var(--space-md);
  background: var(--surface); border-left: 3px solid var(--forma-highlight);
}
.dup-warning-title { font-family: var(--font-ui); font-weight: var(--font-weight-ui); font-size: var(--text-sm); margin-bottom: var(--space-sm); }

/* ── Dashboard: attention strip ── */
.attention-strip { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; margin-bottom: var(--space-lg); }
.stat-chip {
  display: flex; align-items: baseline; gap: var(--space-sm);
  background: var(--surface); padding: var(--space-sm) var(--space-md);
  cursor: pointer; border-left: 3px solid var(--accent);
  transition: box-shadow var(--transition-fast);
}
.stat-chip:hover { box-shadow: var(--shadow-md); }
.stat-chip .n { font-family: var(--font-ui); font-weight: var(--font-weight-ui); font-size: var(--text-2xl); color: var(--accent); }
.stat-chip .l { font-size: var(--text-sm); color: var(--muted); }
.stat-chip.attention { border-left-color: var(--forma-highlight); }
.stat-chip.attention .n { color: var(--forma-highlight); }
.snapshot-row { display: flex; align-items: baseline; gap: var(--space-sm); padding: 2px var(--space-xs); cursor: pointer; }
.snapshot-row:hover { background: var(--surface); }
.snapshot-row .n { font-family: var(--font-ui); font-weight: var(--font-weight-ui); font-size: var(--text-xl); min-width: 2rem; }
.snapshot-row.zero { color: var(--muted); }
.snapshot-row.deposit { background: var(--surface); border-left: 3px solid var(--forma-highlight); padding: var(--space-sm); }


/* ── New Lead Card fields (rendered inside a panel slide-over; the old bespoke
   .modal overlay was removed when openLeadCard moved to panel.js) ── */
.lc-section {
  font-family: var(--font-heading); font-size: var(--text-lg);
  margin: var(--space-lg) 0 var(--space-md); padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--line);
}
.lc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-sm) var(--space-md); }
.lc-field { display: flex; flex-direction: column; }
.lc-field label { font-size: var(--text-sm); margin-bottom: 2px; }
@media (max-width: 860px) {
  .lc-grid { grid-template-columns: 1fr; }
}


/* ── Guided booking flow (in the lead panel) ──────────────────────────────── */
.bk-flow { display: flex; flex-direction: column; }
.bk-steps { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: var(--space-md); }
.bk-step { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.bk-step b { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.bk-step.active { color: var(--accent); font-weight: 600; }
.bk-step.active b, .bk-step.done b { background: var(--accent); color: #fff; border-color: var(--accent); }
.bk-step.done b { opacity: .55; }
.bk-body { animation: bkfade .18s ease; }
@keyframes bkfade { from { opacity: .4; } to { opacity: 1; } }
.bk-context { display: grid; gap: 4px; padding: var(--space-md); background: var(--surface, #F2F2F2); margin-bottom: var(--space-md); }
.bk-context .muted { display: inline-block; min-width: 54px; }
.bk-weeknav { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-sm); }
.bk-grid-wrap { min-height: 120px; }
.bk-grid { display: flex; gap: var(--space-sm); overflow-x: auto; }
.bk-col { flex: 1; min-width: 84px; display: flex; flex-direction: column; gap: 6px; }
.bk-col-head { font-size: 12px; color: var(--muted); text-align: center; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.bk-slot { font-size: 13px; padding: 7px 4px; border: 1px solid var(--line); background: transparent; cursor: pointer; color: inherit; }
.bk-slot.sl-available { background: rgba(6, 28, 82, .06); border-color: rgba(6, 28, 82, .2); }
.bk-slot.sl-available:hover { background: rgba(6, 28, 82, .12); }
.bk-slot.sl-selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.bk-slot.sl-taken { background: var(--surface, #F2F2F2); color: var(--muted); cursor: not-allowed; text-decoration: line-through; }
.bk-legend { display: flex; gap: var(--space-md); margin-top: var(--space-sm); font-size: 12px; color: var(--muted); }
.bk-legend i { display: inline-block; width: 11px; height: 11px; margin-right: 5px; vertical-align: -1px; }
.bk-legend i.sl-available { background: rgba(6, 28, 82, .12); border: 1px solid rgba(6, 28, 82, .2); }
.bk-legend i.sl-selected { background: var(--accent); }
.bk-legend i.sl-taken { background: var(--surface, #F2F2F2); border: 1px solid var(--line); }
.bk-loading, .bk-empty { padding: var(--space-lg); text-align: center; color: var(--muted); }
.bk-summary dl { margin: 0; }
.bk-summary dl > div { display: flex; gap: var(--space-md); padding: 7px 0; border-bottom: 1px solid rgba(127, 127, 127, .15); }
.bk-summary dt { min-width: 84px; color: var(--muted); font-size: 13px; }
.bk-summary dd { margin: 0; font-size: 14px; }
.bk-actions { justify-content: space-between; }

.bk-empty-state { padding: var(--space-lg); text-align: center; }
.bk-empty-state .bk-empty-title { font-weight: 600; margin-bottom: var(--space-sm); }
.bk-empty-state p { margin: 0 0 var(--space-md); }
.bk-empty-state .inline-btn { margin-top: var(--space-xs, 6px); }



/* ── Print job sheet ─────────────────────────────────────────────────────── */
#print-sheet { display: none; }
@media print {
  body.printing-sheet > *:not(#print-sheet) { display: none !important; }
  #print-sheet { display: block; font-family: Arial, sans-serif; color: #000; }
  .ps-head { display: flex; align-items: baseline; gap: 16px; border-bottom: 3px solid #000; padding-bottom: 6px; margin-bottom: 12px; }
  .ps-brand { font-weight: 800; letter-spacing: .08em; font-size: 15px; }
  .ps-title { font-size: 13px; letter-spacing: .2em; }
  .ps-ref { margin-left: auto; font-size: 22px; font-weight: 800; }
  .ps-grid { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
  .ps-grid th, .ps-grid td { border: 1px solid #000; padding: 6px 8px; font-size: 11px; text-align: left; }
  .ps-grid th { width: 14%; background: #eee; text-transform: uppercase; font-size: 9px; letter-spacing: .05em; }
  .ps-box { border: 1px solid #000; min-height: 110px; margin-bottom: 10px; position: relative;
    background: repeating-linear-gradient(#fff, #fff 26px, #ddd 27px); }
  .ps-box.tall { min-height: 170px; }
  .ps-label { position: absolute; top: 0; left: 0; background: #000; color: #fff; font-size: 8.5px;
    letter-spacing: .12em; padding: 2px 8px; }
  .ps-notes { border: 1px solid #000; padding: 22px 8px 8px; position: relative; margin-bottom: 12px; min-height: 60px; }
  .ps-note { font-size: 10.5px; padding: 2px 0; }
  .ps-sign { display: flex; justify-content: space-between; font-size: 10.5px; margin-top: 8px; }
  @page { margin: 12mm; }
}



/* ── Bookings: desktop layout ────────────────────────────────────────────────
   The generic .cards auto-fill grid reserved a ghost third track on wide
   screens, compressing both cards. Bookings gets an explicit two-column
   desktop layout: agenda flexes, the appointment form gets the width the
   availability grid needs. Mobile unchanged (single column). */
.bk-layout { grid-template-columns: 1fr; }
@media (min-width: 1000px) {
  .bk-layout {
    grid-template-columns: minmax(360px, 1fr) minmax(560px, 720px);
    align-items: start;
  }
  .bk-grid { overflow-x: visible; }
  .bk-col { min-width: 100px; }
}


/* ── Bookings: agenda ────────────────────────────────────────────────────────
   A real day-planner: bordered day groups, a two-line time block, type over
   client, status chip pinned right. Replaces the old inline-styled rows that
   wrapped awkwardly at width. */
.agenda-day { margin-bottom: var(--space-lg); }
.agenda-day-head { font-weight: 600; font-size: 0.95rem; padding-bottom: 6px; margin-bottom: 2px;
  border-bottom: 2px solid var(--accent); }
.agenda-row { display: flex; gap: var(--space-md); align-items: center; padding: 10px 2px;
  border-top: 1px solid var(--line); cursor: pointer; transition: background .12s ease; }
.agenda-day .agenda-row:first-of-type { border-top: 0; }
.agenda-row:hover { background: var(--section-fill, #F2F2F2); }
.agenda-time { min-width: 72px; text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 600; line-height: 1.25; border-right: 2px solid var(--line); padding-right: var(--space-md); }
.agenda-time .muted { font-weight: 400; font-size: 0.85em; }
.agenda-main { flex: 1; min-width: 0; }
.agenda-type { font-weight: 500; text-transform: capitalize; }
.agenda-who { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-row .chip { flex: none; }
.appt-edit { padding: 0.75rem; background: var(--section-fill, #F2F2F2); }
.agenda-empty { text-align: center; padding: var(--space-xl) 0; }
.agenda-empty-title { font-weight: 500; margin-bottom: 4px; }

/* ── Production calendar (the whiteboard, digitised) ────────────────────────── */
.jview-toggle { display: inline-flex; gap: 0; border: 1px solid var(--line); }
.jview-toggle button { border: 0; background: transparent; padding: 0.45rem 1rem; cursor: pointer; }
.jview-toggle button.active { background: var(--accent); color: #fff; }
.jcal-week-label { margin: 0 var(--space-sm); }
.jcal { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--space-sm); align-items: start; }
.jcal-col { background: var(--bg); border: 1px solid var(--line); min-height: 300px; padding: var(--space-sm); }
.jcal-col.today { border-color: var(--accent); border-width: 2px; }
.jcal-col-head { font-weight: 600; text-align: center; padding-bottom: 6px; margin-bottom: 6px;
  border-bottom: 2px solid var(--accent); }
.jcal-col-head span { display: block; font-size: 1.4em; }
.jcal-card { position: relative; border: 1px solid var(--line); border-left: 4px solid var(--muted);
  padding: 8px 10px; margin-bottom: 6px; cursor: pointer; background: var(--bg); box-shadow: var(--shadow-sm); }
.jcal-card:hover { box-shadow: var(--shadow-md, 0 2px 8px rgba(0,0,0,.12)); }
.jcal-num { font-weight: 700; }
.jcal-cust { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jcal-st { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.jcal-card.st-design { border-left-color: #6FA8DC; }
.jcal-card.st-in_review { border-left-color: #8E7CC3; }
.jcal-card.st-sent_to_client { border-left-color: #F6B26B; }
.jcal-card.st-revisions { border-left-color: #E06666; }
.jcal-card.st-approved { border-left-color: #93C47D; }
.jcal-card.st-complete { border-left-color: #34A853; opacity: .75; }
.jcal-unset { position: absolute; top: 2px; right: 4px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; }
.jcal-tray { margin-top: var(--space-lg); border-top: 2px solid var(--line); padding-top: var(--space-md); }
.jcal-tray-head { font-weight: 600; margin-bottom: var(--space-sm); }
.jcal-tray-row { display: flex; gap: var(--space-md); align-items: center; padding: 6px 0;
  border-top: 1px solid var(--line); flex-wrap: wrap; }
.jcal-tray-row input[type="date"] { margin-left: auto; }
@media (max-width: 900px) { .jcal { grid-template-columns: repeat(2, 1fr); } .jcal-col { min-height: 160px; } }

/* TV mode: chrome gone, type scaled for across-the-workshop reading, runs
   unattended (view auto-refreshes every 60s while active). */
body.tv-mode .rail, body.tv-mode .topbar { display: none; }
body.tv-mode .main { padding: 1.2vw 1.5vw; max-width: none; }
body.tv-mode .jview-toggle, body.tv-mode #jcal-tv, body.tv-mode .jcal-tray { display: none; }
body.tv-mode .board-bar { justify-content: center; font-size: 1.6vw; }
body.tv-mode .jcal { gap: 0.8vw; }
body.tv-mode .jcal-col { min-height: 74vh; }
body.tv-mode .jcal-col-head { font-size: 1.5vw; }
body.tv-mode .jcal-num { font-size: 1.7vw; }
body.tv-mode .jcal-cust { font-size: 1.1vw; }
body.tv-mode .jcal-st { font-size: 0.8vw; }
body.tv-mode .jcal-unset { display: none; }
