:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f0f4f8;
  --panel-3: #e7eef6;
  --text: #132238;
  --muted: #64748b;
  --line: #dce5ef;
  --primary: #0f8b8d;
  --primary-2: #1261a0;
  --good: #168a4a;
  --warn: #c98110;
  --bad: #d1495b;
  --info: #3f6fc7;
  --shadow: 0 10px 26px rgba(16, 31, 54, .08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1720;
  --panel: #17212c;
  --panel-2: #202c38;
  --panel-3: #263645;
  --text: #f3f7fb;
  --muted: #a7b4c4;
  --line: #304152;
  --primary: #2bc7b8;
  --primary-2: #7fb5ff;
  --good: #4fc17b;
  --warn: #f2b950;
  --bad: #ff6b7e;
  --info: #8fb3ff;
  --shadow: 0 10px 26px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.25; }
h2 { margin: 0 0 14px; font-size: 22px; }
img { max-width: 100%; }
p, td, th, .page-subtitle { overflow-wrap: anywhere; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.sidebar-toggle,
.mobile-sidebar-head {
  display: none;
}

.brand,
.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand { margin-bottom: 26px; }

.brand-logo,
.login-logo {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 4px 12px rgba(16, 31, 54, .08);
}

.login-logo {
  width: 68px;
  height: 68px;
}

.brand-title {
  font-size: 19px;
  font-weight: 800;
}

.brand-subtitle,
.page-subtitle,
.stat-label {
  color: var(--muted);
}

.brand-subtitle { font-size: 13px; margin-top: 1px; }

.nav-section {
  margin: 22px 10px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 650;
}

.nav-link:hover,
.nav-link.active {
  background: var(--panel-2);
  color: var(--text);
}

.nav-link.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-nav {
  min-width: 0;
}

.icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--primary-2);
  font-size: 13px;
  font-weight: 900;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.page-title {
  margin: 0;
  font-size: 30px;
  font-weight: 850;
}

.page-subtitle { margin-top: 5px; }

.toolbar {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.toolbar.space-between {
  justify-content: space-between;
}

.button,
button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.toolbar form {
  min-width: 0;
}

.button:hover,
button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(15, 139, 141, .18);
}

.button.secondary,
button.secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

.button.warn { background: var(--warn); color: #151515; }

.grid { display: grid; gap: 14px; }
.stats-grid { grid-template-columns: repeat(6, minmax(140px, 1fr)); }
.two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.stat-label { font-size: 14px; font-weight: 750; }
.stat-value { font-size: 32px; font-weight: 900; margin-top: 6px; }
.stat-good { color: var(--good); }
.stat-warn { color: var(--warn); }
.stat-bad { color: var(--bad); }
.stat-info { color: var(--info); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  background: color-mix(in srgb, var(--panel-2) 70%, transparent);
}

tr:hover td { background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

td small,
td strong {
  display: block;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-weight: 850;
  font-size: 13px;
}

.badge.good { background: rgba(22, 138, 74, .13); color: var(--good); }
.badge.warn { background: rgba(201, 129, 16, .15); color: var(--warn); }
.badge.bad { background: rgba(209, 73, 91, .14); color: var(--bad); }
.badge.info { background: rgba(63, 111, 199, .14); color: var(--info); }

.form-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 750;
  min-width: 0;
}

input,
select {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
  max-width: 100%;
}

input:focus,
select:focus {
  outline: 3px solid rgba(15, 139, 141, .18);
  border-color: var(--primary);
}

.theme-toggle {
  display: inline-flex;
  gap: 5px;
  background: var(--panel-2);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.theme-toggle button {
  min-height: 34px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.theme-toggle button.active {
  background: var(--primary);
  color: #fff;
}

.chart {
  display: block;
  width: min(100%, 360px);
  height: auto;
  margin: 8px auto 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 54px;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

.bar-track,
.stacked-track {
  background: var(--panel-2);
  overflow: hidden;
  border-radius: 999px;
}

.bar-track { height: 14px; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; }

.stacked-bars { display: grid; gap: 10px; }
.stacked-row { display: grid; grid-template-columns: 46px 1fr 82px; gap: 10px; align-items: center; }
.stacked-track { display: flex; min-width: 200px; height: 20px; }
.stacked-segment { min-width: 2px; height: 100%; }
.stacked-segment.good { background: var(--good); }
.stacked-segment.warn { background: var(--warn); }
.stacked-segment.bad { background: var(--bad); }

.sparkline { width: 100%; height: 180px; }

.device-hero {
  display: grid;
  gap: 16px;
}

.device-hero-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
}

.device-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  gap: 10px;
}

.device-summary div,
.device-rule-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 12px;
}

.device-summary div {
  min-height: 74px;
}

.device-summary span,
.device-rule-grid span,
.device-note {
  color: var(--muted);
}

.device-summary span,
.device-summary strong,
.device-rule-grid strong,
.device-rule-grid span {
  display: block;
}

.device-summary strong {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1;
}

.device-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.device-rule-grid strong {
  margin-bottom: 5px;
}

.device-note {
  margin: 0;
  font-size: 14px;
}

.device-table {
  min-width: 1060px;
}

.device-table th:nth-child(1) { width: 24%; }
.device-table th:nth-child(2) { width: 16%; }
.device-table th:nth-child(3) { width: 20%; }
.device-table th:nth-child(4) { width: 9%; }
.device-table th:nth-child(5) { width: 11%; }
.device-table th:nth-child(6) { width: 20%; }

.device-identity span,
.device-identity small,
.device-status-cell small {
  display: block;
  color: var(--muted);
}

.device-badges,
.device-action-links {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.device-actions {
  display: grid;
  gap: 9px;
  min-width: 220px;
  align-content: start;
}

.device-status-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
  margin: 0;
}

.device-status-form select,
.device-status-form button {
  min-height: 38px;
  width: 100%;
}

.device-action-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.device-action-links .button {
  justify-content: center;
  text-align: center;
}

.device-action-links .button,
.device-edit-details summary,
.device-edit-form button {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 14px;
}

.device-edit-details {
  margin: 0;
}

.device-edit-details summary {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
  font-weight: 800;
  text-align: center;
}

.device-edit-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.heatmap { display: grid; grid-template-columns: repeat(7, minmax(38px, 1fr)); gap: 8px; }
.heat-cell {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  display: grid;
  align-content: space-between;
  background: var(--panel-2);
}
.heat-cell strong { font-size: 13px; }
.heat-cell span { font-size: 12px; color: var(--muted); }

.rank-row {
  display: grid;
  grid-template-columns: 44px 1fr 76px;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.table-link { color: var(--primary-2); font-weight: 900; text-decoration: underline; text-underline-offset: 3px; }
.risk-row { background: rgba(209, 73, 91, .06); }
.empty { color: var(--muted); text-align: center; padding: 26px 12px; }

.director-summary {
  display: grid;
  gap: 16px;
  box-shadow: none;
}

.director-summary-head,
.director-date-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.director-summary h2 {
  margin: 0;
  font-size: 30px;
}

.director-date-form {
  margin: 0;
}

.director-meta {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.director-meta span {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 800;
}

.director-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.director-compact {
  display: grid;
  gap: 14px;
}

.director-summary-compact {
  box-shadow: none;
}

.director-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.director-kpi-card {
  display: grid;
  min-height: 148px;
  align-content: center;
  gap: 6px;
  box-shadow: none;
}

.director-kpi-card span {
  color: var(--muted);
  font-size: 20px;
  font-weight: 900;
}

.director-kpi-card strong {
  font-size: clamp(48px, 6vw, 74px);
  line-height: 1;
  font-weight: 950;
}

.director-kpi-card small {
  color: var(--muted);
  font-weight: 850;
}

.director-kpi-card.present strong { color: var(--good); }
.director-kpi-card.late strong { color: var(--warn); }
.director-kpi-card.absent strong { color: var(--bad); }

.director-list-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.director-list-card {
  box-shadow: none;
}

.person-profile-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-top: 16px;
  box-shadow: none;
}

.person-photo {
  width: 104px;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  color: var(--primary-2);
  font-size: 42px;
  font-weight: 950;
  border: 1px solid var(--line);
}

.person-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.person-profile-card h2 {
  margin-bottom: 6px;
}

.person-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.person-meta span {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 800;
}

.director-status-card {
  padding: 0;
  overflow: hidden;
  box-shadow: none;
}

.director-status-card summary {
  min-height: 142px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr auto;
  column-gap: 10px;
  align-items: center;
  padding: 18px;
  cursor: pointer;
  list-style: none;
}

.director-status-card summary::-webkit-details-marker {
  display: none;
}

.director-status-card summary::after {
  content: "รายชื่อ";
  align-self: end;
  justify-self: start;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.director-status-card[open] summary::after {
  content: "ย่อ";
}

.director-status-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 20px;
  font-weight: 900;
}

.director-status-card summary strong {
  grid-row: 2;
  font-size: clamp(48px, 5vw, 66px);
  line-height: 1;
  font-weight: 950;
}

.director-status-card summary small {
  grid-row: 2;
  justify-self: start;
  color: var(--muted);
  font-size: 18px;
  font-weight: 850;
}

.director-status-card.present summary {
  background: color-mix(in srgb, var(--panel) 86%, rgba(22, 138, 74, .14));
}

.director-status-card.present summary strong {
  color: var(--good);
}

.director-status-card.absent summary {
  background: color-mix(in srgb, var(--panel) 86%, rgba(209, 73, 91, .15));
}

.director-status-card.absent summary strong {
  color: var(--bad);
}

.director-status-card.late summary {
  background: color-mix(in srgb, var(--panel) 86%, rgba(201, 129, 16, .16));
}

.director-status-card.late summary strong {
  color: var(--warn);
}

.director-status-body {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.director-name-list {
  display: grid;
  gap: 7px;
  max-height: min(54vh, 460px);
  overflow-y: auto;
  padding-right: 4px;
}

.director-person-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 6px 10px;
  align-items: center;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.director-person-row:hover {
  background: var(--panel-3);
}

.director-person-row strong {
  font-size: 15px;
  grid-row: span 2;
}

.director-person-row span {
  font-size: 16px;
  font-weight: 800;
  min-width: 0;
}

.director-person-row small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-2);
}

.director-day-row {
  display: grid;
  grid-template-columns: 54px 1fr 80px;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.director-day-row:hover {
  background: var(--panel-2);
}

.report-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.report-hero h2 {
  margin: 4px 0 0;
  font-size: 28px;
}

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

.help-step {
  display: grid;
  gap: 4px;
  box-shadow: none;
}

.help-step strong {
  font-size: 18px;
}

.help-step span {
  color: var(--muted);
}

.report-filter-card,
.report-kpis,
.report-calendar-kpis {
  margin-bottom: 14px;
}

.report-shortcuts {
  margin-bottom: 14px;
}

.report-filter-row {
  align-items: end;
}

.report-search {
  min-width: min(320px, 100%);
}

.people-profile-preview {
  display: block;
  width: 104px;
  height: 104px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.people-pagination button:disabled {
  opacity: .45;
  cursor: default;
}

.duty-day-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.duty-day-tab {
  display: grid;
  gap: 3px;
  min-height: 56px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-align: center;
  text-decoration: none;
}

.duty-day-tab small {
  color: var(--muted);
}

.duty-day-tab.active {
  border-color: var(--primary);
  background: rgba(15, 139, 141, .1);
  color: var(--primary);
}

.duty-roster-form {
  display: grid;
  gap: 14px;
}

.duty-roster-heading,
.duty-roster-pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.duty-roster-heading label {
  min-width: 150px;
}

.duty-roster-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.duty-roster-pane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.duty-roster-pane.selected {
  border-color: rgba(22, 138, 74, .62);
}

.duty-roster-pane-heading {
  min-height: 74px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.duty-roster-pane-heading h3 {
  margin-bottom: 3px;
}

.duty-roster-pane-heading input {
  width: min(240px, 100%);
}

.duty-roster-list {
  min-height: 320px;
  max-height: 520px;
  overflow-y: auto;
}

.duty-roster-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 7px 9px 7px 12px;
  border-bottom: 1px solid var(--line);
}

.duty-roster-row[hidden] {
  display: none;
}

.duty-roster-row:last-of-type {
  border-bottom: 0;
}

.duty-roster-row strong,
.duty-roster-row small {
  display: block;
}

.duty-roster-row small {
  color: var(--muted);
}

.duty-roster-action {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
}

.duty-roster-action.remove {
  border-color: rgba(209, 73, 91, .62);
  background: rgba(209, 73, 91, .1);
  color: var(--bad);
}

.duty-roster-empty {
  padding: 24px 12px;
}

.inline-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding-bottom: 2px;
}

.inline-check input,
.report-calendar-picker input {
  min-height: auto;
}

.report-details {
  margin-top: 14px;
}

.report-details > summary {
  cursor: pointer;
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
}

.report-details > summary::marker {
  color: var(--primary);
}

.report-details[open] > summary {
  margin-bottom: 10px;
}

.report-scroll-table {
  max-height: 520px;
  overflow: auto;
}

.report-scroll-table table {
  min-width: 900px;
}

.report-scroll-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.report-calendar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 2px;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  flex: 0 1 440px;
  width: 100%;
  min-width: 0;
  padding: 28px;
}

.login-brand > div {
  min-width: 0;
}

.login-card h1 {
  margin: 24px 0 18px;
  font-size: 30px;
}

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(209, 73, 91, .12);
  color: var(--bad);
  margin-bottom: 14px;
}

.signature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin-top: 48px; }
.signature-box { text-align: center; padding-top: 54px; border-top: 1px solid #222; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .main { padding: 20px; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar-toggle {
    display: inline-flex;
    position: sticky;
    z-index: 35;
    top: 10px;
    left: 10px;
    width: fit-content;
    margin: 10px 0 0 10px;
  }
  .mobile-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }
  .sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    left: 0;
    width: min(320px, 86vw);
    height: 100vh;
    transform: translateX(-104%);
    transition: transform .18s ease;
    padding: 16px;
    border-right: 1px solid var(--line);
    box-shadow: 0 18px 34px rgba(16, 31, 54, .22);
    overflow-y: auto;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .brand {
    margin-bottom: 10px;
  }
  .brand-logo {
    width: 42px;
    height: 42px;
  }
  .brand-title {
    font-size: 17px;
  }
  .sidebar-nav {
    display: grid;
    gap: 7px;
    overflow: visible;
    padding-bottom: 20px;
  }
  .nav-section {
    display: block;
  }
  .nav-link {
    min-height: 40px;
    padding: 6px 9px;
    border: 1px solid transparent;
  }
  .nav-link.active {
    border-color: color-mix(in srgb, var(--primary) 38%, var(--line));
    box-shadow: inset 0 -3px 0 var(--primary);
  }
  .icon {
    width: 25px;
    height: 25px;
  }
  .main { padding: 12px 16px 16px; }
  .topbar,
  .two-col {
    grid-template-columns: 1fr;
    display: grid;
  }
  .topbar {
    gap: 12px;
    margin-bottom: 16px;
  }
  .topbar-actions {
    justify-content: space-between;
  }
  .page-title {
    font-size: 27px;
  }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .card {
    padding: 15px;
  }
  .form-row > label {
    flex: 1 1 220px;
  }
  .table-wrap table {
    min-width: 620px;
  }
  .report-filter-row .report-search {
    flex-basis: 100%;
  }
  .report-hero .toolbar,
  .report-shortcuts {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
  }
  .report-hero .button,
  .report-shortcuts .button {
    flex: 0 0 auto;
  }
  .heatmap {
    grid-template-columns: repeat(4, minmax(58px, 1fr));
  }
  .director-status-grid {
    grid-template-columns: 1fr;
  }
  .director-kpi-grid,
  .director-list-grid {
    grid-template-columns: 1fr;
  }
  .director-kpi-card {
    min-height: 116px;
  }
  .person-profile-card {
    grid-template-columns: 82px minmax(0, 1fr);
  }
  .person-photo {
    width: 82px;
  }
  .director-status-card summary {
    min-height: 118px;
  }
  .report-help {
    grid-template-columns: 1fr;
  }
  .device-hero-head {
    display: grid;
  }
  .device-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .device-rule-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .sidebar {
    padding-inline: 12px;
  }
  .brand-subtitle {
    display: none;
  }
  .main {
    padding: 12px;
  }
  .stats-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 24px; }
  h2 {
    font-size: 20px;
  }
  .card {
    padding: 13px;
  }
  .toolbar,
  .form-row {
    gap: 8px;
  }
  .form-row {
    display: grid;
    align-items: stretch;
  }
  .form-row > *,
  .form-row > label,
  .form-row input,
  .form-row select,
  .form-row button,
  .form-row .button {
    width: 100%;
  }
  .topbar-actions > form:last-child,
  .topbar-actions > form:last-child button {
    width: 100%;
  }
  .button,
  button {
    min-height: 40px;
    padding: 9px 11px;
  }
  .stat-value {
    font-size: 28px;
  }
  .director-summary-head,
  .director-date-tools {
    display: grid;
    align-items: stretch;
  }
  .director-summary-head .button,
  .director-date-tools .button,
  .director-date-tools button {
    width: 100%;
  }
  .director-date-tools .toolbar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .director-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .director-kpi-card {
    min-height: 98px;
    padding: 10px;
  }
  .director-kpi-card span {
    font-size: 15px;
  }
  .director-kpi-card strong {
    font-size: 42px;
  }
  .director-status-card summary {
    min-height: 104px;
    padding: 14px;
  }
  .person-profile-card {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .person-photo {
    margin: 0 auto;
  }
  .person-meta {
    justify-content: center;
  }
  .director-person-row {
    grid-template-columns: 50px minmax(0, 1fr);
  }
  .table-wrap {
    margin-inline: -1px;
  }
  .table-wrap table {
    min-width: 560px;
  }
  .device-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .device-table {
    min-width: 860px;
  }
  .device-status-form {
    grid-template-columns: 1fr;
  }
  .device-status-form select,
  .device-status-form button,
  .device-action-links .button {
    width: 100%;
  }
  .inline-check {
    width: 100%;
  }
  .duty-day-tabs {
    display: flex;
    overflow-x: auto;
    padding-bottom: 3px;
  }
  .duty-day-tab {
    flex: 0 0 92px;
  }
  .duty-roster-heading,
  .duty-roster-pane-heading {
    align-items: stretch;
    flex-direction: column;
  }
  .duty-roster-columns {
    grid-template-columns: 1fr;
  }
  .duty-roster-pane-heading input {
    width: 100%;
  }
  .duty-roster-list {
    min-height: 220px;
    max-height: 360px;
  }
  .report-calendar-picker {
    display: grid;
    grid-template-columns: 1fr;
  }
  .heatmap {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .bar-row { grid-template-columns: 1fr; }
  .login-card {
    padding: 20px;
  }
  .login-brand {
    align-items: flex-start;
  }
}
