:root {
  --green-900: #14291d;
  --green-800: #1d3b2a;
  --green-700: #275138;
  --cream: #f7f5ef;
  --ink: #1f2823;
  --muted: #5f6d64;
  --line: #e3e0d6;
  --red: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 41, 29, 0.06), 0 8px 24px rgba(20, 41, 29, 0.08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Nav */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--green-800);
  color: #fff;
}
.brand {
  color: #fff;
  text-decoration: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  letter-spacing: 0.2px;
}
.brand span { color: #b9d3c2; font-style: italic; }
.nav-right { display: flex; align-items: center; gap: 14px; }
.who { font-size: 14px; color: #d6e4db; }

/* Layout */
.main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 72px;
}
.main.wide { max-width: min(1480px, calc(100% - 32px)); }
.footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  padding: 18px;
  border-top: 1px solid var(--line);
}

/* Hero / welcome */
.hero { text-align: center; padding-top: 6vh; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 2.5px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 14px;
}
.hero h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(40px, 7vw, 64px);
  font-weight: 500;
  color: var(--green-900);
}
.hero .accent { font-style: italic; color: var(--green-700); }
.lede {
  font-size: 17px;
  line-height: 1.65;
  color: var(--muted);
  max-width: 52ch;
  margin: 18px auto 0;
}
.cta { margin-top: 34px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hint { margin-top: 16px; font-size: 13.5px; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: transform 0.06s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-sm { padding: 7px 14px; font-size: 13.5px; }
.btn-primary { background: var(--green-700); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--green-800); }
.btn-ghost { border-color: rgba(255, 255, 255, 0.35); color: inherit; }
.main .btn-ghost { border-color: var(--line); color: var(--ink); background: #fff; }
.main .btn-ghost:hover { border-color: var(--muted); }

/* Dashboard */
.dash-head h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 34px;
  color: var(--green-900);
}
.dash-head .lede { margin: 8px 0 0; }
.grid {
  margin-top: 36px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
}

/* App cards */
.card {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.card:hover { transform: translateY(-2px); border-color: #c9c4b4; }
.card-red { border-top: 4px solid var(--red); }
.card-icon { width: 48px; flex: none; }
.card-icon svg { width: 48px; height: 48px; }
.card-body h3 { font-size: 18px; color: var(--green-900); }
.card-tag {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--red);
  margin: 3px 0 8px;
  font-weight: 700;
}
.card-desc { font-size: 14px; line-height: 1.55; color: var(--muted); }
.card-go {
  position: absolute;
  right: 18px;
  bottom: 14px;
  color: var(--muted);
  font-size: 18px;
  transition: transform 0.12s ease;
}
.card:hover .card-go { transform: translateX(3px); color: var(--green-700); }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  background: #fff;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 56px 28px;
}
.empty h3 { font-size: 19px; color: var(--green-900); margin-bottom: 8px; }
.empty p { color: var(--muted); font-size: 14.5px; max-width: 46ch; margin: 0 auto; line-height: 1.6; }

/* App stub + access pages */
.app-stub, .access { text-align: center; padding-top: 5vh; }
.stub-icon svg, .access-mark { width: 72px; height: 72px; }
.access-mark { font-size: 56px; line-height: 1; }
.app-stub h1, .access h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 38px;
  color: var(--green-900);
  margin-top: 18px;
}
.app-stub p, .access p { margin-top: 14px; }
.app-stub > p { color: var(--muted); max-width: 54ch; margin-left: auto; margin-right: auto; line-height: 1.65; }
.badge {
  display: inline-block;
  background: #eef3ef;
  border: 1px solid #cfdcd3;
  color: var(--green-700);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 7px 16px;
}

/* Red Cross app */
.app-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 22px;
}
.app-head-icon { width: 56px; }
.app-head-icon svg { width: 56px; height: 56px; }
.app-head h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 32px;
  color: var(--green-900);
  margin-top: 2px;
}
.app-head .lede { margin: 8px 0 0; max-width: none; }
.app-head-back { margin-top: 8px; }

.banner {
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 18px;
}
.banner-ok {
  background: #eef6f0;
  border: 1px solid #c5dccb;
  color: var(--green-800);
}
.banner-warn {
  background: #fff6e8;
  border: 1px solid #f0d4a8;
  color: #7a4e0e;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.table-search {
  flex: 1 1 280px;
  max-width: 420px;
}
.table-search input {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
  box-shadow: 0 1px 0 rgba(20, 41, 29, 0.03);
}
.table-search input:focus {
  border-color: #9bb5a4;
  box-shadow: 0 0 0 3px rgba(39, 81, 56, 0.12);
}
.table-count {
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  max-width: 100%;
}
.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 13.5px;
}
.data-table th,
.data-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.data-table th {
  background: #f3f1ea;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
  user-select: none;
}
.data-table td.col-name {
  white-space: normal;
  word-break: break-word;
  overflow: hidden;
}
.data-table .th-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: calc(100% - 8px);
  max-width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  text-align: left;
}
.data-table .th-label {
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table .th-ind::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  opacity: 0.35;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  transform: translateY(1px);
}
.data-table th.is-sorted .th-ind::after { opacity: 1; }
.data-table th.is-desc .th-ind::after {
  border-bottom: 0;
  border-top: 5px solid currentColor;
  transform: translateY(2px);
}
.data-table th.is-sorted {
  color: var(--green-800);
}
.col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}
.col-resize::after {
  content: '';
  position: absolute;
  top: 20%;
  bottom: 20%;
  left: 3px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
}
.data-table th:hover .col-resize::after,
.data-table th.is-resizing .col-resize::after {
  background: #b7c7bc;
}
body.col-resizing {
  cursor: col-resize;
  user-select: none;
}
body.col-resizing * { cursor: col-resize !important; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #faf9f5; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .num .th-sort { justify-content: flex-end; }
.data-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.data-table .lv-link {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--ink) 28%, transparent);
  text-underline-offset: 2px;
}
.data-table .lv-link:hover {
  color: var(--green, #1d3b2a);
  text-decoration-color: currentColor;
}
.data-table .empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 8px;
  margin-right: 4px;
}
.pill-red { background: #fbe9e9; color: var(--red); }
.pill-amber { background: #fff1d6; color: #9a6700; }
.muted { color: var(--muted); }

/* Live / Cleared groups */
.group-header td {
  background: #ebe8df !important;
  padding: 8px 12px !important;
  border-bottom: 1px solid var(--line);
  white-space: normal !important;
  overflow: visible !important;
}
.group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--green-900);
  cursor: pointer;
  padding: 2px 0;
}
.group-toggle .group-chevron {
  display: inline-block;
  width: 1em;
  transition: transform 0.12s ease;
}
.group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #d5d0c4;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
tbody.is-collapsed .group-toggle .group-chevron {
  transform: rotate(-90deg);
}
tbody.is-collapsed tr:not(.group-header) {
  display: none !important;
}
#red-cross-live .group-header td {
  background: #e7f0ea !important;
}
#red-cross-cleared .group-header td {
  background: #f0eee8 !important;
}
.data-table tr.row-cleared td {
  color: var(--muted);
  background: #faf9f6;
}
.data-table tr.row-cleared:hover td {
  background: #f3f1ea;
}
.data-table tr.row-cleared .lv-link {
  color: var(--muted);
}

.col-clear {
  text-align: center;
  width: 56px;
}
.clear-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.clear-toggle {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--green-700);
}
.row-error {
  display: block;
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  white-space: nowrap;
  background: #fbe9e9;
  color: var(--red);
  border: 1px solid #f0c4c0;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  z-index: 3;
}

.col-log {
  text-align: center;
  width: 64px;
}
.log-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 34px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.log-pill:hover {
  border-color: #9bb5a4;
  color: var(--green-800);
}
.log-pill.has-entries {
  border-color: #9bb5a4;
  background: #eef6f0;
  color: var(--green-800);
}
.log-pill.is-empty {
  opacity: 0.72;
}
.log-pill-icon {
  font-size: 11px;
  line-height: 1;
}

/* Activity slide-over */
body.log-open {
  overflow: hidden;
}
.log-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 41, 29, 0.28);
  z-index: 40;
}
.log-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 28px rgba(20, 41, 29, 0.12);
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.log-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
  background: #f7f5ef;
}
.log-panel-head h2 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 22px;
  color: var(--green-900);
  margin-top: 2px;
}
.log-panel-sub {
  font-size: 13px;
  margin-top: 4px;
  max-width: 28ch;
}
.log-timeline {
  flex: 1;
  overflow: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.log-empty {
  font-size: 14px;
  text-align: center;
  padding: 28px 8px;
}
.log-entry {
  background: #faf9f5;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.log-entry header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 12.5px;
}
.log-entry header strong {
  color: var(--green-900);
}
.log-entry header time {
  color: var(--muted);
  white-space: nowrap;
}
.log-entry p {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.log-system {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 4px;
}
.log-panel-foot {
  border-top: 1px solid var(--line);
  padding: 14px 18px 18px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.log-clear-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.log-clear-toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--green-700);
}
.log-note-form textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 72px;
  outline: none;
}
.log-note-form textarea:focus {
  border-color: #9bb5a4;
  box-shadow: 0 0 0 3px rgba(39, 81, 56, 0.12);
}
.log-note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}
.log-error {
  color: var(--red);
  font-size: 12.5px;
  flex: 1;
}

@media (max-width: 720px) {
  .app-head {
    grid-template-columns: auto 1fr;
  }
  .app-head-back { grid-column: 1 / -1; }
  .log-panel {
    width: 100vw;
  }
}
