/* Echelon Grievance Tracker — mobile-first stylesheet.
   Built phone-up: the base rules describe a 360px screen, and the wider
   layouts are added at breakpoints above. Everything a thumb can touch is at
   least 44px, and every form control is 16px so iOS does not zoom on focus. */

:root {
  /* Clean clinical: cool greys with one calm blue for anything actionable. */
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --ink: #16232e;
  --ink-soft: #3d4f5e;
  --ink-muted: #64798a;
  --line: #dbe3ea;
  --line-strong: #c3cfd9;

  --accent: #1b5e8f;
  --accent-hover: #17527d;
  --accent-ink: #ffffff;
  --accent-soft: #e3eef7;

  --status-new: #9a5b00;
  --status-new-soft: #fbeed6;
  --status-progress: #1b5e8f;
  --status-progress-soft: #e3eef7;
  --status-resolved: #15654a;
  --status-resolved-soft: #dcefe7;

  --danger: #a32e2e;
  --danger-soft: #fae2e2;

  --shadow-sm: 0 1px 2px rgba(22, 35, 46, 0.07);
  --shadow: 0 1px 2px rgba(22, 35, 46, 0.06), 0 6px 20px -10px rgba(22, 35, 46, 0.22);
  --shadow-lg: 0 -2px 16px -6px rgba(22, 35, 46, 0.18);

  --radius: 12px;
  --radius-sm: 9px;

  /* Height of the phone bottom bar, so content can clear it. */
  --tabbar-h: 60px;
  --tap: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Stop the whole page sliding sideways on a phone if one child overflows. */
body { overflow-x: hidden; }

h1, h2, h3, .brand {
  font-family: "Fraunces", Georgia, serif;
  text-wrap: balance;
}

.mono, .tabular, time, td.num { font-variant-numeric: tabular-nums; }
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* =================================================================
   App shell — bottom tab bar on phones, sidebar from 900px up
   ================================================================= */

.shell { min-height: 100vh; min-height: 100dvh; }

/* ---- Phone: top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  min-height: 56px;
}
.topbar .brand {
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
  margin: 0;
  line-height: 1.15;
  flex: 1;
  min-width: 0;
}
.topbar .brand small {
  display: block;
  font-family: "Public Sans", sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 1px;
}

/* ---- Phone: bottom tab bar ---- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tabbar-h);
  padding: 8px 4px;
  border: none;
  background: none;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tabbar .tab .ic {
  font-size: 19px;
  line-height: 1;
  display: block;
}
.tabbar .tab .lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.tabbar .tab.active { color: var(--accent); }
.tabbar .tab.active .ic { transform: translateY(-1px); }
.tabbar .tab.tab-primary .ic {
  background: var(--accent);
  color: var(--accent-ink);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-top: -2px;
}
.tabbar .tab.tab-primary.active .ic { background: var(--accent-hover); }

/* ---- Phone: the "More" sheet ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 35, 46, 0.42);
  z-index: 55;
  display: flex;
  align-items: flex-end;
}
.sheet {
  width: 100%;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  max-height: 80vh;
  overflow-y: auto;
}
.sheet .grip {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--line-strong);
  margin: 8px auto 12px;
}
.sheet .sheet-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.sheet .nav-link { font-size: 16px; min-height: var(--tap); }

.sidebar { display: none; }

.main {
  padding: 18px 16px calc(24px + var(--tabbar-h));
  min-width: 0;
}

/* ---- Desktop shell ---- */
@media (min-width: 900px) {
  .shell { display: flex; }
  .topbar, .tabbar { display: none; }

  .sidebar {
    display: flex;
    width: 236px;
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--line);
    flex-direction: column;
    padding: 20px 14px;
    gap: 3px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
  .sidebar .brand {
    font-size: 19px;
    font-weight: 600;
    color: var(--accent);
    padding: 4px 10px;
    margin-bottom: 10px;
  }
  .sidebar .brand small {
    display: block;
    font-family: "Public Sans", sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-top: 2px;
  }
  .main {
    flex: 1;
    padding: 28px 36px 60px;
    max-width: 1120px;
  }
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link .ic { width: 20px; text-align: center; flex: none; font-size: 16px; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  font-size: 13px;
  min-width: 0;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; flex: none;
}
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .role { color: var(--ink-muted); font-size: 12px; text-transform: capitalize; }

/* =================================================================
   Page headings
   ================================================================= */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; margin: 0; font-weight: 600; line-height: 1.2; }
.page-head p { color: var(--ink-muted); margin: 5px 0 0; font-size: 14px; }
.page-head .head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (min-width: 700px) {
  .page-head h1 { font-size: 27px; }
}

/* On a phone the page title is already in the top bar, so the big
   "+ New Grievance" button in the header is redundant with the tab bar. */
@media (max-width: 899px) {
  .hide-phone { display: none !important; }
}
@media (min-width: 900px) {
  .hide-desktop { display: none !important; }
}

/* =================================================================
   Buttons and forms
   ================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 15px;
  min-height: var(--tap);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
a.btn, a.btn:visited { color: var(--ink); }
a.btn.primary, a.btn.primary:visited { color: var(--accent-ink); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: 13.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (min-width: 700px) {
  .btn { font-size: 14px; min-height: 40px; padding: 9px 14px; }
  .btn.small { min-height: 32px; padding: 5px 11px; font-size: 13px; }
}

label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}
.field { margin-bottom: 18px; }
.field .hint { font-weight: 400; color: var(--ink-muted); font-size: 12.5px; margin-top: 5px; }

input[type="text"], input[type="password"], input[type="date"],
input[type="number"], input[type="email"], input[type="tel"],
select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  /* 16px keeps iOS Safari from zooming the page when a field is focused. */
  font-size: 16px;
  min-height: var(--tap);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364798a' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }

@media (min-width: 700px) {
  input[type="text"], input[type="password"], input[type="date"],
  input[type="number"], input[type="email"], input[type="tel"],
  select, textarea {
    font-size: 14.5px;
    min-height: 40px;
    padding: 9px 11px;
  }
  textarea { min-height: 88px; }
}

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 700px) {
  .grid-2 { grid-template-columns: 1fr 1fr; gap: 0 16px; }
}

.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 100%; }
@media (min-width: 700px) {
  .inline-form .field { min-width: 150px; }
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.form-actions .btn { flex: 1; min-width: 140px; }
@media (min-width: 700px) {
  .form-actions .btn { flex: 0 0 auto; min-width: 0; }
}

/* A file input styled as a button-sized drop target. */
.file-field input[type="file"] {
  width: 100%;
  font-size: 14px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  min-height: var(--tap);
}
.attach-choices { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.attach-choices .btn { flex: 1; min-width: 130px; }

/* =================================================================
   Cards and surfaces
   ================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 16px; }
.card + .card { margin-top: 16px; }
@media (min-width: 700px) {
  .card-pad { padding: 20px; }
  .card + .card { margin-top: 20px; }
}

.section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
  margin: 0 0 12px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.section-head .section-title { margin: 0; }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: none; }

/* =================================================================
   Sign-in
   ================================================================= */

.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.login-card { width: 100%; max-width: 380px; padding: 28px 22px; }
@media (min-width: 700px) { .login-card { padding: 34px 30px; } }
.login-card .brand { text-align: center; margin: 0 0 5px; font-size: 21px; color: var(--accent); }
.login-card .tag { text-align: center; color: var(--ink-muted); font-size: 13.5px; margin-bottom: 22px; }

.error-msg {
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 14px; margin-bottom: 14px;
}
.success-msg {
  background: var(--status-resolved-soft); color: var(--status-resolved);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 14px; margin-bottom: 14px;
}
.notice-msg {
  background: var(--accent-soft); color: var(--accent);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 14px; margin-bottom: 14px;
}

.login-context {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-muted);
  text-align: center;
}
.code-input {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 26px !important;
  letter-spacing: 0.24em;
  text-align: center;
  padding-left: 0.24em !important;
}
.backup-codes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 16px;
}
@media (min-width: 480px) { .backup-codes { grid-template-columns: repeat(2, 1fr); } }
.backup-codes code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  text-align: center;
  letter-spacing: 0.05em;
}

/* =================================================================
   Status pills
   ================================================================= */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.01em;
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.status-new { background: var(--status-new-soft); color: var(--status-new); }
.pill.status-progress { background: var(--status-progress-soft); color: var(--status-progress); }
.pill.status-resolved { background: var(--status-resolved-soft); color: var(--status-resolved); }
.pill.status-pending { background: var(--surface-3); color: var(--ink-muted); }
.pill.status-done { background: var(--status-resolved-soft); color: var(--status-resolved); }
.pill.status-locked { background: var(--danger-soft); color: var(--danger); }
.pill.overdue { background: var(--danger-soft); color: var(--danger); }

.tag-chip {
  display: inline-block;
  background: var(--surface-3);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.badge-role {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  white-space: nowrap;
}
.badge-role.staff { background: var(--surface-3); color: var(--ink-muted); }

/* =================================================================
   Dashboard stats and filters
   ================================================================= */

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}
.stat-tile .num {
  font-family: "IBM Plex Mono", monospace;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.1;
}
.stat-tile.alert .num { color: var(--danger); }
.stat-tile .lbl {
  font-size: 11px;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}
@media (min-width: 700px) {
  .stat-row { grid-template-columns: repeat(3, minmax(130px, 180px)); gap: 14px; }
  .stat-tile { padding: 14px 18px; text-align: left; }
}

/* Horizontally scrolling segmented filter, which beats wrapped buttons
   on a narrow screen. */
.filter-bar { margin-bottom: 14px; }
.seg {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  margin-bottom: 10px;
}
.seg::-webkit-scrollbar { display: none; }
.seg .btn { flex: none; min-height: 38px; padding: 7px 14px; font-size: 14px; border-radius: 999px; }
.seg .btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.search-field { position: relative; }
.search-field input {
  padding-left: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Ccircle cx='7' cy='7' r='5' stroke='%2364798a' stroke-width='1.7' fill='none'/%3E%3Cpath d='M11 11l3.2 3.2' stroke='%2364798a' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 13px center;
}
@media (min-width: 700px) {
  .filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .seg { margin-bottom: 0; }
  .search-field { margin-left: auto; min-width: 260px; }
}

/* =================================================================
   Grievance list — cards on a phone, rows on a wide screen
   ================================================================= */

.g-list { display: flex; flex-direction: column; gap: 10px; }

.g-row {
  display: grid;
  grid-template-areas:
    "status  id"
    "title   title"
    "sub     sub"
    "who     who";
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.g-row:active { background: var(--surface-2); }
.g-row .g-status { grid-area: status; justify-self: start; }
.g-row .g-id {
  grid-area: id;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11.5px;
  color: var(--ink-muted);
  justify-self: end;
}
.g-row .g-title {
  grid-area: title;
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.35;
  margin-top: 4px;
  /* Two lines on a phone, then ellipsis — full text is on the detail page. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.g-row .g-sub { grid-area: sub; font-size: 12.5px; color: var(--ink-muted); }
.g-row .g-assignees {
  grid-area: who;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

@media (min-width: 900px) {
  .g-row {
    grid-template-areas: "id title status who";
    grid-template-columns: 92px 1fr auto 200px;
    gap: 14px;
    padding: 14px 16px;
  }
  .g-row:hover { border-color: var(--accent); }
  .g-row .g-id { justify-self: start; }
  .g-row .g-title {
    -webkit-line-clamp: 1;
    margin-top: 0;
    font-size: 15px;
  }
  .g-row .g-sub { display: none; }
  .g-row .g-assignees { justify-content: flex-end; margin-top: 0; }
}

.empty-state {
  text-align: center;
  color: var(--ink-muted);
  padding: 44px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  font-size: 14.5px;
}

/* =================================================================
   Detail view
   ================================================================= */

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 1000px) {
  .detail-grid { grid-template-columns: 1fr 330px; gap: 20px; }
}

/* Assignment panel matters most to Sam, so on a phone it sits first. */
.detail-side { order: -1; }
@media (min-width: 1000px) { .detail-side { order: 0; } }

.kv { display: grid; grid-template-columns: 1fr; gap: 2px; font-size: 15px; margin: 0; }
.kv dt {
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 14px;
}
.kv dt:first-child { margin-top: 0; }
.kv dd { margin: 0; white-space: pre-wrap; }
@media (min-width: 700px) {
  .kv { grid-template-columns: 165px 1fr; gap: 10px 14px; font-size: 14.5px; }
  .kv dt { margin-top: 0; text-transform: none; font-size: 13.5px; letter-spacing: 0; }
}

.detail-title { min-width: 0; }
.detail-title h1 {
  font-size: 21px;
  margin: 0;
  overflow-wrap: anywhere;
}
.detail-meta {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin: 6px 0 0;
  font-family: "IBM Plex Mono", monospace;
}
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.detail-actions .btn { flex: 1; min-width: 130px; }
@media (min-width: 700px) {
  .detail-title h1 { font-size: 26px; }
  .detail-actions { margin-top: 0; }
  .detail-actions .btn { flex: 0 0 auto; min-width: 0; }
}

.assignee-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.assignee-row:first-child { padding-top: 0; }
.assignee-row:last-child { border-bottom: none; padding-bottom: 0; }
.assignee-row .a-who { flex: 1 1 100%; min-width: 130px; }
@media (min-width: 700px) { .assignee-row .a-who { flex: 1 1 auto; } }
.assignee-row .a-name { font-weight: 600; }
.assignee-row .a-meta { font-size: 12.5px; color: var(--ink-muted); margin-top: 1px; }
.assignee-row .a-status { flex: 1 1 auto; min-width: 140px; width: auto; }
.assignee-row .a-remove { flex: none; min-width: 0; width: 44px; padding: 0; }
@media (min-width: 700px) { .assignee-row .a-status { flex: none; } }

.timeline { display: flex; flex-direction: column; gap: 15px; }
.timeline-item { display: flex; gap: 11px; }
.timeline-item .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); margin-top: 6px; flex: none;
}
.timeline-item .body { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14.5px; }
.timeline-item .meta { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; }

.attachment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  flex-wrap: wrap;
}
.attachment-row:first-child { padding-top: 0; }
.attachment-row:last-child { border-bottom: none; padding-bottom: 0; }
.attachment-row .fname { flex: 1; min-width: 140px; overflow-wrap: anywhere; font-weight: 600; }
.attachment-row .fmeta { font-size: 12.5px; color: var(--ink-muted); width: 100%; }
@media (min-width: 700px) {
  .attachment-row .fmeta { width: auto; }
}

/* =================================================================
   Tables — real tables on a wide screen, stacked cards on a phone
   ================================================================= */

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  background: var(--surface-2);
  font-weight: 700;
}
tr:last-child td { border-bottom: none; }

/* Below 860px a .stack-table turns each row into its own card, with the
   column heading printed beside each value. No sideways scrolling. */
@media (max-width: 859px) {
  .stack-table, .stack-table thead, .stack-table tbody,
  .stack-table th, .stack-table td, .stack-table tr { display: block; }
  .stack-table thead { display: none; }
  .stack-table { font-size: 14.5px; }
  .stack-table tr {
    border-bottom: 1px solid var(--line);
    padding: 14px 15px;
  }
  .stack-table tr:last-child { border-bottom: none; }
  .stack-table td {
    border: none;
    padding: 3px 0;
    display: grid;
    grid-template-columns: 40% 1fr;
    gap: 10px;
    align-items: start;
  }
  .stack-table td::before {
    content: attr(data-label);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-muted);
    font-weight: 700;
    padding-top: 2px;
  }
  /* A cell marked data-primary is the row's headline: full width, no label. */
  .stack-table td[data-primary] {
    display: block;
    font-weight: 600;
    font-size: 16px;
    padding-bottom: 7px;
  }
  .stack-table td[data-primary]::before { content: none; }
  .stack-table td[data-empty]:empty { display: none; }
  /* A grid item stretches by default, which would smear a status pill across
     the whole value column. Several pills in one cell go in a .cellwrap. */
  .stack-table td > .pill,
  .stack-table td > .cellwrap,
  .stack-table td > .badge-role,
  .stack-table td > .tag-chip { justify-self: start; }
  .stack-table td > .cellwrap { display: flex; gap: 6px; flex-wrap: wrap; }
  .stack-table tr.is-clickable { cursor: pointer; }
  .stack-table tr.is-clickable:active { background: var(--surface-2); }
}

/* Any table that must keep its grid (rare) can scroll inside its wrapper. */
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 720px; }

/* =================================================================
   Toast, idle warning, misc
   ================================================================= */

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom));
  background: var(--ink);
  color: #fff;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  box-shadow: var(--shadow);
  z-index: 60;
  text-align: center;
}
@media (min-width: 900px) {
  .toast { left: auto; right: 24px; bottom: 24px; max-width: 380px; text-align: left; }
}

.idle-warning {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--status-new); color: #fff;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  text-align: center; font-size: 14px;
}

/* The label is the tap target, not just the box, so it carries the height. */
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 400;
  font-size: 15px;
  margin: 0 0 6px;
  padding: 7px 0;
  cursor: pointer;
  min-height: var(--tap);
}
.check-row input[type="checkbox"] {
  width: 22px; height: 22px; min-height: 0; margin: 0; flex: none;
  accent-color: var(--accent);
}
.check-row span { flex: 1; }

.hint { font-size: 13px; color: var(--ink-muted); }

/* =================================================================
   Printable paper forms — unchanged from the paper originals.
   Reproduces the facility's Nursing Home Resident Grievance Form and
   Grievance/Concern Log. Calibri first, so a printed page matches
   what came out of Word before.
   ================================================================= */

.print-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.print-bar .btn { flex: 1; min-width: 150px; }
.print-bar .hint { flex-basis: 100%; }
@media (min-width: 700px) {
  .print-bar .btn { flex: 0 0 auto; min-width: 0; }
  .print-bar .hint { flex-basis: auto; }
}

.paper {
  background: #ffffff;
  color: #000000;
  max-width: 8.5in;
  margin: 0 auto 24px;
  padding: 0.55in 0.5in;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-family: Calibri, Carlito, "Segoe UI", "Public Sans", sans-serif;
  font-size: 11.5pt;
  line-height: 1.35;
  /* A letter-width page must never push the phone layout sideways. */
  overflow-x: auto;
}
@media (min-width: 900px) { .paper { padding: 0.8in 0.9in; } }

.paper .pf-title {
  font-family: inherit;
  text-align: center;
  font-size: 14pt;
  font-weight: 700;
  margin: 0 0 14pt;
}
.paper .pf-title2 {
  font-family: inherit;
  font-size: 13pt;
  font-weight: 700;
  margin: 0 0 4pt;
}
.paper .pf-subhead { font-size: 10pt; color: #333; margin: 0 0 14pt; }
.paper .pf-facility { font-weight: 700; margin: 0 0 14pt; }

.paper .pf-line { margin: 0 0 7pt; font-weight: 700; }
.paper .pf-line .fill {
  font-weight: 400;
  display: inline-block;
  border-bottom: 1px solid #000;
  padding: 0 4px;
  margin-left: 2px;
  max-width: 100%;
}
.paper .pf-line .fill.blank { border-bottom: 1px solid #000; }
.paper .sig-line {
  display: inline-block;
  border-bottom: 1px solid #000;
  min-width: 3.6in;
  max-width: 100%;
  margin-left: 4px;
}
.paper .pf-sig { margin-top: 18pt; }

.paper .pf-q { font-weight: 700; margin: 16pt 0 2pt; }
.paper .pf-q.pf-section { margin-top: 26pt; }
.paper .pf-note { font-size: 10pt; font-style: italic; margin: 0 0 6pt; color: #333; }
.paper .pf-answer {
  white-space: pre-wrap;
  min-height: 0.55in;
  border-bottom: 1px solid #cfcfcf;
  padding: 2pt 0 6pt;
  overflow-wrap: anywhere;
}
.paper .pf-answer.short { min-height: 0.28in; }

.paper .pf-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 10pt;
  margin: 4pt 0 14pt;
  display: table;
}
.paper .pf-table thead { display: table-header-group; }
.paper .pf-table tr { display: table-row; padding: 0; border: none; }
.paper .pf-table th,
.paper .pf-table td {
  display: table-cell;
  border: 1px solid #000;
  padding: 4pt 6pt;
  text-align: left;
  vertical-align: top;
  background: none;
  text-transform: none;
  letter-spacing: 0;
  color: #000;
  font-size: 10pt;
  font-weight: 400;
}
.paper .pf-table th { font-weight: 700; background: #f0f0f0; }
.paper .pf-table td::before { content: none !important; }
.paper .log-table td:nth-child(5) { width: 34%; }

/* Attachment pages printed behind the form */
.exhibit-page { display: flex; flex-direction: column; }
.exhibit-head {
  font-size: 9.5pt;
  border-bottom: 1px solid #000;
  padding-bottom: 4pt;
  margin-bottom: 10pt;
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}
.exhibit-head .exhibit-ref { margin-left: auto; color: #444; }
.exhibit-img {
  display: block;
  max-width: 100%;
  max-height: 9in;
  margin: 0 auto;
  object-fit: contain;
  border: 1px solid #ddd;
}

@media print {
  @page { size: letter portrait; margin: 0.5in; }
  .exhibit-img { border: none; max-height: 9.2in; }
  html, body { background: #ffffff !important; }
  .sidebar, .topbar, .tabbar, .print-bar, .no-print, .toast,
  .sheet-backdrop, .idle-warning { display: none !important; }
  .shell { display: block; }
  .main { padding: 0 !important; max-width: none !important; }
  .paper {
    max-width: none;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    font-size: 11pt;
    overflow: visible;
  }
  .paper .pf-table { page-break-inside: auto; }
  .paper .pf-table tr { page-break-inside: avoid; }
  .page-break { page-break-before: always; padding-top: 0; }
  .backup-codes { page-break-inside: avoid; grid-template-columns: repeat(2, 1fr); }
  .backup-codes code { border: 1px solid #000; background: none; }
}
