/* Tokens from DESIGN.md. Colours and spacing live only here. */
:root {
  --ink: #141414;
  --paper: #FAFAF7;
  --accent: #1F6F5C;
  --muted: #6B6B66;
  --line: #E4E3DD;
  --danger: #B42318;
  --white: #fff;

  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 40px; --s6: 48px; --s8: 64px;

  --font-display: "Bricolage Grotesque", sans-serif;
  --font-body: "Instrument Sans", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s1);
  padding: var(--s2);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--font-display); font-weight: 800; color: var(--ink); text-decoration: none; }
nav a { margin-left: var(--s2); color: var(--muted); text-decoration: none; }
nav a:hover, nav a.active { color: var(--ink); }

/* Profile dropdown */
.menu { position: relative; display: inline-block; margin-left: var(--s2); }
.menu-toggle { background: none; border: none; border-radius: 0; color: var(--muted); padding: 0; font-weight: 400; }
.menu-toggle:hover, .menu-toggle.active, .menu-toggle[aria-expanded="true"] { color: var(--ink); }
.menu-panel {
  position: absolute; right: 0; top: 100%; margin-top: var(--s1); z-index: 10;
  min-width: 200px; display: grid; background: var(--white); border: 1px solid var(--line); padding: var(--s1) 0;
}
.menu-panel a, .menu-panel button {
  display: block; width: 100%; text-align: left; margin: 0; padding: var(--s1) var(--s2);
  background: none; border: none; border-radius: 0; color: var(--ink); font: inherit; text-decoration: none; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--paper); }

/* Layout and type: in-app ladder 16 / 24 / 32 */
main { max-width: 760px; margin: 0 auto; padding: var(--s3) var(--s2); }
h1 { font-family: var(--font-display); font-weight: 800; font-size: 32px; line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 var(--s2); }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1.2; margin: var(--s4) 0 var(--s2); }
a { color: var(--ink); }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0; min-height: 24px; }

/* Forms */
form { display: grid; gap: var(--s2); }
label { display: grid; gap: var(--s1); color: var(--muted); }
input, select, textarea {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--white);
  padding: var(--s1);
  border: 1px solid var(--ink);
  border-radius: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
input:disabled { background: var(--paper); color: var(--muted); border-color: var(--line); }

/* Buttons: primary is the accent; secondary and danger are outlined */
button, a.button {
  font: inherit;
  font-weight: 700;
  display: inline-block;
  padding: var(--s1) var(--s2);
  border: 1px solid var(--accent);
  border-radius: 0;
  background: var(--accent);
  color: var(--white);
  cursor: pointer;
  text-decoration: none;
}
button:disabled { opacity: 0.4; cursor: default; }
button.secondary, a.button.secondary { background: transparent; color: var(--ink); border-color: var(--ink); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; color: var(--muted); padding: 0; font-weight: 400; }

/* Layout blocks */
.narrow { max-width: 360px; margin: var(--s6) auto; }
.card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  padding: var(--s2);
  margin-bottom: var(--s1);
}
.card strong { font-weight: 700; }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--s1); }

/* Status badge: small uppercase label, square */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 var(--s1);
  margin-left: var(--s1);
  border: 1px solid var(--line);
  color: var(--muted);
  vertical-align: middle;
  white-space: nowrap;
}

/* Time slots: mono, booked ones struck through, selected in the accent */
.slots { display: flex; flex-wrap: wrap; gap: var(--s1); margin: var(--s1) 0 var(--s2); }
.slot {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 400;
  padding: var(--s1) var(--s2);
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
}
.slot.selected { background: var(--accent); border-color: var(--accent); color: var(--white); }
.slot:disabled { background: var(--paper); color: var(--muted); text-decoration: line-through; opacity: 1; }

.picked { font-family: var(--font-mono); font-size: 16px; margin: var(--s1) 0; }

/* Calendar (Day / Week / Month) */
.cal-tabs { display: flex; gap: var(--s3); border-bottom: 1px solid var(--line); margin-bottom: var(--s2); }
.cal-tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--muted); padding: var(--s1) 0; margin-bottom: -1px; font-weight: 400;
}
.cal-tabs button.active { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); margin-bottom: var(--s2); }
.cal-nav { display: flex; gap: var(--s1); }
.cal-nav button { background: var(--white); color: var(--ink); border-color: var(--line); height: var(--s4); padding: 0 var(--s2); font-size: 14px; }
.cal-nav button:first-child, .cal-nav button:last-child { padding: 0 var(--s1); }
.cal-title { margin: 0; font-size: 20px; flex: 1; min-width: 160px; }
.is-today .cal-head, .is-today.cal-cell .cell-date { color: var(--accent); font-weight: 700; }

.cal-day, .cal-col, .cal-cell { border: 1px solid var(--line); background: var(--white); }
.cal-day { padding: var(--s2); }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s1); }
.cal-col { padding: var(--s1); min-height: 160px; }
.cal-head { font-weight: 700; padding-bottom: var(--s1); border-bottom: 1px solid var(--line); margin-bottom: var(--s1); }
.event, .open-time { font-size: 14px; padding: var(--s1); margin-bottom: var(--s1); }
.event { border-left: 3px solid var(--accent); background: var(--paper); }
.event span { display: block; }
.event.is-closed { opacity: 0.5; }
.event, .open-time, .cell-item { cursor: pointer; }

/* Appointment popup */
dialog { border: 1px solid var(--line); border-radius: 0; padding: var(--s3); width: min(520px, calc(100% - 32px)); background: var(--white); color: var(--ink); }
dialog::backdrop { background: rgba(20, 20, 20, 0.35); }
dialog .card { margin-bottom: 0; border: none; padding: 0; }
.dialog-foot { display: flex; justify-content: flex-end; margin-top: var(--s2); }
.open-time { border: 1px dashed var(--muted); color: var(--muted); }
.open-time:hover { border-color: var(--accent); color: var(--accent); }
.event.internal { background: var(--ink); border-left: none; color: var(--white); }
.amount-row { display: flex; align-items: center; gap: var(--s1); }
.amount-row input { flex: 1; min-width: 0; }
input:disabled, select:disabled { opacity: 0.5; }
label.check { display: flex; align-items: center; gap: var(--s1); color: var(--ink); }
label.check input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.admin-box { display: grid; gap: var(--s2); border: 1px solid var(--line); margin: 0; padding: var(--s2); }
.admin-box legend { color: var(--muted); padding: 0 var(--s1); }
.repeat { display: grid; gap: var(--s1); border: 1px solid var(--line); margin: 0; padding: var(--s1) var(--s2); }
.repeat legend { color: var(--muted); padding: 0 var(--s1); }
.repeat label { display: flex; align-items: center; gap: var(--s1); color: var(--ink); }
.repeat input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.event.internal .muted { color: #c9c9c4; }

.cal-month-head, .cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0; }
.cal-month-head span { font-size: 12px; color: var(--muted); padding: var(--s1); }
.cal-cell {
  text-align: left; font: inherit; color: var(--ink); min-height: 96px; padding: var(--s1);
  margin: 0 -1px -1px 0; cursor: pointer; display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.cal-cell.outside { color: var(--muted); background: var(--paper); }
.cell-date { font-weight: 700; }
.cell-item { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 700px) {
  .cal-week { grid-template-columns: 1fr; }
  .cal-col { min-height: 0; }
  .cal-cell { min-height: 64px; }
  .cal-title { font-size: 18px; }
}

.day { justify-content: flex-start; }
.day label { color: var(--ink); display: flex; align-items: center; gap: var(--s1); min-width: 136px; }
.day input[type="time"] { width: 120px; }
.reschedule { margin-top: var(--s2); width: 100%; }
.filter { max-width: 280px; margin-bottom: var(--s2); }

/* Organization chooser: chips for selected organizations, search below */
.field-group { display: grid; gap: var(--s1); }
.field-group .label { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s1); margin-bottom: var(--s1); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s1);
  padding: 0 var(--s1); border: 1px solid var(--accent); color: var(--ink);
}
.chip button.link { color: var(--ink); font-size: 16px; line-height: 1; }
.org-results { display: grid; gap: var(--s1); margin-top: var(--s1); }
.result {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s2);
  padding: var(--s1) var(--s2); border: 1px solid var(--line); background: var(--white);
}
input[type="search"] { width: 100%; }

@media (max-width: 480px) {
  header { padding: var(--s1) var(--s2); }
  nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); width: 100%; }
  nav a { margin-left: 0; }
  .menu { margin-left: auto; }
  main { padding: var(--s3) var(--s2); }
  .day input[type="time"] { width: 100%; }
}
