:root {
  --canvas: #F2F6F5;
  --surface: #FFFFFF;
  --surface-2: #EAF1EF;
  --ink: #1E2E2B;
  --muted: #6E817C;
  --line: #DDE7E4;
  --sage: #4F8A7B;
  --sage-soft: #E2EFEB;
  --clay: #CE8A66;
  --clay-soft: #F6E7DE;
  --gold: #C9A24B;
  --alert: #C2503C;
  --radius: 10px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Mulish', system-ui, sans-serif;
}

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

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

h1, h2, h3, .brand {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.3;
}

h1 {
  font-size: 32px;
  margin-bottom: 16px;
}

h2 {
  font-size: 24px;
  margin-bottom: 12px;
}

h3 {
  font-size: 20px;
  margin-bottom: 10px;
}

.sidebar {
  background: var(--surface);
  width: 240px;
  border-right: 1px solid var(--line);
  padding: 24px 0;
  flex-shrink: 0;
}

.brand {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  padding: 0 20px 24px;
  position: relative;
}

.brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--sage);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

nav {
  display: flex;
  flex-direction: column;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 10px 20px;
  margin: 2px 12px;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  font-weight: 500;
}

.nav-link:hover {
  background: var(--sage-soft);
  color: var(--ink);
}

.nav-link.active {
  background: var(--sage-soft);
  color: var(--sage);
}

.main {
  flex: 1;
  padding: 28px 32px;
  overflow-x: auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(31, 60, 55, 0.06);
  margin-bottom: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

table {
  width: 100%;
  background: var(--surface);
  border-collapse: collapse;
  border-radius: var(--radius);
  overflow: hidden;
}

thead {
  background: var(--surface);
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody td {
  padding: 14px 16px;
  color: var(--ink);
}

input,
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  width: 100%;
  transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--sage);
  outline-offset: 0;
  border-color: var(--sage);
}

textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

button,
.btn {
  background: var(--sage);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
  text-decoration: none;
}

button:hover,
.btn:hover {
  background: #3d6e61;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(79, 138, 123, 0.25);
}

button:active,
.btn:active {
  transform: translateY(0);
}

.btn-2 {
  background: transparent;
  color: var(--clay);
  border: 1.5px solid var(--clay);
  border-radius: var(--radius);
  padding: 9px 20px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
  text-decoration: none;
}

.btn-2:hover {
  background: var(--clay-soft);
  transform: translateY(-1px);
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.prac-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.day-calendar {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.day-calendar .prac-column {
  min-width: 220px;
  flex-shrink: 0;
}

.day-calendar .prac-header {
  font-weight: 600;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  display: flex;
  align-items: center;
}

.day-calendar .time-slots {
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  padding: 8px;
}

.appt-block {
  background: var(--sage-soft);
  border-left: 3px solid var(--sage);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.4;
}

.appt-block .time {
  font-weight: 600;
  color: var(--sage);
  font-size: 13px;
}

.appt-block .patient {
  color: var(--ink);
}

.appt-block.clay {
  background: var(--clay-soft);
  border-left-color: var(--clay);
}

.appt-block.clay .time {
  color: var(--clay);
}

.slot-free {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.slot-free:hover {
  background: var(--surface-2);
  border-color: var(--sage);
  color: var(--sage);
}

.note-entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
  padding-left: 24px;
}

.note-entry::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 20px;
  width: 6px;
  height: 6px;
  background: var(--sage);
  border-radius: 50%;
}

.note-entry .note-meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.note-entry .note-content {
  color: var(--ink);
  line-height: 1.6;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pill-booked {
  background: var(--sage-soft);
  color: var(--sage);
}

.pill-arrived {
  background: var(--clay-soft);
  color: var(--clay);
}

.pill-completed {
  background: #F5EFD5;
  color: var(--gold);
}

.pill-cancelled {
  background: var(--surface-2);
  color: var(--muted);
}

.pill-no_show {
  background: #F7E3DF;
  color: var(--alert);
}

:focus-visible {
  outline: 2px solid var(--sage);
  outline-offset: 2px;
}

/* polish v2 — grammar over the existing tinted canvas */
.page-head{ display:flex; align-items:flex-end; justify-content:space-between; gap:1rem;
  margin-bottom:1.5rem; padding-bottom:1rem; border-bottom:1px solid var(--line); flex-wrap:wrap; }
.page-head h1{ margin:0; }
.eyebrow{ text-transform:uppercase; letter-spacing:.16em; font-size:.7rem; font-weight:700;
  color:var(--sage); font-family:var(--font-body); margin-bottom:.4rem; }

.stats{ display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:16px; margin-bottom:20px; }
.stat{ background:var(--surface); border:1px solid var(--line); border-left:4px solid var(--sage);
  border-radius:var(--radius); padding:18px 20px; box-shadow:0 1px 3px rgba(31,60,55,.06);
  transition:transform .15s ease, box-shadow .15s ease; }
.stat:hover{ transform:translateY(-2px); box-shadow:0 6px 18px rgba(31,60,55,.10); }
.stat.is-clay{ border-left-color:var(--clay); }
.stat.is-gold{ border-left-color:var(--gold); }
.stat.is-alert{ border-left-color:var(--alert); }
.stat-value{ font-family:var(--font-display); font-size:2.2rem; font-weight:600; line-height:1; color:var(--ink); }
.stat.is-alert .stat-value{ color:var(--alert); }
.stat-label{ font-size:.72rem; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); margin-top:10px; }
.stat-sub{ font-size:.78rem; color:var(--muted); margin-top:5px; }

.prac-load{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:1.25rem; }
.load-chip{ display:inline-flex; align-items:center; gap:7px; background:var(--surface-2);
  border:1px solid var(--line); border-radius:999px; padding:5px 12px; font-size:13px; font-weight:600; }
.load-chip .count{ color:var(--sage); font-weight:700; }

.agenda{ display:flex; flex-direction:column; gap:8px; }
.agenda-row{ display:flex; align-items:center; gap:14px; padding:12px 14px; background:var(--surface-2);
  border-radius:var(--radius); border-left:4px solid var(--sage); }
.agenda-time{ font-weight:700; min-width:74px; color:var(--ink); }
.agenda-prac{ display:flex; align-items:center; gap:6px; color:var(--muted); font-size:14px; }
.agenda-row .pill{ margin-left:auto; }

.row-actions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.row-actions form{ display:inline; margin:0; }
.activity-feed{ display:flex; flex-direction:column; }
.activity-row{ display:flex; justify-content:space-between; gap:1rem; padding:.55rem 0; border-bottom:1px solid var(--line); }
.activity-row:last-child{ border-bottom:none; }
.activity-when{ font-size:.85rem; color:var(--muted); white-space:nowrap; }

@media (max-width: 820px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 16px 0;
  }

  .brand {
    padding: 0 16px 12px;
    font-size: 20px;
  }

  nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 0 4px;
  }

  .nav-link {
    white-space: nowrap;
    margin: 0 4px;
  }

  .main {
    padding: 20px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* records page + stacked form grammar */
.count-badge{ display:inline-block; background:var(--sage-soft); color:var(--sage);
  font-size:.75rem; font-weight:700; padding:5px 12px; border-radius:999px; }
.records-layout{ display:grid; grid-template-columns:420px 1fr; gap:20px; align-items:start; }
.records-layout > .card{ margin-bottom:0; }
.field-grid{ display:grid; grid-template-columns:1fr 1fr; gap:0 16px; }
.card form label{ display:block; margin-bottom:16px; font-weight:600; font-size:14px; color:var(--ink); }
.card form label input, .card form label select, .card form label textarea{ margin-top:6px; font-weight:400; }
.patient-name{ display:inline-flex; align-items:center; gap:10px; color:var(--sage); font-weight:600; text-decoration:none; }
.patient-name:hover{ text-decoration:underline; }
.avatar{ display:inline-flex; align-items:center; justify-content:center; width:30px; height:30px;
  border-radius:50%; background:var(--sage-soft); color:var(--sage); font-size:12px; font-weight:700; flex-shrink:0; }
@media (max-width: 820px){
  .records-layout{ grid-template-columns:1fr; }
  .field-grid{ grid-template-columns:1fr; }
}
