:root {
  color-scheme: light;
  --ink: #1f2a2e;
  --muted: #657176;
  --line: #d9e0df;
  --panel: #ffffff;
  --bg: #f3f7f5;
  --accent: #f6b21a;
  --accent-dark: #674500;
  --green: #176b5a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
}

.app-layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #102c25;
  color: #f5faf8;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 18px;
}

.brand-block h1 {
  color: #fff;
  font-size: 26px;
}

.sidebar .eyebrow,
.sidebar label {
  color: #b8d1c8;
}

.sidebar select {
  background: #183a32;
  border-color: #2f5a50;
  color: #fff;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.side-tab {
  background: transparent;
  border-color: transparent;
  color: #d7e8e2;
  justify-content: flex-start;
  text-align: left;
}

.side-tab.active,
.side-tab:hover {
  background: #f6b21a;
  border-color: #f6b21a;
  color: #312300;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
}

.sidebar-footer span {
  color: #d7e8e2;
  font-size: 13px;
  font-weight: 700;
}

.main-area {
  min-width: 0;
  padding: 28px;
}

.hidden {
  display: none !important;
}

.login-screen {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.login-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(31, 42, 46, 0.08);
  max-width: 420px;
  padding: 26px;
  width: 100%;
}

.login-panel h1 {
  margin-bottom: 18px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.eyebrow {
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 22px;
}

.actions,
.profile-editors {
  display: flex;
  gap: 8px;
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
  padding: 8px 13px;
}

button:hover {
  border-color: var(--green);
}

.workspace {
  display: block;
}

.date-pill {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 12px;
}

.profile-editors {
  align-items: flex-start;
  margin-bottom: 14px;
}

.profile-editors details {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  flex: 1 1 0;
  padding: 12px 14px;
}

.profile-editors summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.profile-editors .grid {
  margin-top: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: none;
  padding: 22px;
}

.panel.active {
  display: block;
}

.section-head {
  border-bottom: 4px solid var(--accent);
  margin-bottom: 18px;
  padding-bottom: 12px;
}

.section-head p {
  color: var(--muted);
  margin: 6px 0 0;
}

h3 {
  font-size: 17px;
  letter-spacing: 0;
  margin: 0 0 14px;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric span {
  display: block;
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 6px;
}

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

.quick-actions {
  display: flex;
  gap: 8px;
}

.quick-actions button {
  font-weight: 800;
}

.quick-actions .form-action {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.quick-actions .patient-action {
  background: #fff;
  border-color: var(--green);
  color: var(--green);
}

.split-view,
.settings-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.split-view aside,
.settings-grid aside {
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.settings-note {
  background: #f8fbfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 14px;
  padding: 12px;
}

.settings-block {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.signature-uploader {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 14px;
}

.signature-draw {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.signature-draw span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.signature-draw canvas {
  background: #fff;
  border: 1px solid #bfc9c7;
  border-radius: 6px;
  height: 130px;
  touch-action: none;
  width: 100%;
}

.signature-preview {
  align-items: center;
  background: #fff;
  border: 1px dashed #bfc9c7;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
  min-height: 86px;
  padding: 10px;
}

.signature-preview img {
  display: block;
  max-height: 64px;
  max-width: 100%;
  object-fit: contain;
}

.signature-preview span {
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.form-patient-picker {
  margin-bottom: 18px;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  color: var(--muted);
  display: grid;
  font-size: 14px;
  font-weight: 700;
  gap: 6px;
  margin-bottom: 14px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid #bfc9c7;
  border-radius: 6px;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 800;
  margin-top: 4px;
}

.result {
  color: var(--green);
  font-weight: 700;
  margin: 14px 0 0;
}

.result a {
  color: var(--green);
}

.capacity-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(560px, 1.35fr) minmax(360px, 1fr);
  align-items: start;
  margin: 6px 0 18px;
  overflow-x: auto;
}

.capacity-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  overflow: hidden;
}

.capacity-table.physical {
  grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(112px, 0.8fr));
  min-width: 620px;
}

.capacity-table.mental {
  align-self: start;
  grid-template-columns: minmax(210px, 1fr) repeat(2, minmax(120px, 0.75fr));
  min-width: 470px;
}

.capacity-table > * {
  align-items: center;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  display: flex;
  min-height: 36px;
  padding: 7px 9px;
}

.capacity-table.physical > :nth-last-child(-n + 4) {
  border-bottom: 0;
}

.capacity-table.mental > :nth-last-child(-n + 3) {
  border-bottom: 0;
}

.capacity-table.physical > :nth-child(4n),
.capacity-table.mental > :nth-child(3n) {
  border-right: 0;
}

.capacity-table label {
  justify-content: center;
  margin: 0;
  padding: 0;
}

.capacity-table input {
  height: 18px;
  min-height: 18px;
  width: 18px;
}

.cap-head {
  background: #eaf0ee;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item,
.list-item {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.history-item span,
.list-item span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 4px;
}

.history-item a,
.result a {
  color: var(--green);
  font-weight: 800;
}

.empty {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 780px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .main-area {
    padding: 16px;
  }

  .topbar,
  .top-actions,
  .actions,
  .profile-editors,
  .quick-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .two,
  .three,
  .capacity-grid,
  .metric-grid,
  .split-view,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .split-view aside,
  .settings-grid aside {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 18px;
  }

  .capacity-table.physical {
    grid-template-columns: minmax(180px, 1fr) repeat(3, minmax(112px, 0.8fr));
  }

  .capacity-table.mental {
    grid-template-columns: minmax(210px, 1fr) repeat(2, minmax(120px, 0.75fr));
  }
}
