:root {
  color-scheme: light;
  --ink: #14213D;
  --paper: #F5F6F3;
  --surface: #FFFFFF;
  --muted: #5B6472;
  --line: #DCDFD6;
  --civic-blue: #1D5FA8;
  --civic-blue-dark: #123E72;
  --civic-blue-tint: #E8F0FA;
  --signal-amber: #C97A0E;
  --signal-amber-tint: #FCF0DD;
  --go-green: #2E8B57;
  --go-green-tint: #E7F3EC;
  --danger: #A3301C;
  --danger-tint: #FBEAE6;
  --focus: #123E72;
  --font-display: 'Barlow Semi Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
}

p { margin: 0 0 0.75rem; max-width: 60ch; }

/* ---------- App bar ---------- */

header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.brand { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--civic-blue);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.identity { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.identity-chip {
  display: none;
}
@media (min-width: 480px) {
  .identity-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--muted);
  }
}
.role-pill {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--civic-blue-tint);
  color: var(--civic-blue-dark);
}

main { padding: 1rem 1rem 3rem; max-width: 640px; margin: 0 auto; }

/* ---------- Buttons & form controls ---------- */

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

button {
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
}
button.primary {
  background: var(--civic-blue);
  color: #fff;
  border-color: var(--civic-blue);
}
button.primary:hover { background: var(--civic-blue-dark); }
button.ghost {
  background: none;
  border-color: transparent;
  color: var(--civic-blue-dark);
  padding-left: 0.4rem;
  padding-right: 0.4rem;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

label { display: block; font-weight: 600; margin-bottom: 0.3rem; font-size: 0.95rem; }

input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 1rem;
  min-height: 44px;
  background: var(--surface);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--civic-blue); }

.field-group { margin-bottom: 1rem; }

/* ---------- Status / live regions ---------- */

[role="alert"], [role="status"]:not(.attention-banner) {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}
[role="alert"] { background: var(--danger-tint); border: 1px solid var(--danger); color: var(--danger); }
[role="status"]:not(.attention-banner) { background: var(--civic-blue-tint); border: 1px solid var(--civic-blue); }

.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;
}

.optional-fields {
  margin: 0.5rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 0.9rem;
}
.optional-fields summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.75rem 0;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.optional-fields[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 0.75rem; }
.optional-fields summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Sign-in screen ---------- */

.hero-band {
  margin: -1rem -1rem 1.5rem;
  padding: 2.25rem 1.25rem 2.5rem;
  background: linear-gradient(160deg, var(--civic-blue) 0%, var(--civic-blue-dark) 100%);
  color: #fff;
}
.hero-band h2 {
  font-size: clamp(1.75rem, 7vw, 2.4rem);
  color: #fff;
  margin-bottom: 0.5rem;
}
.hero-band p {
  color: rgba(255,255,255,0.85);
  max-width: 44ch;
  margin: 0;
}

.role-toggle {
  display: flex;
  background: var(--civic-blue-tint);
  border-radius: 999px;
  padding: 0.25rem;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}
.role-toggle button {
  flex: 1;
  border: none;
  border-radius: 999px;
  background: none;
  min-height: 40px;
  padding: 0.4rem 0.5rem;
  font-weight: 600;
  color: var(--civic-blue-dark);
}
.role-toggle button[aria-pressed="true"] {
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(18, 62, 114, 0.18);
}
.role-copy { color: var(--muted); margin-bottom: 1.5rem; min-height: 1.5em; }

.login-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 1.5rem;
}
.login-card h3 { font-size: 1.2rem; margin-bottom: 0.35rem; }
.login-card > p.meta { margin-bottom: 1rem; }
.login-card > button.ghost { display: block; margin: 1rem auto 0; }

.locate-btn {
  margin: -0.5rem 0 1rem;
  font-size: 0.85rem;
  min-height: 36px;
  padding: 0.3rem 0.7rem;
}

/* The Catalyst SDK injects its own iframe with an inline height:100%,
   sized for a standalone hosted login page — that resolves against the
   full viewport height (verified live: ~840px) even though the actual
   form only needs ~300px, leaving a huge blank area below the widget.
   Override with !important (a stylesheet rule beats any non-!important
   inline style) and let the iframe's own scrollbar handle any step of
   the flow that's taller than this. */
#catalyst-signin { max-width: 100%; }
#catalyst-signin iframe {
  width: 100% !important;
  height: 480px !important;
  border: none !important;
}

/* ---------- Page intro / greeting ---------- */

.page-intro { margin-bottom: 1.25rem; }
.page-intro h2 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.page-intro .eyebrow {
  display: block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--civic-blue-dark);
  margin-bottom: 0.15rem;
}
.page-intro p { color: var(--muted); margin: 0; }

/* ---------- Attention banner (ticket-stub style) ---------- */

.attention-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: var(--signal-amber-tint);
  border-left: 4px solid var(--signal-amber);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 1.5rem;
}
.attention-banner .attention-text { font-weight: 600; }
.attention-banner button {
  background: none;
  border: none;
  color: var(--civic-blue-dark);
  font-weight: 700;
  min-width: auto;
  min-height: 36px;
  padding: 0.2rem 0.4rem;
}

/* ---------- Quick-request rail ---------- */

.quick-tiles-section { margin-bottom: 1.75rem; }
.quick-tiles-section h3 { font-size: 1.05rem; margin-bottom: 0.6rem; }
.quick-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}
@media (min-width: 420px) {
  .quick-tiles { grid-template-columns: repeat(3, 1fr); }
}
.quick-tile {
  min-height: 108px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  border-top: 4px solid var(--tile-accent, var(--civic-blue));
  background: var(--surface);
  padding: 0.75rem 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.quick-tile:hover { border-color: var(--tile-accent, var(--civic-blue)); }
.quick-tile-icon { font-size: 1.4rem; }
.quick-tile-name { font-weight: 600; font-size: 0.88rem; line-height: 1.25; }

/* ---------- Card sections & ticket-stub list ---------- */

.card-section {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 1.1rem;
}
.card-section > .toolbar { margin-bottom: 0.9rem; justify-content: space-between; }
.card-section h3 { margin: 0; font-size: 1.1rem; }

.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar select { margin-bottom: 0; width: auto; min-width: 0; flex: 1 1 auto; }

.fab {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 999px;
  background: var(--civic-blue);
  color: #fff;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fab:hover { background: var(--civic-blue-dark); }

ul.ticket-list { list-style: none; padding: 0; margin: 0; }
ul.ticket-list li {
  border: 1px solid var(--line);
  border-left: 4px solid var(--stub-accent, var(--civic-blue));
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}
ul.ticket-list button.ticket-open {
  width: 100%;
  text-align: left;
  border: none;
  padding: 0;
  background: none;
  min-height: auto;
  font-weight: 700;
  color: var(--ink);
}
ul.ticket-list button.ticket-open:hover { color: var(--civic-blue-dark); }

.meta { color: var(--muted); font-size: 0.88rem; margin: 0.2rem 0 0; }

.tag-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.3rem 0 0.5rem; }
.tag {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--civic-blue-tint);
  color: var(--civic-blue-dark);
}

/* ---------- Admin: people list ---------- */

.user-row {
  border-bottom: 1px solid var(--line);
  padding: 0.9rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.user-row:last-child { border-bottom: none; }
.user-info { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.user-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.user-controls select { width: auto; min-width: 0; flex: 1 1 140px; margin-bottom: 0; }
.user-controls button { flex-shrink: 0; }

/* ---------- Stage progress (segmented, not a continuous bar) ---------- */

.stage-progress { margin-top: 0.6rem; }
.stage-label { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.3rem; }
.stage-segments { display: flex; gap: 4px; }
.stage-segment {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
}
.stage-segment.filled { background: var(--civic-blue); }
.stage-segment.done { background: var(--go-green); }

/* ---------- Stage timeline (full vertical view, citizen ticket detail) ---------- */

.stage-timeline { margin: 0.75rem 0 1.5rem; }
.stage-timeline-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  position: relative;
  padding-bottom: 1.25rem;
}
.stage-timeline-item:last-child { padding-bottom: 0; }
.stage-timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 24px;
  bottom: 0;
  width: 2px;
  background: var(--line);
}
.stage-timeline-item.complete:not(:last-child)::before { background: var(--go-green); }
.stage-timeline-dot {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.stage-timeline-item.complete .stage-timeline-dot { background: var(--go-green); border-color: var(--go-green); color: #fff; }
.stage-timeline-item.current .stage-timeline-dot { background: var(--civic-blue); border-color: var(--civic-blue); color: #fff; }
.stage-timeline-label { font-weight: 700; }
.stage-timeline-item.upcoming .stage-timeline-label { color: var(--muted); font-weight: 600; }
.stage-timeline-sub { font-size: 0.85rem; color: var(--muted); margin-top: 0.1rem; }

/* ---------- Persona/contact panel ---------- */

.panel360 {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.1rem;
  background: var(--civic-blue-tint);
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}
.panel360-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--civic-blue);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.panel360 p { margin: 0; }
.panel360 p.name { font-weight: 700; }

/* ---------- Conversation timeline ---------- */

.convo-day-heading {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  margin: 1.1rem 0 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}
.convo-day-heading:first-child { margin-top: 0; }

.conversation-item {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.5rem 0;
}
.convo-icon-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--civic-blue-tint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
.convo-body { min-width: 0; }
.convo-text { margin: 0; }
.convo-body .meta { margin-top: 0.15rem; }

/* ---------- Sticky submit bar (create-request form) ---------- */

.sticky-submit-bar {
  position: sticky;
  bottom: 0;
  margin: 1.5rem -1rem -3rem;
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.sticky-submit-bar button { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
