:root {
  color-scheme: light;
  --bg: #f2f0ea;
  --bg-2: #e9e5da;
  --ink: #171c1a;
  --ink-2: #2e3835;
  --muted: #6d756f;
  --muted-2: #939a92;
  --surface: #fffcf6;
  --surface-2: #f8f4eb;
  --surface-3: #efe8dc;
  --elevated: #ffffff;
  --line: #ded6c8;
  --line-strong: #c5b9a6;
  --rail: #101917;
  --rail-2: #17231f;
  --rail-text: #f6efe3;
  --rail-muted: #9da79c;
  --primary: #123c35;
  --primary-2: #0c2d28;
  --accent: #a87538;
  --accent-2: #d6a85a;
  --danger: #a9352a;
  --warn: #9a6518;
  --ok: #257154;
  --focus: #d8a642;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow-soft: 0 18px 44px rgba(32, 37, 33, 0.11);
  --shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 12px 28px rgba(45, 38, 27, 0.08);
  --font: Aptos, "Segoe UI", "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(18, 60, 53, 0.04), transparent 28%),
    radial-gradient(circle at 82% 8%, rgba(168, 117, 56, 0.10), transparent 24rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

button,
input,
select,
textarea {
  border-radius: var(--radius-sm);
}

button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(#fffdf8, #f5efe5);
  color: var(--ink-2);
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 650;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

button:hover {
  border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 6px 14px rgba(46, 33, 15, 0.08);
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(216, 166, 66, 0.30);
  outline-offset: 2px;
  border-color: var(--focus);
}

button.primary {
  background: linear-gradient(180deg, #174b42, #0e332e);
  border-color: #0e332e;
  color: #fffaf0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.16) inset, 0 8px 18px rgba(18, 60, 53, 0.18);
}

button.primary:hover {
  background: linear-gradient(180deg, #1c5b50, #0d2f2a);
}

button.danger {
  color: var(--danger);
  border-color: #d6a49e;
}

button.small {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  padding: 8px 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

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

select[multiple] {
  min-height: 170px;
}

#roomCareAssignmentForm select[multiple] {
  min-height: 82px;
  padding: 4px 8px;
}

.room-assignment-table .assignment-summary {
  min-height: 32px;
  display: flex;
  align-items: center;
  line-height: 1.45;
  max-width: 100%;
}

.room-assignment-table .assignment-summary-text {
  overflow-wrap: anywhere;
}

.room-assignment-table tr:not(.editing) td {
  padding-block: 8px;
}

.room-assignment-table tr.editing td {
  vertical-align: top;
}

.top-nav-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.top-nav-shell .app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 10px clamp(16px, 2vw, 28px);
  background:
    linear-gradient(180deg, rgba(16, 25, 23, 0.98), rgba(23, 35, 31, 0.98));
  border-bottom: 1px solid rgba(214, 168, 90, 0.24);
  color: var(--rail-text);
  box-shadow: 0 10px 28px rgba(20, 18, 13, 0.16);
}

.app-header-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-brand {
  flex: 0 0 auto;
  min-width: 210px;
  padding: 0;
}

.top-brand strong {
  color: var(--rail-text);
}

.top-nav {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.top-nav button,
.top-nav summary,
.top-nav .nav-dropdown-trigger {
  width: auto;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #d8dfd8;
  box-shadow: none;
  list-style: none;
  cursor: pointer;
  font-weight: 720;
  white-space: nowrap;
}

.top-nav summary::-webkit-details-marker {
  display: none;
}

.top-nav summary::after {
  content: "▾";
  color: var(--accent-2);
  font-size: 10px;
}

.top-nav button:hover,
.top-nav summary:hover,
.top-nav .nav-dropdown-trigger:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.10);
  transform: none;
}

.top-nav button.active,
.top-nav summary.active,
.top-nav .nav-dropdown-trigger.active {
  background: rgba(214, 168, 90, 0.17);
  border-color: rgba(214, 168, 90, 0.36);
  color: #fff7e8;
}

.nav-dropdown {
  position: relative;
}

.nav-caret {
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 5px solid var(--accent-2);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  min-width: 210px;
  max-height: min(70vh, 520px);
  overflow: auto;
  display: grid;
  gap: 4px;
  padding: 8px;
  background: #17231f;
  border: 1px solid rgba(214, 168, 90, 0.24);
  border-radius: var(--radius);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

.nav-dropdown-menu button {
  width: 100%;
  justify-content: flex-start;
}

.nav-empty {
  padding: 8px 10px;
  color: var(--rail-muted);
  font-size: 12px;
}

.app-header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.top-userbar {
  margin: 0;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
}

.top-nav-shell .main {
  min-width: 0;
  padding-top: 22px;
}

.export-resident-picker select[multiple] {
  min-height: 124px;
}

.export-resident-picker .compact-actions {
  margin-top: -2px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--elevated);
}

.clinical-record-table {
  table-layout: fixed;
  min-width: 980px;
}

.clinical-record-table .col-time {
  width: 118px;
}

.clinical-record-table .col-bed {
  width: 74px;
}

.clinical-record-table .col-person {
  width: 170px;
}

.clinical-record-table .col-category {
  width: 150px;
}

.clinical-record-table .col-content {
  width: auto;
}

.clinical-record-table .col-followup {
  width: 150px;
}

.clinical-record-table .col-revision {
  width: 72px;
}

.clinical-record-table .col-actions {
  width: 76px;
}

.clinical-record-table th,
.clinical-record-table td {
  padding: 7px 9px;
}

.clinical-record-table th {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-strong);
}

.clinical-record-table .record-time,
.clinical-record-table .record-bed,
.clinical-record-table .record-category,
.clinical-record-table .record-followup,
.clinical-record-table .record-revision,
.clinical-record-table .record-actions {
  white-space: nowrap;
}

.clinical-record-table .record-time {
  white-space: pre-line;
  line-height: 1.35;
  font-size: 13px;
  font-weight: 700;
}

.clinical-record-table .record-person {
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 800;
}

.clinical-record-table .record-person .table-subtext {
  font-weight: 500;
}

.clinical-record-table .record-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.clinical-record-table .record-category {
  white-space: normal;
}

.clinical-record-table .record-category .pill {
  display: flex;
  width: fit-content;
  max-width: 100%;
  justify-content: flex-start;
  white-space: normal;
  text-align: left;
  overflow-wrap: anywhere;
  line-height: 1.35;
  margin-bottom: 4px;
}

.clinical-record-table .record-category .pill:last-child {
  margin-bottom: 0;
}

.follow-up-cell {
  display: grid;
  gap: 6px;
  align-items: start;
}

.follow-up-cell .follow-up-select {
  min-height: 30px;
  padding-block: 4px;
}

.follow-up-cell .follow-up-input-btn {
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #ebe4d9;
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #6b6256;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f3eee4;
}

td {
  color: #2a332f;
}

.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 520px);
  align-items: stretch;
  padding: 28px;
  gap: 18px;
}

.login-brief,
.login-panel {
  border: 1px solid rgba(197, 185, 166, 0.76);
  background: rgba(255, 252, 246, 0.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.login-brief {
  display: grid;
  align-content: end;
  min-height: calc(100vh - 56px);
  padding: clamp(28px, 5vw, 70px);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(16, 25, 23, 0.84), rgba(16, 25, 23, 0.94)),
    linear-gradient(135deg, rgba(214, 168, 90, 0.32), transparent);
  color: var(--rail-text);
}

.login-brief h1 {
  max-width: 780px;
  margin: 10px 0 12px;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.02;
  font-weight: 760;
}

.login-brief p {
  max-width: 580px;
  color: #d5d0c6;
  font-size: 16px;
}

.login-panel {
  align-self: center;
  padding: 30px;
  border-radius: 12px;
}

.login-panel h2 {
  margin: 4px 0 6px;
  font-size: 28px;
  line-height: 1.1;
}

.login-assurance {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.login-assurance span {
  border: 1px solid rgba(246, 239, 227, 0.20);
  background: rgba(255, 255, 255, 0.06);
  color: #f4ead8;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(214, 168, 90, 0.45);
  background: linear-gradient(145deg, #d6a85a, #7c5124);
  color: #fff7e9;
  border-radius: 7px;
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 34%),
    linear-gradient(180deg, var(--rail), var(--rail-2));
  color: var(--rail-text);
  padding: 16px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  padding: 6px 5px 18px;
}

.brand strong {
  font-size: 14px;
  line-height: 1.2;
  font-weight: 780;
}

.brand span:not(.brand-mark) {
  grid-column: 2;
  margin-top: -8px;
  color: var(--rail-muted);
  font-size: 11px;
}

.userbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin: 4px 2px 14px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
}

.userbar span {
  font-weight: 760;
}

.userbar small {
  color: var(--rail-muted);
  font-family: var(--mono);
  font-size: 11px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-section {
  margin: 13px 8px 5px;
  color: #7f8a82;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.nav button {
  width: 100%;
  justify-content: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid transparent;
  background: transparent;
  color: #cfd7cf;
  text-align: left;
  box-shadow: none;
}

.nav button:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  transform: none;
}

.nav button.active {
  background: linear-gradient(180deg, rgba(214, 168, 90, 0.18), rgba(214, 168, 90, 0.09));
  color: #fff5e5;
  border-color: rgba(214, 168, 90, 0.32);
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.main {
  min-width: 0;
  padding: 22px clamp(18px, 2.2vw, 34px) 34px;
  overflow: auto;
}

.topline {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin: -22px calc(clamp(18px, 2.2vw, 34px) * -1) 18px;
  padding: 18px clamp(18px, 2.2vw, 34px) 14px;
  background: rgba(242, 240, 234, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(197, 185, 166, 0.52);
}

.topline h1 {
  margin: 0 0 3px;
  color: var(--ink);
  font-size: 25px;
  line-height: 1.1;
  font-weight: 760;
}

.topline p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.topline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.panel {
  min-width: 0;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(248, 244, 235, 0.96));
  border: 1px solid rgba(197, 185, 166, 0.72);
  border-radius: var(--radius);
  padding: 15px;
  box-shadow: var(--shadow-panel);
}

.panel h2,
.panel h3 {
  margin: 0 0 11px;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.25;
  font-weight: 780;
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

.dashboard-grid {
  align-items: stretch;
}

.risk-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 96px;
  display: grid;
  align-content: space-between;
  gap: 6px;
  padding: 14px;
  border-top: 3px solid transparent;
}

.metric span,
.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metric strong {
  color: var(--ink);
  font-size: clamp(24px, 2.2vw, 34px);
  line-height: 1;
  font-weight: 780;
}

.metric small {
  color: var(--muted-2);
}

.metric.ok { border-top-color: var(--ok); }
.metric.warn { border-top-color: var(--warn); }
.metric.danger { border-top-color: var(--danger); }

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

.metric-card {
  min-height: 104px;
  display: grid;
  align-items: start;
  gap: 6px;
  text-align: left;
  background: linear-gradient(180deg, #fffdf8, #f6f0e6);
  border-color: rgba(197, 185, 166, 0.72);
}

.metric-card strong {
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.followup-card strong {
  font-size: 36px;
}

.followup-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.followup-card.has-pending {
  border-color: rgba(169, 53, 42, 0.42);
  background: linear-gradient(180deg, #fffaf7, #f8ede8);
}

.followup-card.has-pending strong {
  color: var(--danger);
}

.metric-label {
  display: flex;
  gap: 7px;
  align-items: center;
}

.metric-label i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

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

.form-grid .span-6 {
  grid-column: span 1;
}

.form-grid .span-12 {
  grid-column: 1 / -1;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(140px, 0.9fr) minmax(130px, 0.8fr) minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 9px;
  align-items: end;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.72);
  border-radius: var(--radius);
}

.table-actions {
  justify-content: space-between;
  margin-bottom: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  border: 1px solid var(--line);
  background: #f5efe5;
  color: var(--muted);
  white-space: nowrap;
}

.pill.ok {
  color: #15543c;
  border-color: rgba(37, 113, 84, 0.32);
  background: #e6f1eb;
}

.pill.warn {
  color: #74480c;
  border-color: rgba(154, 101, 24, 0.34);
  background: #f7ecd6;
}

.pill.danger {
  color: #7d241d;
  border-color: rgba(169, 53, 42, 0.32);
  background: #f6e5e2;
}

.notice {
  border: 1px solid #e3ca91;
  border-left: 4px solid var(--focus);
  background: #fff5df;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: #5b4210;
  font-size: 13px;
}

.error-summary {
  border: 1px solid rgba(169, 53, 42, 0.36);
  background: #fff3f1;
  color: var(--danger);
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.error-summary ul {
  margin: 7px 0 0;
  padding-left: 20px;
}

.preview-box {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.74);
  border-radius: var(--radius);
  padding: 13px;
  margin-top: 13px;
  display: grid;
  gap: 8px;
}

.preview-box h3,
.preview-box p {
  margin: 0;
}

.danger-text { color: var(--danger); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.resident-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin: 12px 0;
  max-height: 46vh;
  overflow: auto;
  padding-right: 4px;
}

.batch-console .panel {
  align-self: start;
}

.floor-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 8px;
  margin: 8px 0 14px;
}

.floor-strip button {
  display: grid;
  gap: 2px;
  justify-items: start;
  min-height: 54px;
}

.floor-strip button span {
  color: inherit;
  opacity: 0.72;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
  max-height: 38vh;
  overflow: auto;
  padding-right: 4px;
}

.room-card {
  display: grid;
  gap: 4px;
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.room-card input {
  width: auto;
}

.room-card strong {
  color: var(--ink);
  font-size: 15px;
}

.room-card span {
  color: var(--muted);
  font-size: 12px;
}

.room-card.selected {
  border-color: rgba(18, 60, 53, 0.44);
  background: #eef6f1;
  box-shadow: 0 0 0 2px rgba(18, 60, 53, 0.08) inset;
}

.selection-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.selection-summary span {
  display: grid;
  gap: 2px;
  min-height: 56px;
  padding: 9px;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
}

.selection-summary strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.resident-picker {
  display: grid;
  gap: 8px;
  max-height: 60vh;
  overflow: auto;
  padding-right: 4px;
}

.resident-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 9px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: var(--radius-sm);
  color: var(--ink);
}

.resident-picker .resident-row:has(input[type="checkbox"]:not(:checked)) {
  background: #f5ecd9;
  border-color: #dfc994;
}

.batch-review-page {
  align-items: start;
}

.batch-review-sticky {
  position: sticky;
  top: 0;
  z-index: 20;
}

.batch-review-actions {
  margin-top: 10px;
}

.compact-summary {
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  min-width: 220px;
  margin-bottom: 0;
}

.compact-summary span {
  min-height: 44px;
  padding: 7px 9px;
}

.compact-summary strong {
  font-size: 18px;
}

.batch-review-form {
  padding: 0;
  overflow: hidden;
}

.batch-review-table-wrap {
  max-height: calc(100vh - 260px);
}

.batch-review-table {
  min-width: 1180px;
}

.batch-review-table .col-include { width: 58px; }
.batch-review-table .col-bed { width: 92px; }
.batch-review-table .col-person { width: 112px; }
.batch-review-table .col-room { width: 88px; }
.batch-review-table .col-responsibility { width: 190px; }
.batch-review-table .col-content { width: auto; }
.batch-review-table .col-followup { width: 150px; }

.batch-review-table textarea {
  min-height: 44px;
  resize: vertical;
  width: 100%;
}

.batch-review-table select {
  min-width: 130px;
}

.batch-review-table tr.inactive-row {
  opacity: 0.58;
}

.excluded-list {
  display: grid;
  gap: 8px;
}

.excluded-list p {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 9px;
  border: 1px solid var(--line);
  background: #fff9f0;
  border-radius: var(--radius-sm);
}

.excluded-list small {
  color: var(--muted);
}

.resident-row input,
.checkline input {
  width: auto;
}

.table-wrap {
  overflow: auto;
  max-height: 62vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--elevated);
}

.table-wrap table {
  border: 0;
  min-width: 860px;
}

.table-wrap th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-wrap tr:nth-child(even) td {
  background: #fffaf1;
}

.table-wrap tr:hover td {
  background: #f0eadf;
}

.inactive-row td {
  background: #eee9df !important;
  color: var(--muted);
}

.bed-cell {
  width: 78px;
  white-space: nowrap;
  color: var(--primary);
  font-weight: 800;
}

.content-cell {
  min-width: 280px;
  max-width: 560px;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 12px;
}

.follow-up-select {
  min-width: 98px;
  padding: 5px 8px;
}

.ai-box {
  display: grid;
  gap: 10px;
  background: #edf5f1;
  border: 1px solid #c9dcd2;
  border-radius: var(--radius);
  padding: 12px;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  font-size: 13px;
  border-radius: var(--radius-sm);
}

@media (max-width: 1180px) {
  .span-3 {
    grid-column: span 4;
  }

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

@media (max-width: 980px) {
  .login {
    grid-template-columns: 1fr;
  }

  .login-brief {
    min-height: auto;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
  }

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

  .nav-section {
    grid-column: 1 / -1;
  }

  .top-nav-shell .app-header {
    position: static;
    grid-template-columns: 1fr;
  }

  .app-header-main {
    display: grid;
    gap: 10px;
  }

  .top-brand {
    min-width: 0;
  }

  .top-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .nav-dropdown-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    min-width: 0;
  }

  .app-header-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: span 12;
  }

  .toolbar,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .span-6,
  .form-grid .span-12 {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 13px;
  }

  .login,
  .main {
    padding: 14px;
  }

  .topline {
    position: static;
    margin: -14px -14px 14px;
    padding: 14px;
    display: grid;
  }

  .topline h1 {
    font-size: 22px;
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .risk-strip {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 561px) and (max-width: 980px) {
  .risk-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    padding: 12px;
  }

  .perm-grid,
  .resident-list {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  #app {
    display: none !important;
  }

  .print-area {
    display: block !important;
    color: #111;
    font-family: "Microsoft JhengHei", "Segoe UI", sans-serif;
    padding: 0;
  }

  .print-area h1 {
    font-size: 20px;
    margin: 0 0 8px;
  }

  .print-area table {
    width: 100%;
    border-collapse: collapse;
  }

  .print-area th,
  .print-area td {
    border: 1px solid #777;
    padding: 6px;
  }

  .sidebar,
  .topline .actions,
  .topline-actions,
  button,
  .no-print {
    display: none !important;
  }

  .shell {
    display: block;
  }

  .main {
    padding: 0;
  }

  .panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}

.print-area {
  display: none;
}

.compliance-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.8;
}

.compliance-list strong {
  color: var(--text-strong);
}

.field-label {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 8px;
}

.category-picker-field {
  min-width: 0;
}

.category-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  min-width: 0;
}

.category-check-grid .checkline {
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  white-space: normal;
  overflow: hidden;
}

.category-check-grid .checkline input {
  flex: 0 0 auto;
}

.category-checkline {
  align-items: flex-start;
  gap: 8px;
}

.category-checkline span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.individual-picker {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.66);
}

.picker-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.floor-strip.compact,
.room-grid.compact {
  margin: 0;
}

.floor-strip.compact {
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
}

.floor-strip.compact button {
  min-height: 46px;
  padding: 9px 10px;
}

.room-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  max-height: 170px;
}

.room-grid.compact .room-card {
  cursor: pointer;
  text-align: left;
}

.history-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.history-head h2 {
  margin-bottom: 4px;
}

.history-head p {
  margin: 0;
}

.history-head .actions {
  justify-content: end;
  margin: 0;
}

.review-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 7px;
  padding: 8px;
}

.review-toolbar > select,
.review-toolbar > input {
  flex: 1 1 128px;
  min-width: 0;
  width: auto;
}

.review-toolbar > input[name="query"] {
  flex: 2 1 220px;
}

.review-toolbar > button {
  flex: 0 0 auto;
  min-width: 72px;
  white-space: nowrap;
}

.record-template-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 248, 0.74);
}

.record-template-tools select,
.record-template-tools input {
  flex: 1 1 132px;
  min-width: 0;
}

.record-template-tools .record-template-follow-up {
  flex: 0 1 132px;
  min-width: 120px;
}

.record-template-tools button {
  flex: 0 0 auto;
  min-width: 68px;
  white-space: nowrap;
  word-break: keep-all;
  writing-mode: horizontal-tb;
}

.quick-input-tools {
  align-items: stretch;
}

.quick-input-heading {
  display: flex;
  flex: 1 1 100%;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.quick-suggestions {
  display: flex;
  flex: 1 1 100%;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-chip {
  min-height: 30px;
  padding: 5px 10px;
  border-color: rgba(18, 75, 62, 0.28);
  background: rgba(18, 75, 62, 0.08);
  color: var(--ink);
}

.quick-shortcut-row {
  display: flex;
  flex: 1 1 280px;
  gap: 6px;
  min-width: 220px;
}

.quick-shortcut-row input {
  flex: 1 1 140px;
}

.quick-voice-button {
  border-color: rgba(37, 109, 123, 0.35);
}

.draft-preview-quick-input {
  margin-top: 10px;
  background: rgba(247, 244, 237, 0.78);
}

.record-template-table textarea {
  min-height: 44px;
  resize: vertical;
}

.record-template-table th:nth-child(2),
.record-template-table td:nth-child(2) {
  min-width: 360px;
}

.record-template-table th:nth-child(3),
.record-template-table td:nth-child(3) {
  min-width: 150px;
}

.follow-up-status-field select {
  max-width: 220px;
}

.export-layout {
  align-items: stretch;
}

.export-layout .export-conditions-panel,
.export-layout .export-preview-panel {
  height: 100%;
}

.export-layout .export-preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.export-layout .export-preview-panel .preview-box,
.export-layout .export-preview-empty {
  flex: 1 1 auto;
}

.export-layout .export-preview-panel .preview-box {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.export-layout .export-preview-panel .preview-box .table-wrap {
  flex: 1 1 auto;
}

@media (max-width: 720px) {
  .review-toolbar > select,
  .review-toolbar > input,
  .review-toolbar > button {
    flex: 1 1 100%;
    width: 100%;
  }

  .record-template-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .record-template-tools select,
  .record-template-tools input {
    grid-column: 1 / -1;
  }

  .record-template-tools button {
    width: 100%;
  }
}

.category-review-group {
  display: grid;
  gap: 10px;
  padding: 12px 0 18px;
  border-bottom: 1px solid var(--line);
}

.category-review-group:last-child {
  border-bottom: 0;
}

.ok-text {
  color: var(--ok);
  font-weight: 700;
}

.resident-responsibility-strip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding: 9px 10px;
  border: 1px solid rgba(19, 78, 74, 0.22);
  border-radius: var(--radius-sm, 6px);
  background: rgba(240, 253, 250, 0.64);
  color: var(--text);
  font-size: 12px;
}

.resident-responsibility-strip.warn {
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(255, 251, 235, 0.78);
}

.resident-responsibility-strip span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.resident-responsibility-strip .responsibility-line {
  width: 100%;
}

.resident-responsibility-strip strong {
  color: var(--text-strong);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.resident-responsibility-strip small,
.table-subtext {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-line;
}

.weekly-cm-group {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.weekly-cm-group h3 {
  margin: 0;
  font-size: 15px;
}

.weekly-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.weekly-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.weekly-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.weekly-card textarea {
  min-height: 260px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.6;
}

.section-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.section-list span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.58);
}

.assignment-table {
  display: grid;
  gap: 8px;
  overflow-x: auto;
}

.assignment-row {
  display: grid;
  grid-template-columns: minmax(88px, 0.7fr) minmax(160px, 1fr) minmax(140px, 1fr) minmax(170px, 1fr) minmax(140px, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 760px;
}

.assignment-row.head {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.assignment-row strong {
  color: var(--text-strong);
}

.assignment-row.compact {
  grid-template-columns: minmax(96px, 0.7fr) minmax(220px, 1fr) minmax(240px, 1fr);
  min-width: 620px;
}

.inline-datetime {
  width: 170px;
  min-height: 28px;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.weekly-reference-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.weekly-reference-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm, 6px);
  background: rgba(255, 255, 255, 0.55);
}

.weekly-reference-item strong {
  color: var(--text-strong);
  font-size: 12px;
}

.weekly-reference-item span {
  color: var(--text-muted);
  font-size: 11px;
}

.weekly-reference-item p {
  margin: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

/* Compact card controls */
.category-check-grid {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 6px;
}

.category-check-grid .checkline,
.category-checkline {
  min-height: 34px;
  padding: 7px 8px;
  gap: 6px;
  font-size: 12px;
  line-height: 1.25;
  border-radius: 6px;
}

.category-checkline span {
  line-height: 1.25;
}

.floor-strip.compact,
.room-grid.compact {
  gap: 6px;
}

.floor-strip.compact button {
  min-height: 38px;
  padding: 7px 9px;
}

.room-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
}

.room-grid.compact .room-card {
  min-height: 44px;
  padding: 8px 10px;
}

.room-card strong,
.floor-strip button {
  font-size: 12px;
}

.room-card span,
.floor-strip button span {
  font-size: 11px;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
}

.metric-card {
  min-height: 76px;
  gap: 4px;
  padding: 10px;
}

.metric.metric-action {
  min-height: 86px;
  display: grid;
  align-items: start;
  gap: 6px;
  text-align: left;
  padding: 14px 16px;
  border-top-width: 3px;
}

.metric.metric-action:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-panel);
}

.metric-card strong {
  font-size: 24px;
}

.followup-card strong {
  font-size: 28px;
}

.individual-picker {
  gap: 8px;
  padding: 8px;
}

/* Dense horizontal pickers */
.category-check-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
}

.category-check-grid .checkline,
.category-checkline {
  width: auto;
  min-width: 112px;
  max-width: 190px;
  min-height: 0;
  height: auto;
  padding: 6px 8px;
  align-items: center;
}

.category-checkline span {
  display: block;
}

.floor-strip.compact,
.room-grid.compact {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  max-height: none;
}

.floor-strip.compact button,
.room-grid.compact .room-card {
  width: auto;
  min-width: 86px;
  max-width: 140px;
  min-height: 0;
  height: auto;
  padding: 6px 9px;
}

.room-grid.compact .room-card strong,
.room-grid.compact .room-card span,
.floor-strip.compact button span {
  display: block;
}

/* Room pickers: cap real rooms at five per row for easier scanning. */
.individual-picker:not(.export-resident-picker) .room-grid.compact,
.export-resident-picker .room-grid.compact {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
}

.individual-picker:not(.export-resident-picker) .room-grid.compact .room-card,
.export-resident-picker .room-grid.compact .room-card {
  width: 100%;
  max-width: none;
}

.room-control-row {
  display: flex;
  gap: 6px;
}

.room-control-row .room-card {
  min-width: 132px;
}

.individual-picker > .room-control-row {
  margin-bottom: -2px;
}

.export-range-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.resident-check-field {
  display: grid;
  gap: 6px;
}

.compact-head {
  margin: 0;
}

.resident-check-list {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid;
  max-height: 260px;
  overflow: auto;
  background: #fffdf8;
}

.resident-check-row {
  align-items: center;
  border-bottom: 1px solid #eee6da;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 74px minmax(88px, 1fr) 72px;
  min-height: 34px;
  padding: 6px 8px;
  color: var(--ink);
  font-size: 12px;
}

.resident-check-row:last-child {
  border-bottom: 0;
}

.resident-check-row input {
  min-height: 0;
  width: auto;
}

.resident-check-row strong {
  color: var(--ink);
  font-size: 13px;
}

.resident-check-row small {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.compact-category-check-grid {
  gap: 4px;
}

.compact-category-check-grid .checkline {
  min-height: 28px;
  min-width: 96px;
  padding: 4px 7px;
  font-size: 12px;
}

.settings-inline-table {
  max-height: none;
}

.settings-inline-table table {
  min-width: 980px;
}

.settings-inline-table th,
.settings-inline-table td {
  vertical-align: middle;
}

.settings-inline-table input,
.settings-inline-table select {
  min-height: 32px;
  padding: 5px 7px;
  font-size: 12px;
}

.settings-inline-table input[type="color"] {
  width: 48px;
  padding: 2px;
}

.settings-inline-table .actions {
  justify-content: flex-start;
}

@media (max-width: 720px) {
  .weekly-summary-grid {
    grid-template-columns: 1fr;
  }

  .resident-responsibility-strip {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Top navigation final override: keep the app header full-width after legacy sidebar rules. */
.shell.top-nav-shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
}

.shell.top-nav-shell .app-header {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
}

.shell.top-nav-shell .main {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  min-width: 0;
}

.shell.top-nav-shell .top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.shell.top-nav-shell .nav-dropdown {
  position: relative;
}

.shell.top-nav-shell .nav-dropdown-menu {
  display: none;
  z-index: 80;
}

.shell.top-nav-shell .nav-dropdown:hover > .nav-dropdown-menu,
.shell.top-nav-shell .nav-dropdown.is-open > .nav-dropdown-menu {
  display: grid;
}

@media (max-width: 980px) {
  .individual-picker:not(.export-resident-picker) .room-grid.compact,
  .export-resident-picker .room-grid.compact {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .shell.top-nav-shell {
    grid-template-columns: 1fr;
  }

  .shell.top-nav-shell .app-header {
    position: static;
  }

  .shell.top-nav-shell .top-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .shell.top-nav-shell .nav-dropdown-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .individual-picker:not(.export-resident-picker) .room-grid.compact,
  .export-resident-picker .room-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  .individual-picker:not(.export-resident-picker) .room-grid.compact,
  .export-resident-picker .room-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Revision modal and handover workflow */
.modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 20, 0.46);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 200;
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(22, 31, 28, 0.28);
  max-height: calc(100vh - 40px);
  overflow: auto;
  width: min(720px, 100%);
}

.modal-panel form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.modal-head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.modal-head h2 {
  margin: 0 0 4px;
}

.modal-head .muted {
  white-space: pre-line;
}

.icon-button {
  align-items: center;
  display: inline-flex;
  font-size: 20px;
  height: 32px;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 32px;
}

.revision-modal textarea[readonly] {
  background: #fffdf8;
  color: var(--ink);
  border-color: var(--line);
}

.revision-modal .category-check-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.modal-actions {
  justify-content: flex-end;
}

.handover-floor-strip {
  margin-top: 12px;
}

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

.handover-resident-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.handover-resident-group > header {
  align-items: flex-start;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 12px;
}

.handover-resident-group > header strong {
  font-size: 18px;
  margin-right: 10px;
}

.handover-resident-group > header span {
  font-size: 15px;
  font-weight: 700;
}

.handover-resident-group > header small {
  color: var(--text-muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.compact-table-wrap {
  max-height: none;
}

.handover-record-table .record-time {
  white-space: pre-line;
  width: 112px;
}

.handover-record-table .record-category {
  width: 180px;
}

.handover-record-table .record-followup {
  width: 150px;
}

/* Top navigation compact horizontal layout */
.shell.top-nav-shell .app-header {
  grid-template-columns: minmax(0, 1fr) auto;
}

.shell.top-nav-shell .app-header-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.shell.top-nav-shell .top-brand {
  min-width: 0;
  width: max-content;
}

.shell.top-nav-shell .top-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  overflow: visible;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.shell.top-nav-shell .top-nav button,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  justify-content: center;
  white-space: nowrap;
}

.shell.top-nav-shell .top-nav > button,
.shell.top-nav-shell .top-nav > .nav-dropdown {
  flex: 0 0 auto;
}

.shell.top-nav-shell .app-header-meta {
  flex: 0 0 auto;
}

@media (max-width: 980px) {
  .shell.top-nav-shell .app-header {
    grid-template-columns: 1fr;
  }

  .shell.top-nav-shell .app-header-main {
    grid-template-columns: 1fr;
  }

  .shell.top-nav-shell .top-brand {
    width: auto;
  }

  .shell.top-nav-shell .top-nav {
    overflow: visible;
  }
}

.shell.top-nav-shell .top-nav {
  overflow: visible;
}

.shell.top-nav-shell .nav-dropdown-menu {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  min-width: 220px;
  z-index: 120;
}

/* Lovable-inspired AI SaaS visual refresh. Presentation only: no schema/API changes. */
:root {
  --motion-fast: 140ms;
  --motion-med: 280ms;
  --motion-slow: 560ms;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.2, 1.22, .28, 1);
  --glass: rgba(255, 255, 255, .72);
  --glass-strong: rgba(255, 255, 255, .88);
  --lovable-pink: #f8d9e7;
  --lovable-mint: #ccefe5;
  --lovable-sky: #dcecff;
  --lovable-amber: #ffe8b9;
  --lovable-ink: #17211f;
  --shadow-float: 0 24px 70px rgba(44, 35, 61, .14), 0 3px 18px rgba(18, 60, 53, .08);
  --shadow-glow: 0 14px 40px rgba(88, 105, 255, .10), 0 8px 28px rgba(18, 60, 53, .10);
}

html {
  background: #f8f7f4;
}

body {
  background:
    radial-gradient(circle at 18% 12%, rgba(248, 217, 231, .72), transparent 31rem),
    radial-gradient(circle at 78% 5%, rgba(204, 239, 229, .66), transparent 34rem),
    radial-gradient(circle at 52% 46%, rgba(220, 236, 255, .58), transparent 38rem),
    linear-gradient(135deg, #fffdfa 0%, #f5f1ff 46%, #f1fbf6 100%);
  color: var(--lovable-ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: .42;
  background-image:
    linear-gradient(rgba(18, 60, 53, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 60, 53, .03) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, #000, transparent 84%);
}

@keyframes lovableHeaderIn {
  from { opacity: 0; transform: translateY(-16px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes lovablePanelIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); filter: blur(8px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes lovableShimmer {
  from { transform: translateX(-120%) skewX(-18deg); }
  to { transform: translateX(220%) skewX(-18deg); }
}

.shell.top-nav-shell {
  background: transparent;
}

.shell.top-nav-shell .app-header {
  position: sticky;
  top: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  margin: 10px clamp(10px, 1.2vw, 18px) 0;
  width: auto;
  border: 1px solid rgba(255, 255, 255, .46);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(18, 30, 27, .90), rgba(23, 50, 45, .82)),
    linear-gradient(120deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, 0));
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: 0 24px 70px rgba(17, 24, 39, .22), inset 0 1px 0 rgba(255, 255, 255, .18);
  animation: lovableHeaderIn var(--motion-slow) var(--ease-out) both;
}

.shell.top-nav-shell .app-header::after {
  content: "";
  position: absolute;
  inset: 1px;
  pointer-events: none;
  border-radius: 21px;
  background: linear-gradient(90deg, rgba(255, 232, 185, .12), rgba(220, 236, 255, .08), rgba(204, 239, 229, .12));
  opacity: .72;
  mask-image: linear-gradient(180deg, #000, transparent 72%);
}

.shell.top-nav-shell .app-header-main,
.shell.top-nav-shell .app-header-meta {
  position: relative;
  z-index: 1;
}

.brand-mark {
  border-radius: 13px;
  background: linear-gradient(135deg, #f7c56f, #d9903d 48%, #7357ff);
  box-shadow: 0 12px 26px rgba(216, 156, 74, .28), inset 0 1px 0 rgba(255, 255, 255, .32);
}

.shell.top-nav-shell .top-brand strong {
  font-size: 15px;
  letter-spacing: .01em;
}

.shell.top-nav-shell .top-brand span:not(.brand-mark) {
  color: rgba(246, 239, 227, .72);
}

.shell.top-nav-shell .top-nav {
  flex-wrap: nowrap;
  overflow: visible;
  gap: 7px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 17px;
  background: rgba(255, 255, 255, .055);
}

.shell.top-nav-shell .top-nav button,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger {
  width: auto;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 13px;
  color: rgba(250, 252, 248, .88);
  transition:
    background var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out),
    transform var(--motion-fast) var(--ease-spring),
    box-shadow var(--motion-fast) var(--ease-out);
}

.shell.top-nav-shell .top-nav button:hover,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger:hover,
.shell.top-nav-shell .top-nav button.active,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger.active {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), 0 10px 28px rgba(0, 0, 0, .16);
}

.shell.top-nav-shell .nav-dropdown-menu {
  display: none;
  min-width: 220px;
  top: calc(100% - 1px);
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 18px;
  background: rgba(14, 27, 24, .86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 26px 74px rgba(0, 0, 0, .24), inset 0 1px 0 rgba(255, 255, 255, .12);
  transform: translateY(8px) scale(.98);
  transform-origin: top left;
  animation: lovablePanelIn var(--motion-med) var(--ease-out) both;
}

.shell.top-nav-shell .nav-dropdown:hover > .nav-dropdown-menu,
.shell.top-nav-shell .nav-dropdown.is-open > .nav-dropdown-menu {
  display: grid;
  transform: translateY(0) scale(1);
}

.shell.top-nav-shell .nav-dropdown-menu button {
  border-radius: 12px;
  color: rgba(255, 255, 255, .90);
}

.shell.top-nav-shell .main {
  padding-top: 22px;
}

.topline {
  border: 1px solid rgba(255, 255, 255, .58);
  border-radius: 26px;
  background: rgba(255, 255, 255, .48);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-glow);
  animation: lovablePanelIn var(--motion-slow) var(--ease-out) both;
}

.topline h1 {
  font-size: clamp(26px, 3vw, 42px);
  letter-spacing: -.01em;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .62);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .82), rgba(255, 255, 255, .60)),
    linear-gradient(135deg, rgba(255, 232, 185, .12), rgba(220, 236, 255, .10));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-float);
  animation: lovablePanelIn var(--motion-slow) var(--ease-out) both;
}

.grid > .panel:nth-child(2) { animation-delay: 60ms; }
.grid > .panel:nth-child(3) { animation-delay: 110ms; }
.grid > .panel:nth-child(4) { animation-delay: 160ms; }

.dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}

.risk-strip.dashboard-shortcuts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric,
.metric-card,
.room-card,
.category-check-grid .checkline,
.resident-check-row {
  border-radius: 18px;
  border-color: rgba(255, 255, 255, .62);
  background: rgba(255, 255, 255, .66);
  box-shadow: 0 12px 32px rgba(32, 38, 52, .08), inset 0 1px 0 rgba(255, 255, 255, .72);
  transition:
    transform var(--motion-fast) var(--ease-spring),
    box-shadow var(--motion-fast) var(--ease-out),
    border-color var(--motion-fast) var(--ease-out),
    background var(--motion-fast) var(--ease-out);
}

.metric-action {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.metric-action::before {
  content: "";
  position: absolute;
  inset: -20% auto -20% -35%;
  width: 30%;
  opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .72), transparent);
  z-index: -1;
}

.metric-action:hover::before {
  opacity: .9;
  animation: lovableShimmer 900ms var(--ease-out);
}

.metric:hover,
.metric-card:hover,
.room-card:hover,
.category-check-grid .checkline:hover,
.resident-check-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 46px rgba(32, 38, 52, .14), inset 0 1px 0 rgba(255, 255, 255, .88);
}

.metric strong {
  font-size: clamp(31px, 4vw, 48px);
}

.clinical-record-table {
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(255, 255, 255, .62);
  border-radius: 18px;
  overflow: hidden;
}

.clinical-record-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 255, 255, .84);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.clinical-record-table tbody tr {
  transition:
    background var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out);
}

.clinical-record-table tbody tr:hover {
  background: rgba(220, 236, 255, .28);
  box-shadow: inset 3px 0 0 rgba(115, 87, 255, .38);
}

button {
  position: relative;
  overflow: hidden;
}

button.primary {
  background: linear-gradient(135deg, #144d43, #7357ff);
  border-color: rgba(255, 255, 255, .18);
  box-shadow: 0 14px 30px rgba(45, 57, 143, .18);
}

input,
select,
textarea {
  border-color: rgba(153, 143, 122, .44);
  background: rgba(255, 255, 255, .74);
  transition:
    border-color var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out),
    background var(--motion-fast) var(--ease-out);
}

input:focus,
select:focus,
textarea:focus {
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 0 0 4px rgba(115, 87, 255, .11), 0 10px 28px rgba(32, 38, 52, .08);
}

.pill {
  border-radius: 999px;
  background: rgba(255, 255, 255, .66);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-backdrop {
  background: rgba(17, 24, 39, .38);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-panel {
  border-radius: 24px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 34px 100px rgba(17, 24, 39, .28);
  animation: lovablePanelIn var(--motion-med) var(--ease-out) both;
}

@media (max-width: 980px) {
  .shell.top-nav-shell .app-header {
    border-radius: 18px;
  }

  .shell.top-nav-shell .top-nav {
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 5px;
  }

  .risk-strip.dashboard-shortcuts {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topline,
  .panel {
    border-radius: 18px;
  }

  .shell.top-nav-shell .app-header {
    margin: 6px;
  }

  .metric strong {
    font-size: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

/* Compact page title bar: keep Lovable polish without covering dashboard cards. */
.topline {
  position: relative;
  top: auto;
  z-index: 1;
  align-items: center;
  margin: 0 0 10px;
  padding: 10px clamp(16px, 2vw, 24px) 9px;
  border-radius: 18px;
  min-height: 0;
}

.topline h1 {
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.05;
  margin-bottom: 2px;
}

.topline p {
  font-size: 12px;
  line-height: 1.25;
}

.topline-actions {
  align-items: center;
}

/* Compact separated navigation buttons. */
.shell.top-nav-shell .top-nav {
  gap: 4px;
  padding: 2px;
  border-color: transparent;
  background: transparent;
}

.shell.top-nav-shell .top-nav button,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 11px;
  background: rgba(255, 255, 255, .075);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .10);
}

.shell.top-nav-shell .top-nav button:hover,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger:hover,
.shell.top-nav-shell .top-nav button.active,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger.active {
  border-color: rgba(255, 232, 185, .42);
  background: rgba(255, 255, 255, .15);
}

.shell.top-nav-shell .nav-dropdown-menu {
  min-width: 172px;
  padding: 5px;
  border-radius: 14px;
}

.shell.top-nav-shell .nav-dropdown-menu button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 13px;
  border-radius: 10px;
}

/* Lovable-style glass buttons. */
button {
  border: 1px solid rgba(255, 255, 255, .54);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .58)),
    radial-gradient(circle at 18% 12%, rgba(255, 232, 185, .46), transparent 42%),
    radial-gradient(circle at 82% 18%, rgba(220, 236, 255, .58), transparent 46%);
  color: var(--ink-2);
  box-shadow:
    0 10px 26px rgba(32, 38, 52, .10),
    inset 0 1px 0 rgba(255, 255, 255, .86),
    inset 0 -1px 0 rgba(18, 60, 53, .06);
  transition:
    transform var(--motion-fast) var(--ease-spring),
    box-shadow var(--motion-fast) var(--ease-out),
    border-color var(--motion-fast) var(--ease-out),
    background var(--motion-fast) var(--ease-out),
    color var(--motion-fast) var(--ease-out);
}

button::before {
  content: "";
  position: absolute;
  inset: -35% auto -35% -48%;
  width: 38%;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .68), transparent);
  transform: translateX(-120%) skewX(-18deg);
}

button:hover {
  border-color: rgba(115, 87, 255, .30);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(245, 249, 255, .70)),
    radial-gradient(circle at 18% 12%, rgba(255, 232, 185, .62), transparent 42%),
    radial-gradient(circle at 82% 18%, rgba(220, 236, 255, .76), transparent 46%);
  box-shadow:
    0 16px 36px rgba(45, 57, 143, .16),
    inset 0 1px 0 rgba(255, 255, 255, .94),
    inset 0 -1px 0 rgba(18, 60, 53, .06);
  transform: translateY(-1px);
}

button:hover::before {
  opacity: 1;
  animation: lovableShimmer 850ms var(--ease-out);
}

button.primary {
  border-color: rgba(255, 255, 255, .24);
  background:
    linear-gradient(135deg, #0f4b42 0%, #4f46e5 52%, #d97a45 100%);
  color: #fffdf8;
  box-shadow:
    0 18px 42px rgba(79, 70, 229, .24),
    0 8px 24px rgba(15, 75, 66, .18),
    inset 0 1px 0 rgba(255, 255, 255, .24);
}

button.primary:hover {
  background:
    linear-gradient(135deg, #125b50 0%, #6258f0 50%, #e88d54 100%);
  box-shadow:
    0 22px 52px rgba(79, 70, 229, .28),
    0 10px 28px rgba(15, 75, 66, .20),
    inset 0 1px 0 rgba(255, 255, 255, .30);
}

button.danger {
  border-color: rgba(169, 53, 42, .26);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .92), rgba(255, 243, 241, .70)),
    radial-gradient(circle at 80% 10%, rgba(255, 190, 180, .48), transparent 44%);
}

.shell.top-nav-shell .top-nav button,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger {
  background: linear-gradient(135deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .06));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .18),
    0 8px 18px rgba(0, 0, 0, .08);
}

.shell.top-nav-shell .top-nav button:hover,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger:hover,
.shell.top-nav-shell .top-nav button.active,
.shell.top-nav-shell .top-nav .nav-dropdown-trigger.active {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .26), rgba(255, 255, 255, .10)),
    radial-gradient(circle at 20% 0%, rgba(255, 232, 185, .28), transparent 40%);
}

/* handover soft header final override */
.handover-resident-group {
  border-color: rgba(255, 255, 255, .52);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .84), rgba(255, 255, 255, .64)),
    radial-gradient(circle at 8% 0%, rgba(204, 239, 229, .36), transparent 34%);
  box-shadow:
    0 18px 44px rgba(32, 38, 52, .08),
    inset 0 1px 0 rgba(255, 255, 255, .88);
}

.handover-resident-group > header {
  background: linear-gradient(135deg, rgba(255, 255, 255, .94), rgba(241, 248, 246, .78));
  border-bottom: 1px solid rgba(18, 60, 53, .10);
  color: var(--lovable-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .90);
}

.handover-resident-group > header strong,
.handover-resident-group > header span {
  color: var(--lovable-ink);
}

.handover-resident-group > header small {
  color: var(--text-muted);
}

/* Risk strategy console */
.risk-console {
  gap: 14px;
}

.risk-console-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .58);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .86), rgba(255, 255, 255, .62)),
    radial-gradient(circle at 15% 0%, rgba(255, 232, 185, .34), transparent 42%),
    radial-gradient(circle at 88% 10%, rgba(220, 236, 255, .46), transparent 45%);
  box-shadow:
    0 16px 38px rgba(32, 38, 52, .08),
    inset 0 1px 0 rgba(255, 255, 255, .90);
}

.risk-console-toolbar select {
  min-width: 180px;
}

.risk-alert-list {
  display: grid;
  gap: 12px;
}

.risk-alert-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .62);
  border-left: 5px solid rgba(30, 107, 99, .62);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .92), rgba(255, 255, 255, .68)),
    radial-gradient(circle at 92% 0%, rgba(220, 236, 255, .40), transparent 40%);
  box-shadow:
    0 18px 42px rgba(32, 38, 52, .09),
    inset 0 1px 0 rgba(255, 255, 255, .92);
}

.risk-alert-card.high {
  border-left-color: #cf3e31;
}

.risk-alert-card.medium {
  border-left-color: #c78922;
}

.risk-alert-card.low {
  border-left-color: #256d7b;
}

.risk-alert-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
  gap: 14px;
  align-items: start;
}

.risk-alert-main h3 {
  margin: 6px 0 4px;
  font-size: 18px;
  line-height: 1.25;
}

.risk-alert-main p,
.risk-alert-main small {
  margin: 0;
  color: var(--text-muted);
}

.risk-severity {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(18, 60, 53, .12);
  background: rgba(255, 255, 255, .74);
}

.risk-severity.high {
  color: #a9352a;
  background: #fff2ef;
}

.risk-severity.medium {
  color: #8a5b13;
  background: #fff6df;
}

.risk-severity.low {
  color: #1b6170;
  background: #eaf8f6;
}

.risk-resident {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid rgba(18, 60, 53, .10);
  border-radius: 14px;
  background: rgba(255, 255, 255, .68);
}

.risk-resident strong {
  font-size: 20px;
  line-height: 1.1;
}

.risk-resident small {
  color: var(--text-muted);
}

.risk-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.risk-suggestions span {
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid rgba(18, 60, 53, .10);
  background: rgba(246, 250, 247, .78);
  color: var(--text-muted);
  font-size: 12px;
}

.risk-source-list {
  display: grid;
  gap: 7px;
}

.risk-source-row {
  display: grid;
  grid-template-columns: 140px 180px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .58);
  border: 1px solid rgba(18, 60, 53, .08);
}

.risk-source-row time {
  font-weight: 700;
  color: var(--lovable-ink);
}

.risk-source-row p {
  margin: 0;
  line-height: 1.45;
}

.category-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.risk-action-form {
  display: grid;
  grid-template-columns: 160px minmax(180px, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
}

.risk-action-form input {
  min-width: 0;
}

.risk-status {
  justify-self: end;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid rgba(18, 60, 53, .12);
  background: rgba(255, 255, 255, .72);
  font-size: 12px;
  font-weight: 700;
}

.risk-status.new,
.risk-status.supervisor_review_required {
  color: #a9352a;
  background: #fff2ef;
}

.risk-status.in_progress {
  color: #8a5b13;
  background: #fff6df;
}

.risk-status.actioned,
.risk-status.dismissed {
  color: #1f6b5f;
  background: #e9f7f2;
}

.risk-ai-box {
  white-space: pre-line;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.risk-timeline {
  display: grid;
  gap: 14px;
}

.risk-timeline-group {
  border: 1px solid rgba(255, 255, 255, .60);
  border-radius: 18px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 16px 38px rgba(32, 38, 52, .08);
  overflow: hidden;
}

.risk-timeline-group > header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .92), rgba(241, 248, 246, .74));
  border-bottom: 1px solid rgba(18, 60, 53, .08);
}

.risk-timeline-chain {
  display: grid;
  gap: 0;
  padding: 10px 14px 14px 30px;
}

.risk-timeline-node {
  position: relative;
  padding: 10px 0 10px 18px;
  border-left: 2px solid rgba(18, 60, 53, .14);
}

.risk-timeline-node::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid #1f6b5f;
}

.risk-timeline-node.alert::before {
  border-color: #c78922;
  background: #fff6df;
}

.risk-timeline-node.alert.high::before {
  border-color: #cf3e31;
  background: #fff2ef;
}

.risk-timeline-node time {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.risk-timeline-node p {
  margin: 4px 0 0;
}

.risk-star-panel {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(260px, .85fr);
  gap: 16px;
}

.risk-star-map {
  position: relative;
  min-height: 430px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(18, 60, 53, .08);
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, .92) 0 10%, transparent 11%),
    radial-gradient(circle at center, transparent 0 26%, rgba(31, 107, 95, .10) 27%, transparent 28%),
    radial-gradient(circle at center, transparent 0 43%, rgba(199, 137, 34, .12) 44%, transparent 45%),
    linear-gradient(135deg, rgba(255, 255, 255, .88), rgba(232, 244, 249, .58));
}

.risk-star-center,
.risk-star-node {
  position: absolute;
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, .64);
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 14px 32px rgba(32, 38, 52, .12);
}

.risk-star-center {
  left: 50%;
  top: 50%;
  width: 150px;
  min-height: 110px;
  transform: translate(-50%, -50%);
}

.risk-star-center strong {
  font-size: 24px;
}

.risk-star-center small {
  color: var(--text-muted);
}

.risk-star-node {
  min-width: 112px;
  min-height: 62px;
  padding: 8px;
  font-size: 12px;
}

.risk-star-node.category.node-1 { left: 12%; top: 16%; }
.risk-star-node.category.node-2 { right: 13%; top: 17%; }
.risk-star-node.category.node-3 { left: 10%; bottom: 20%; }
.risk-star-node.category.node-4 { right: 12%; bottom: 22%; }
.risk-star-node.record-1 { left: 39%; top: 7%; }
.risk-star-node.record-2 { right: 5%; top: 44%; }
.risk-star-node.record-3 { left: 5%; top: 44%; }
.risk-star-node.record-4 { left: 38%; bottom: 8%; }
.risk-star-node.alert {
  right: 8%;
  bottom: 8%;
  color: #a9352a;
  background: #fff2ef;
}

.risk-star-side {
  display: grid;
  align-content: start;
  gap: 10px;
}

@media (max-width: 980px) {
  .risk-alert-main,
  .risk-source-row,
  .risk-action-form,
  .risk-star-panel {
    grid-template-columns: 1fr;
  }

  .risk-status {
    justify-self: start;
  }
}
