:root {
  --bg: #eef2f8;
  --bg-2: #e3e9f3;
  --surface: #ffffff;
  --ink: #0b1220;
  --ink-2: #334155;
  --muted: #5b6b80;
  --line: #d5dee9;
  --brand: #1d4ed8;
  --brand-dark: #1739a8;
  --teal: #0f766e;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.05);
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dbe7ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #d8f3ef 0%, transparent 50%),
    var(--bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.2px;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand .brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--teal));
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.brand small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.hnav { display: flex; gap: 6px; flex-wrap: wrap; }
.hnav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.hnav a:hover { background: #edf2fb; text-decoration: none; }
.hnav a.active { background: var(--ink); color: #fff; }
.hnav a.ext {
  margin-left: 6px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
  border-radius: 0 999px 999px 0;
  color: var(--brand);
}
.hnav a.ext:hover { background: #eef4ff; }

.authbox { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink-2);
}
.chip.admin { background: #e0e7ff; border-color: #c7d2fe; color: #1e3a8a; }
.chip.clerk { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.chip.planner { background: #fef3c7; border-color: #fde68a; color: #78350f; }

/* ------------------------------------------------------------------ layout */

main { max-width: 1180px; margin: 0 auto; padding: 30px 24px 64px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--teal);
}
h1 { margin: 0 0 8px; font-size: clamp(26px, 3.4vw, 38px); line-height: 1.15; letter-spacing: -0.5px; }
.sub { margin: 0; color: var(--muted); max-width: 68ch; }

/* ------------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 26px 0 22px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat .lbl { font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.stat.s-not_started { border-top: 4px solid #b91c1c; }
.stat.s-in_progress { border-top: 4px solid #d97706; }
.stat.s-under_review { border-top: 4px solid #2563eb; }
.stat.s-rejected { border-top: 4px solid #991b1b; }
.stat.s-approved { border-top: 4px solid #16a34a; }
.stat.s-not_started .num { color: #b91c1c; }
.stat.s-in_progress .num { color: #92400e; }
.stat.s-under_review .num { color: #1e40af; }
.stat.s-rejected .num { color: #991b1b; }
.stat.s-approved .num { color: #166534; }
.stat-check { color: #15803d; font-weight: 900; }

/* ------------------------------------------------------------------- panel */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  /* Pagination scrolls the panel into view; leave room for the sticky topbar. */
  scroll-margin-top: 92px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfdff, #f6f9fe);
}
.panel-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.2px; }
.muted { color: var(--muted); font-size: 13.5px; }

.list { display: flex; flex-direction: column; }

.item {
  display: grid;
  grid-template-columns: 1.15fr 2.2fr 1fr 0.85fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e8eef6;
  background: #fff;
}
.item:last-child { border-bottom: 0; }
.item:hover { background: #fbfdff; }

.item .loc { font-weight: 800; font-size: 15.5px; overflow-wrap: anywhere; }
.item .meta { margin-top: 3px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.item .sum {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* Shift marker: night shift must stand out from the surrounding meta text. */
.shift-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}
.shift-pill.day {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #475569;
}
.shift-pill.night {
  background: linear-gradient(135deg, #1e293b, #3730a3);
  border-color: #4338ca;
  color: #fff;
  box-shadow: 0 2px 8px rgba(49, 46, 129, 0.35);
}
.item .urq { font-size: 12.5px; font-weight: 800; }
.meta-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.item .files-mini { margin-top: 4px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; min-width: 0; }
.item .meta-col { min-width: 0; }
.file-chip {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  cursor: pointer;
}
.file-chip:hover { color: var(--brand); }
.file-chip.is-image { cursor: zoom-in; }
.file-chip + .file-chip { margin-top: 2px; }
.files-toggle {
  margin-top: 5px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.files-toggle:hover { text-decoration: underline; }
.files-full {
  margin-top: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--line);
  max-height: 148px;
  overflow-y: auto;
}
.file-line { margin: 3px 0; }

/* --------------------------------------------------- image hover / lightbox */

.img-preview {
  position: fixed;
  z-index: 70;
  left: 0;
  top: 0;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.2);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
  pointer-events: auto;
}
.img-preview.show { opacity: 1; visibility: visible; }
.img-preview.multi { min-width: 210px; }
.img-preview img { display: block; margin: 0 auto; max-width: 260px; max-height: 260px; border-radius: 7px; }
.img-preview-loading { padding: 18px 22px; font-size: 12.5px; color: var(--muted); }
.img-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 19px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}
.img-nav.prev { left: 10px; }
.img-nav.next { right: 10px; }
.img-nav:hover { background: #eef4ff; border-color: #c7d7f2; }
.img-preview-count {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.img-preview-count.show { display: block; }

.img-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: rgba(9, 15, 30, 0.8);
  backdrop-filter: blur(2px);
}
.img-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 94vw;
  max-height: 92vh;
}
.img-modal-body img {
  display: block;
  max-width: 92vw;
  max-height: 82vh;
  max-height: 82dvh;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  background: #fff;
}
.img-modal-caption {
  max-width: 90vw;
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
  text-align: center;
}
.img-modal-loading { color: #e2e8f0; font-size: 13px; }
.img-modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.img-modal-nav.prev { left: 20px; }
.img-modal-nav.next { right: 20px; }
.img-modal-nav:hover { background: rgba(255, 255, 255, 0.3); }
.img-modal-count {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.img-modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.img-modal-close:hover { background: rgba(255, 255, 255, 0.26); }
body.modal-open { overflow: hidden; }

@media (max-width: 700px) {
  .img-preview { display: none; }
  .img-modal { padding: 16px; }
  .img-modal-nav { width: 38px; height: 38px; font-size: 23px; }
  .img-modal-nav.prev { left: 8px; }
  .img-modal-nav.next { right: 8px; }
  .img-modal-count { top: 12px; }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.not_started { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.badge.not_started::before { background: #fff; }
.badge.in_progress { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge.under_review { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.badge.rejected { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge.approved { background: #dcfce7; color: #14532d; border-color: #86efac; }
.badge.approved::before {
  content: "✓";
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  color: #15803d;
  opacity: 1;
}

/* Urgency scale: green/blue = not urgent, yellow = medium, orange/red = urgent. */
.urgency-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.2;
}
.urgency-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}
.urgency-pill b { font-weight: 800; opacity: 0.9; }
.u-low { background: linear-gradient(135deg, #166534, #0e7490); color: #fff; }
.u-medium { background: #facc15; color: #3f2d00; }
.u-medium::before { box-shadow: 0 0 0 3px rgba(63, 45, 0, 0.15); }
.u-high { background: #c2410c; color: #fff; }
.u-critical { background: #991b1b; color: #fff; }

.urgency-legend {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin: 0 0 20px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.legend-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}
.urgency-legend .urgency-pill { padding: 3px 9px; font-size: 10.5px; }

/* Colored spine on each lifting card. */
.item.status-not_started { border-left: 5px solid #b91c1c; }
.item.status-in_progress { border-left: 5px solid #d97706; }
.item.status-under_review { border-left: 5px solid #2563eb; }
.item.status-rejected { border-left: 5px solid #991b1b; }
.item.status-approved { border-left: 5px solid #16a34a; }

.item.urgency-low { border-left: 5px solid #0e7490; }
.item.urgency-medium { border-left: 5px solid #eab308; }
.item.urgency-high { border-left: 5px solid #c2410c; }
.item.urgency-critical { border-left: 5px solid #991b1b; }

label.field select.urgency-select { border-left-width: 7px; }
label.field select.urgency-select.u-low { border-left-color: #0e7490; background: #f0fdfa; }
label.field select.urgency-select.u-medium { border-left-color: #eab308; background: #fefce8; }
label.field select.urgency-select.u-high { border-left-color: #c2410c; background: #fff7ed; }
label.field select.urgency-select.u-critical { border-left-color: #991b1b; background: #fef2f2; }

/* ----------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(29, 78, 216, 0.25); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { background: #f1f5fb; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fecaca; }
.btn.link { background: none; border: 0; color: var(--brand); padding: 4px 6px; font-size: 12.5px; }
.btn.link:hover { text-decoration: underline; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.hidden { display: none !important; }

/* ------------------------------------------------------------------- modal */

dialog.modal {
  width: min(680px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 70px rgba(15, 23, 42, 0.35);
  color: var(--ink);
  background: #fff;
}
dialog.modal::backdrop { background: rgba(9, 17, 32, 0.55); backdrop-filter: blur(2px); }
.modal form, .modal .modal-body { padding: 22px 24px 24px; }
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal .hint { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label.field { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
label.field input,
label.field select,
label.field textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-family: inherit;
  /* 16px keeps iOS Safari from zooming the page when a field is focused. */
  font-size: 16px;
  color: var(--ink);
  background: #fff;
}
label.field textarea { resize: vertical; min-height: 84px; }
label.field input:focus,
label.field select:focus,
label.field textarea:focus { outline: 3px solid #bfdbfe; border-color: var(--brand); }
label.field input:disabled,
label.field select:disabled,
label.field textarea:disabled { background: #f1f5f9; color: #475569; }

.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.spacer { flex: 1; }
.error { color: var(--danger); font-size: 13.5px; font-weight: 700; min-height: 18px; margin: 4px 0 10px; }

/* ------------------------------------------------------------------- files */

.filelist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 10px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-gutter: stable;
}
.file-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  font-size: 13.5px;
}
.file-row .fname {
  flex: 1 1 160px;
  min-width: 0;
  font-weight: 700;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-row .fsize { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.file-row a, .file-row .btn.link { font-size: 12.5px; font-weight: 700; white-space: nowrap; }

.dropzone {
  border: 2px dashed #b9c7da;
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  background: #f8fafc;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--brand); background: #f0f5ff; }
.dropzone.drag-over {
  border-color: var(--brand);
  background: #e8f0ff;
  box-shadow: inset 0 0 0 1px var(--brand);
}
.dropzone input { display: none; }
.dropzone strong { color: var(--brand); }

/* -------------------------------------------------------------------- home */

.hero { padding: 56px 0 26px; text-align: center; }
.hero .eyebrow { color: var(--brand); }
.hero h1 { font-size: clamp(32px, 5vw, 52px); letter-spacing: -1px; }
.hero p { color: var(--muted); font-size: 17px; max-width: 62ch; margin: 12px auto 0; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 34px 0 10px; }
.card-link {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
  overflow: hidden;
}
.card-link:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(15, 23, 42, 0.13); text-decoration: none; }
.card-link::after {
  content: "";
  position: absolute;
  inset: 0 0 autoauto;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(29, 78, 216, 0.12), transparent 70%);
}
.card-link.b::after { background: radial-gradient(circle, rgba(15, 118, 110, 0.14), transparent 70%); }
.card-link .tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--brand);
  background: #e8efff;
  padding: 5px 10px;
  border-radius: 999px;
}
.card-link.b .tag { color: #0f766e; background: #d9f4f0; }
.card-link h2 { margin: 14px 0 8px; font-size: 23px; letter-spacing: -0.4px; }
.card-link p { margin: 0; color: var(--muted); font-size: 14.5px; }
.card-link .go { margin-top: 18px; font-weight: 800; font-size: 14px; color: var(--brand); }
.card-link.b .go { color: var(--teal); }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 34px 0 10px; }

/* ------------------------------------------------------------------- toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  max-width: calc(100vw - 40px);
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #991b1b; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .item { grid-template-columns: 1fr auto; grid-template-areas: "head status" "sum sum" "meta action"; gap: 10px 12px; }
  .item .head { grid-area: head; }
  .item .sum { grid-area: sum; }
  .item .meta-col { grid-area: meta; }
  .item .badge-wrap { grid-area: status; justify-self: end; }
  .item .actions { grid-area: action; justify-self: end; }
}

@media (max-width: 700px) {
  .topbar {
    padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    gap: 10px;
  }
  .brand { min-width: 0; flex: 1 1 auto; }
  .brand > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand small { display: none; }
  .hnav {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .authbox { margin-left: auto; flex: 0 0 auto; }
  main {
    padding: 20px max(14px, env(safe-area-inset-right)) 48px max(14px, env(safe-area-inset-left));
  }
  .stats {
    display: flex;
    gap: 8px;
    margin: 18px 0 16px;
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .stat { flex: 0 0 112px; padding: 11px 13px; }
  .stat .num { font-size: 21px; }
  .urgency-legend { padding: 10px 12px; gap: 6px; margin-bottom: 16px; }
  .urgency-legend .urgency-pill { padding: 3px 9px; font-size: 10.5px; }
  .cards { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .panel-head { padding: 14px 15px; }
  .panel { scroll-margin-top: 150px; }
  .item { padding: 14px 15px; }
  .hero { padding: 34px 0 10px; text-align: left; }
  .hero p { margin-left: 0; }
  .modal form { padding: 18px 16px 20px; }
  /* iOS Safari zooms the page when a focused control is smaller than 16px. */
  label.field input,
  label.field select,
  label.field textarea,
  .pager-jump input {
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  /* Keep the brand mark but drop the long title so the auth control and the
     nav do not stack into a very tall sticky header on phones. */
  .brand > span:last-child { display: none; }
  h1 { font-size: 21px; }
}

/* Short landscape phones: keep the whole header on one compact row. */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { padding: 8px 16px; gap: 10px; flex-wrap: nowrap; }
  .brand > span:last-child { display: none; }
  .hnav {
    order: 0;
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .authbox { flex: 0 0 auto; }
}

/* ---------------------------------------------------------------- pagination */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: #fbfdff;
}
.pager-info { font-size: 13px; color: var(--muted); }
.pager-info strong { color: var(--ink-2); }
.pager-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.pager-btn:hover:not(:disabled):not(.active) { background: #eef4ff; border-color: #c7d7f2; }
.pager-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; cursor: default; }
.pager-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.pager-gap { color: var(--muted); padding: 0 2px; font-weight: 700; }
.pager-jump { display: flex; align-items: center; gap: 6px; }
.pager-jump label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.pager-jump input {
  width: 64px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  font-size: 16px;
  text-align: center;
}

@media (max-width: 700px) {
  .pager { padding: 12px 15px; justify-content: center; }
  .pager-jump { width: 100%; justify-content: center; }
  .pager-btn { min-width: 40px; height: 40px; }
}

/* ------------------------------------------------------------- utilities */

.empty-state { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 34px; margin-bottom: 8px; }
.empty-title { color: var(--ink-2); }
.empty-sub { font-size: 13.5px; margin-top: 4px; }
.note { padding: 4px 0 8px; }
.danger-link { color: var(--danger); }
.file-row.removing { opacity: 0.45; }
.files-head { padding: 0 0 8px; border: 0; background: none; }
.files-title { font-size: 13px; color: var(--ink-2); }
.file-size { color: var(--muted); font-weight: 600; }
