/* Kinetic-JCV: Novello's simple layout (side menu, filter bar, tables), coloured
   by the agency's branding. --primary, --accent, --cand and --client are set from
   core.organisation_branding at sign-in; the values here are Kinetic Flow's defaults.
   Shades are worked out from each accent the same way for every agency. */
:root {
  --primary: #0B2A4A;
  --accent: #D97706;
  --cand: #1D47B8;
  --client: #9343AE;
  --cand-tint: color-mix(in srgb, var(--cand) 4%, white);
  --cand-wash: color-mix(in srgb, var(--cand) 9%, white);
  --cand-wash-strong: color-mix(in srgb, var(--cand) 16%, white);
  --client-tint: color-mix(in srgb, var(--client) 4%, white);
  --client-wash: color-mix(in srgb, var(--client) 9%, white);
  --client-wash-strong: color-mix(in srgb, var(--client) 16%, white);
  --main-action: #B45309;        /* amber: the main action, never a side */
  --ok: #15803D; --ok-wash: #DCFCE7;
  --danger: #B91C1C; --danger-wash: #FEE2E2;
  --ink: #1F2937; --muted: #5B6472; --line: #E3E6EB; --divider-line: #A3ACBA;
  --surface: #F5F6F8; --card: #FFFFFF;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.sandbox-banner {
  background: repeating-linear-gradient(135deg, #374151 0 12px, #4B5563 12px 24px);
  color: #fff; font-size: 13px; padding: 6px 16px; text-align: center; font-weight: 600;
}

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 30px); }
.sidebar { background: var(--primary); color: #fff; padding: 16px 12px; }
.brand { background: #fff; border-radius: var(--radius); padding: 12px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 4px; }
.brand .logo { max-width: 100%; height: 40px; object-fit: contain; object-position: left; }
.brand .wordmark { color: var(--primary); font-weight: 700; font-size: 17px; }
.brand .product { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.menu a { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 10px 12px; border-radius: 6px; opacity: .85; }
.menu a:hover { background: rgb(255 255 255 / .1); opacity: 1; }
.menu a.active { background: rgb(255 255 255 / .18); opacity: 1; font-weight: 600; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 2px solid var(--divider-line); display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; gap: 12px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 14px; }
main { padding: 20px 24px; outline: none; }

/* icons (drawn, no text) */
.icon { display: inline-block; width: 16px; height: 16px; background: currentColor; flex: none;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.icon-person { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='5' r='3'/%3E%3Cpath d='M2 15c0-3.3 2.7-6 6-6s6 2.7 6 6z'/%3E%3C/svg%3E"); }
.icon-building { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 15V2h8v4h4v9H9v-3H7v3zM4 4v2h2V4zm0 4v2h2V8zm4-4v2h1V4zm0 4v2h1V8zm3 0v2h1V8z'/%3E%3C/svg%3E"); }
.icon-percent { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='4' cy='4' r='2.5'/%3E%3Ccircle cx='12' cy='12' r='2.5'/%3E%3Cpath d='M12.6 2 14 3.4 3.4 14 2 12.6z'/%3E%3C/svg%3E"); }
.icon-calendar { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 1h2v2h6V1h2v2h2v12H1V3h2zm-0 5v7h10V6z'/%3E%3C/svg%3E"); }

/* filters and tables */
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: #fff; padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 14px; }
.filter-bar label, form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filter-bar label.grow { flex: 1 1 220px; }
.filter-bar label.check { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 8px; }
.filter-bar label.client-tint select { border-color: var(--client); }
input, select, textarea { font: inherit; color: var(--ink); padding: 7px 9px; border: 1px solid #C9CED6; border-radius: 6px; background: #fff; }
textarea { width: 100%; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.count { margin: 10px 12px; font-size: 13px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #FAFBFC; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid .th-client { background: var(--client-wash); color: var(--client); box-shadow: inset 0 3px 0 var(--client); }
.grid .th-cand { background: var(--cand-wash); color: var(--cand); box-shadow: inset 0 3px 0 var(--cand); }
.grid .td-client { background: var(--client-tint); }
.grid .td-cand { background: var(--cand-tint); font-weight: 500; }
.num { text-align: right; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.actions { white-space: nowrap; display: flex; gap: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; margin-top: 3px; }

/* buttons and pills */
.btn { display: inline-block; font: inherit; font-size: 14px; padding: 7px 12px; border-radius: 6px; border: 1px solid #C9CED6; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--primary); }
.btn-small { font-size: 13px; padding: 4px 9px; }
.btn-main { background: var(--main-action); border-color: var(--main-action); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.link { background: none; border: 0; color: var(--primary); text-decoration: underline; cursor: pointer; font: inherit; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #EEF0F3; color: var(--ink); white-space: nowrap; }
.pill-ok { background: var(--ok-wash); color: var(--ok); }
.pill-danger { background: var(--danger-wash); color: var(--danger); }
.pill-muted { background: #F1F2F4; color: var(--muted); }

/* panels: every panel belongs to one side (accent line, white line, wash header with icon and label) */
.panel { background: #fff; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.panel-cand { border-top: 4px solid var(--cand); }
.panel-client { border-top: 4px solid var(--client); background: var(--client-tint); }
.side-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 2px solid #fff; }
.side-header h2 { margin: 0 0 0 6px; font-size: 16px; color: var(--ink); }
.side-cand { background: var(--cand-wash); color: var(--cand); }
.side-client { background: var(--client-wash); color: var(--client); }
.side-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.panel-body { padding: 14px; }
.panel-body h3 { font-size: 15px; margin: 18px 0 8px; }
.two-sides { display: grid; grid-template-columns: 1fr 7px 1fr; gap: 0 10px; align-items: start; }
.divider { align-self: stretch; border-left: 1px solid var(--divider-line); border-right: 1px solid var(--divider-line); }
.back { display: inline-block; margin-bottom: 12px; color: var(--primary); }
dl.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 16px; margin: 0; }
.field dt { font-size: 12px; color: var(--muted); }
.field dd { margin: 2px 0 0; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.trail { padding-left: 18px; margin: 0; display: grid; gap: 4px; font-size: 14px; }
.trail .when { font-variant-numeric: tabular-nums; color: var(--muted); }
.booking { border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin: 10px 0; background: var(--cand-tint); }
.booking header { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-weight: 600; }
.booking-blocked { background: #fff; border-style: dashed; }
.notice { padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.notice h3 { margin: 0 0 6px; }
.notice-danger { background: var(--danger-wash); border-color: #FCA5A5; color: #7F1D1D; }
.notice-ok { background: var(--ok-wash); border-color: #86EFAC; color: #14532D; }
.notice-override { background: #FFF7ED; border-color: #FDBA74; color: #7C2D12; margin-top: 8px; }
.notice-sandbox { background: #F3F4F6; color: #374151; font-size: 13px; }
.override { margin-top: 14px; display: grid; gap: 8px; }

/* dialog */
dialog { border: 0; padding: 0; background: transparent; width: min(1100px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(17 24 39 / .45); }
.dialog { max-height: calc(100vh - 64px); overflow: auto; }
.dialog-body { margin-top: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* sign-in */
#signin-view { display: grid; place-items: center; min-height: calc(100vh - 30px); padding: 16px; }
.signin-card { background: #fff; padding: 24px; border-radius: 10px; border: 1px solid var(--line); width: min(380px, 100%); display: grid; gap: 12px; }
.signin-card h1 { margin: 0; font-size: 22px; }

/* phones: columns stack */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
  .brand { margin: 0; padding: 6px 10px; }
  .menu { display: flex; gap: 4px; }
  main { padding: 14px 16px; }
  .topbar { padding: 10px 16px; }
  .two-sides { grid-template-columns: 1fr; gap: 12px; }
  .divider { border-left: 0; border-right: 0; border-top: 1px solid var(--divider-line); border-bottom: 1px solid var(--divider-line); height: 4px; }
}

/* statutory rates */
.rates-grid h3 { margin: 20px 0 8px; }
.admin-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.admin-form .wide { grid-column: 1 / -1; }
details.history summary { cursor: pointer; margin: 16px 0 8px; font-weight: 600; }
