/* ============= Base layout ============= */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, Segoe UI, Roboto, Arial;
  background: #f3f6fb;
  color: #0f172a;
}

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: #0f172a;
  color: #fff;
  padding: 16px;
}
.brand { font-weight: 700; margin-bottom: 12px; }
.sidebar a {
  display: block;
  color: #c7e0ff;
  text-decoration: none;
  padding: 8px;
  border-radius: 8px;
}
.sidebar a:hover { background: #1e293b; }

/* Content area with smaller gutters */
:root{
  --sidebar-w: 220px;
  /* 5% of viewport each side, but never smaller than 12px or bigger than 64px */
  --gutter: clamp(12px, 5vw, 64px);
}

.content{
  margin-left: var(--sidebar-w);
  padding: 16px var(--gutter);
  min-height: 100%;
  /* ensure the inner width leaves gutters on both sides */
  width: calc(100vw - var(--sidebar-w) - (var(--gutter) * 2));
  max-width: none;
}
.page, .page-wrap, .page-content, .container, .wrap {
  max-width: none !important;
  width: 100%;
}

/* Headings */
h1, h2 { margin: 8px 0; }
h3 { margin: 10px 0 6px; }

/* ============= Tables ============= */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
th, td {
  border-top: 1px solid #eef1f5;
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}
th {
  background: #f6f8fb;
  font-weight: 600;
  letter-spacing: .2px;
}
tr:hover { background: #f9fbff; }

table.compact-rows td,
table.compact-rows th {
  padding: 6px 8px;
  line-height: 1.2;
}

.table-note-trim {
  max-width: 28ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #516173;
  font-size: .92em;
}

table.clickable-rows tr:hover {
  background: #f6f8fb;
  transition: background .15s ease-in-out;
}
.right { text-align: right; }

/* ---- Compact controls inside tables ---- */
table.compact-rows input,
table.compact-rows select {
  padding: 4px 8px;
  height: 30px;
  font-size: 13px;
  line-height: 1.2;
}
table.compact-rows .btn { padding: 6px 10px; }

/* Date input fixes */
table.compact-rows input[type="date"] {
  padding-block: 2px;
  width: 130px;
}
table.compact-rows input[type="date"]::-webkit-datetime-edit,
table.compact-rows input[type="date"]::-webkit-calendar-picker-indicator {
  margin: 0;
  padding: 0;
}

/* ---- Sticky table header on vertical scroll ---- */
.table-scroll-y {
  max-height: calc(100vh - 240px);
  overflow: auto;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.table-scroll-y table { margin: 0; border-radius: 0; box-shadow: none; }
.table-scroll-y thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f6f8fb;
  box-shadow: 0 1px 0 #eef1f5;
}

/* --- Compact Period column --- */
table.compact-rows th:nth-child(3),
table.compact-rows td:nth-child(3) {
  white-space: nowrap;
  width: 160px;
}
table.compact-rows td:nth-child(3) {
  font-size: 13px;
  color: #334155;
}
table.compact-rows td:nth-child(3) span {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  max-width: 150px;
  white-space: nowrap;
}

/* Align sessions + totals right */
table.compact-rows td:nth-child(4),
table.compact-rows td:nth-child(5) {
  text-align: right;
  width: 90px;
}

/* Optional: tighter global spacing */
table.compact-rows td, table.compact-rows th {
  padding: 6px 8px;
}

/* ============= Forms & Buttons ============= */
.form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 12px;
}
.form label { font-size: 12px; color: #334155; }
.form input, .form select, .form textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: 0;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.25);
}
.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.btn {
  padding: 8px 12px;
  border: 1px solid #0f172a;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
}
.btn.secondary {
  background: #eef2f7;
  color: #0f172a;
  border-color: #cbd5e1;
}
.btn.danger {
  background: #d7263d;
  border-color: #d7263d;
  color: #fff;
}
.small { font-size: .9em; color: #555; }

/* ============= Alerts ============= */
.alert { padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.ok { background: #e7f8ee; border: 1px solid #9adeb6; }
.err { background: #fde2e2; border: 1px solid #f5a3a3; }

/* ============= Intake & shared ============= */
.page-title {
  text-align: center;
  font-size: 2rem;
  color: #0f172a;
  margin: 0 0 18px;
}
.intake-form {
  max-width: 960px;
  margin: 24px auto;
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: 0 12px 30px rgba(2,6,23,.08);
}
.form-section { margin: 24px 0 28px; }
.form-section h3 {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg,#2563eb,#06b6d4);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 1.05rem;
  margin: 0 0 14px;
}
.intake-form label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  margin: 10px 12px 12px 0;
  color: #0f172a;
}
.intake-form input,
.intake-form textarea,
.intake-form select {
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: .95rem;
  background: #f8fafc;
  transition: border .15s, box-shadow .15s, background .15s;
}
.intake-form input:focus,
.intake-form textarea:focus,
.intake-form select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.2);
  outline: 0;
  background: #fff;
}
.intake-form textarea {
  resize: vertical;
  min-height: 84px;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px){
  :root{ --gutter: clamp(12px, 3.5vw, 32px); }
}
.form-actions { text-align: center; margin-top: 8px; }
.btn-primary {
  background: linear-gradient(90deg,#2563eb,#06b6d4);
  color: #fff;
  padding: 12px 22px;
  font-size: 1.05rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(2,6,23,.15);
  transition: transform .12s, box-shadow .12s;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(2,6,23,.18);
}

/* Service chips */
.services-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.service-chip { cursor: pointer; user-select: none; }
.service-chip input { display: none; }
.service-chip span {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 9999px;
  border: 2px solid #2563eb;
  background: #eef2ff;
  color: #1e3a8a;
  font-weight: 600;
  letter-spacing: .2px;
  transition: all .15s;
}
.service-chip:hover span { transform: translateY(-1px); }
.service-chip input:checked + span {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
  box-shadow: 0 6px 16px rgba(37,99,235,.24);
}

/* --- Sessions table visibility fixes --- */
.card { overflow: visible; }
.table-scroller { overflow-x: auto; overflow-y: visible; }
.tbl--sessions {
  min-width: 1100px;
  table-layout: auto;
  width: 100%;
}
.page, .page-wrap, .page-content {
  padding-bottom: 96px;
}
