:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-soft: #ccfbf1;
  --primary-50: #f0fdfa;
  --accent: #0ea5e9;

  --bg: #f0fdfa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #475569;
  --text-soft: #64748b;

  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;

  --pending: #d97706;
  --pending-soft: #fef3c7;
  --work: #2563eb;
  --work-soft: #dbeafe;
  --done: #16a34a;
  --done-soft: #dcfce7;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 6px 20px -8px rgba(15, 23, 42, 0.18), 0 2px 6px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 40px -16px rgba(13, 148, 136, 0.35), 0 6px 14px -6px rgba(15, 23, 42, 0.12);

  --container: 960px;
  --container-form: 720px;
}

* {
  box-sizing: border-box;
}

/*
 * The HTML `hidden` attribute should always win over class-level display
 * rules (e.g. `.topbar-btn { display: inline-flex }`). Without this, setting
 * `el.hidden = true` from JS would have no visible effect.
 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(13, 148, 136, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(14, 165, 233, 0.10), transparent 60%),
    var(--bg);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  margin: 0 0 .25rem;
  color: var(--text);
  line-height: 1.25;
}
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }

p { margin: 0; }
.muted { color: var(--text-muted); font-size: .9rem; }
.hint { color: var(--text-soft); font-size: .85rem; margin: .25rem 0 0; text-align: center; }

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: var(--shadow-sm);
}
.brand-text { letter-spacing: .2px; }

.topbar-end {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar-user {
  text-align: right;
  line-height: 1.2;
}
.topbar-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
}
.topbar-flat {
  font-size: .75rem;
  color: var(--text-muted);
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.logout-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary-soft);
  color: var(--primary-dark);
}
.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.topbar-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary-soft);
  color: var(--primary-dark);
}

/* ===== Topbar dropdown menu (Settings) ===== */
.menu-wrap {
  position: relative;
  display: inline-flex;
}
.menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  min-width: 210px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .92rem;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.menu-item:hover {
  background: var(--primary-50);
  color: var(--primary-dark);
}
.menu-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.menu-item-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ===== Notification bell ===== */
.bell-wrap {
  position: relative;
  display: inline-flex;
}
.bell-btn {
  position: relative;
  padding: 8px 12px;
}
.bell-wrap.is-open .bell-btn {
  background: var(--primary-50);
  border-color: var(--primary-soft);
  color: var(--primary-dark);
}
/* The ring matches the topbar background so the dot reads as a separate mark
   rather than smudging into the bell icon behind it. */
.bell-dot {
  position: absolute;
  top: 5px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

.bell-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  width: 340px;
  max-height: 440px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.bell-head {
  position: sticky;
  top: 0;
  background: var(--surface);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.bell-head h2 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}
.bell-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.bell-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.bell-item:last-child { border-bottom: 0; }
.bell-item.is-unread { background: var(--primary-50); }
.bell-tone {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--text-soft);
}
.bell-tone-done    { background: var(--done); }
.bell-tone-work    { background: var(--work); }
.bell-tone-pending { background: var(--pending); }
.bell-tone-alert   { background: var(--danger); }
.bell-item-body { min-width: 0; }
.bell-message {
  font-size: .88rem;
  line-height: 1.35;
  color: var(--text);
}
.bell-meta {
  margin-top: 3px;
  font-size: .73rem;
  color: var(--text-soft);
}
.bell-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: .88rem;
}
.bell-empty .muted { color: var(--text-soft); font-size: .8rem; }

/* ===== Main view ===== */
.view {
  padding: 24px 24px 80px;
  max-width: var(--container);
  margin: 0 auto;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 18px;
  min-height: 48px;
  cursor: pointer;
  transition: transform .04s ease, background .15s ease, box-shadow .15s ease;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(13, 148, 136, 0.6);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-block { width: 100%; margin-top: 8px; }

.back-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 6px 8px;
  margin-left: -8px;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.back-link:hover {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

/* ===== Page header ===== */
.page-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.page-title h1 { font-size: 1.6rem; }
.page-title .muted { font-size: .95rem; }

/* Form section header inside a card */
.form-section-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.form-section-head h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}
.form-section-head .muted { font-size: .88rem; }

/* ===== Form fields ===== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  position: relative;
}
.field > span {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  min-height: 48px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  width: 100%;
}
.field textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.5;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.18);
  background: #fff;
}
.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-soft);
}
/* A password input paired with its show/hide control. The input reserves room
   on the right so a long password never runs underneath the button. */
.password-field {
  position: relative;
  display: block;
}
.password-field input {
  padding-right: 48px;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.password-toggle:hover {
  color: var(--primary-dark);
  background: var(--primary-50);
}
.password-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.password-icon { display: inline-flex; }

.field .counter {
  position: absolute;
  right: 8px;
  bottom: -18px;
  font-size: .75rem;
  color: var(--text-soft);
}
/* Explanatory text under an input. Unlike .counter this sits in normal flow,
   so it never overlaps whatever follows the field. */
.field .field-hint {
  font-size: .78rem;
  line-height: 1.45;
  color: var(--text-soft);
}
.field input:disabled,
.field select:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ===== Login ===== */
.view-login {
  display: flex;
  align-items: center;
  min-height: calc(100vh - 110px);
}
.login-shell {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
}
.login-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
}
.login-logo {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: var(--shadow-lg);
}
.login-hero h1 { font-size: 1.75rem; margin-top: 8px; }
.login-card {
  padding: 22px;
  box-shadow: var(--shadow);
}
.login-card h2 {
  text-align: center;
  margin-bottom: 18px;
}

/* ===== Dashboard ===== */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Welcome hero card */
.welcome-card {
  background: linear-gradient(135deg, #ecfeff 0%, #d1f5ee 55%, #cfeef8 100%);
  border: 1px solid rgba(13, 148, 136, 0.18);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
}
.welcome-eyebrow {
  color: var(--primary-dark);
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.welcome-name {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.5px;
  color: var(--text);
  margin-bottom: 10px;
  word-break: break-word;
}
.welcome-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: .92rem;
}
.flat-chip {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  font-size: .8rem;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(13, 148, 136, 0.25);
  padding: 4px 10px;
  border-radius: 999px;
}
.welcome-tag {
  color: var(--text-muted);
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
  min-height: 110px;
}
.stat-card:hover {
  border-color: var(--primary-soft);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.stat-card:active { transform: translateY(0); }
.stat-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary-dark);
  flex-shrink: 0;
}
.stat-total .stat-icon,
.metric-total .stat-icon { background: var(--primary-soft); color: var(--primary-dark); }
.stat-active .stat-icon,
.metric-pending .stat-icon { background: var(--pending-soft); color: var(--pending); }
.metric-work .stat-icon { background: var(--work-soft); color: var(--work); }
.stat-complete .stat-icon,
.metric-done .stat-icon { background: var(--done-soft); color: var(--done); }

.metric-pending { border-top: 3px solid var(--pending); }
.metric-work { border-top: 3px solid var(--work); }
.metric-done { border-top: 3px solid var(--done); }

.stat-cta {
  font-size: .78rem;
  color: var(--text-soft);
  margin-top: auto;
}
.metric-pending .stat-cta { color: var(--pending); }
.metric-work .stat-cta { color: var(--work); }
.metric-done .stat-cta { color: var(--done); }
.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  letter-spacing: -.5px;
  margin-top: 4px;
}
.stat-label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Action cards */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.action-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
  min-height: 110px;
}
.action-card:hover {
  border-color: var(--primary-soft);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.action-card:active { transform: translateY(0); }
.action-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.action-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.action-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.action-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.action-sub {
  color: var(--text-muted);
  font-size: .88rem;
  line-height: 1.45;
}
.action-arrow {
  color: var(--text-soft);
  display: inline-grid;
  place-items: center;
  margin-top: 6px;
  flex-shrink: 0;
  transition: transform .15s ease, color .15s ease;
}
.action-card:hover .action-arrow {
  color: var(--primary-dark);
  transform: translateX(2px);
}

/* Recent activity */
.recent-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}
.recent-head h2 {
  font-size: .78rem;
  letter-spacing: .8px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-soft);
}
.recent-link {
  background: none;
  border: 0;
  color: var(--primary-dark);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.recent-link:hover { background: var(--primary-soft); }

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.recent-item:last-child { border-bottom: 0; }
.recent-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.recent-text {
  flex: 1;
  min-width: 0;
}
.recent-title {
  font-weight: 600;
  color: var(--text);
  font-size: .95rem;
  line-height: 1.3;
}
.recent-sub {
  color: var(--text-muted);
  font-size: .82rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.recent-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.recent-date {
  font-size: .75rem;
  color: var(--text-soft);
}
.recent-empty {
  text-align: center;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.recent-empty .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  background: var(--primary-soft);
  margin-bottom: 4px;
}
.recent-empty .btn { margin-top: 10px; }

/* ===== Page (raise/complaints) ===== */
.page {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.page-narrow {
  max-width: var(--container-form);
  width: 100%;
  margin: 0 auto;
}
.form-card {
  padding: 24px;
}

/* ===== Filter bar ===== */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.filter-field > span {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-soft);
}
.filter-field select,
.filter-field input {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 42px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  width: 100%;
}
.filter-field select:focus,
.filter-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.18);
  background: #fff;
}
.filter-field input::placeholder { color: var(--text-soft); }

/* One search field plus the clear button. */
.filter-bar-single { grid-template-columns: 1fr auto; }

.filter-meta {
  margin: 10px 2px 0;
  font-size: .85rem;
  color: var(--text-muted);
}

/* Admin ticket controls: group-by, category, flat search, sort (+ dates). */
.controls-bar {
  display: grid;
  /* Narrow enough that a phone gets two columns instead of one tall stack
     that pushes the tickets themselves off the screen. */
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: end;
  gap: 10px;
  padding: 14px;
}
.controls-bar .filter-clear { align-self: end; }

.ticket-age {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.ticket-age.is-stale {
  background: var(--warning-soft);
  color: var(--warning);
}
.ticket-age.is-deleted {
  background: var(--danger-soft);
  color: var(--danger);
}
.ticket-age.is-done {
  background: var(--done-soft);
  color: var(--done);
}

/* Ungrouped list sits directly on the page, so it needs its own card edge. */
.ticket-list-flush {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Footer of a resident complaint card: the withdraw action. */
.complaint-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Page heading with an action button beside it. */
.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-title-row .page-title { min-width: 0; }
.btn-raise {
  flex-shrink: 0;
  padding: 10px 16px;
  min-height: 44px;
  font-size: .95rem;
}
@media (max-width: 480px) {
  .btn-raise { width: 100%; }
}

/* Recent ticket rows on the admin dashboard open the ticket. */
.recent-item-clickable {
  cursor: pointer;
  transition: background .15s ease;
}
.recent-item-clickable:hover { background: var(--primary-50); }
.recent-item-clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.recent-open {
  display: inline-grid;
  place-items: center;
  color: var(--text-soft);
  flex-shrink: 0;
}
.recent-item-clickable:hover .recent-open { color: var(--primary-dark); }

/* Flat owner + phone on one row, above the complaint description. */
.raiser-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.raiser-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
}
.raiser-nophone {
  font-size: .85rem;
  color: var(--text-soft);
}

/* ===== Grouped ticket sections ===== */
.group-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background .15s ease;
}
.group-head::-webkit-details-marker { display: none; }
.group-head:hover { background: var(--primary-50); }
.group-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  flex: 1 1 auto;
  min-width: 0;
}
.group-count {
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.group-chevron {
  display: inline-grid;
  place-items: center;
  color: var(--text-soft);
  flex-shrink: 0;
  transition: transform .15s ease;
}
.group-section[open] > .group-head > .group-chevron { transform: rotate(90deg); }
.group-section[open] > .group-head { border-bottom: 1px solid var(--border); }
.group-head:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.filter-clear {
  background: var(--surface);
  color: var(--primary-dark);
  border: 1px solid var(--primary-soft);
  border-radius: 10px;
  padding: 0 14px;
  height: 42px;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
  white-space: nowrap;
}
.filter-clear:hover {
  background: var(--primary-soft);
}

/* ===== Complaint cards ===== */
.complaint-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.complaint-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.complaint-card:hover {
  border-color: var(--primary-soft);
  box-shadow: var(--shadow);
}
.complaint-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 6px 10px;
}
.complaint-date {
  color: var(--text-soft);
  font-size: .8rem;
}
.complaint-desc {
  color: var(--text);
  font-size: .95rem;
  line-height: 1.55;
}

/* ===== Status badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge-active,
.badge-pending {
  background: var(--pending-soft);
  color: var(--pending);
  border-color: rgba(217, 119, 6, 0.25);
}
.badge-work {
  background: var(--work-soft);
  color: var(--work);
  border-color: rgba(37, 99, 235, 0.25);
}
.badge-complete,
.badge-done {
  background: var(--done-soft);
  color: var(--done);
  border-color: rgba(22, 163, 74, 0.25);
}
.badge-deleted { background: var(--danger-soft); color: var(--danger); }

/* ===== State banners inside complaint card ===== */
.state-banner {
  margin-top: 8px;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  font-size: .9rem;
}
.state-wait {
  background: var(--info-soft);
  color: #1e3a8a;
  align-items: center;
}
.state-wait p { margin: 0; line-height: 1.4; }
.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--info);
  position: relative;
  flex-shrink: 0;
}
.pulse-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  background: var(--info);
  opacity: .35;
  animation: pulse 1.6s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(.6); opacity: .45; }
  100% { transform: scale(1.6); opacity: 0; }
}

.state-worker {
  background: linear-gradient(135deg, #f0fdfa, #ecfeff);
  border: 1px solid var(--primary-soft);
  flex-direction: column;
  gap: 10px;
  color: var(--text);
}
.worker-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.worker-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.worker-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-soft);
  font-weight: 600;
}
.worker-name {
  font-weight: 600;
  font-size: 1rem;
}
.worker-prof {
  color: var(--text-muted);
  font-size: .85rem;
}
.worker-phone {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  color: var(--primary-dark);
  border: 1px solid var(--primary-soft);
  border-radius: 10px;
  padding: 10px 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
  min-height: 44px;
  justify-content: center;
  transition: background .15s ease;
}
.worker-phone:hover {
  background: var(--primary-soft);
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  background: var(--primary-soft);
  margin-bottom: 4px;
}
.empty-state .btn { margin-top: 10px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: #0f172a;
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: .95rem;
  font-weight: 500;
  box-shadow: 0 18px 40px -14px rgba(15, 23, 42, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  max-width: calc(100% - 32px);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast-success { background: linear-gradient(135deg, #15803d, #16a34a); }
.toast-error { background: linear-gradient(135deg, #b91c1c, #dc2626); }
.toast-info { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); }
.toast-icon { display: inline-grid; place-items: center; flex-shrink: 0; }

/* ===== Role selection ===== */
.view-role {
  display: flex;
  align-items: center;
  min-height: calc(100vh - 110px);
}
.role-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.role-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.role-hero h1 { font-size: 1.85rem; }
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.role-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 6px 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
  min-height: 130px;
}
.role-card:hover {
  border-color: var(--primary-soft);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.role-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.role-icon {
  grid-row: span 2;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: inline-grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.role-admin .role-icon {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
}
.role-title { font-size: 1.1rem; font-weight: 700; }
.role-sub {
  color: var(--text-muted);
  font-size: .9rem;
  grid-column: 2;
}
.role-arrow {
  grid-row: span 2;
  display: inline-grid;
  place-items: center;
  color: var(--text-soft);
  transition: transform .15s ease, color .15s ease;
}
.role-card:hover .role-arrow {
  color: var(--primary-dark);
  transform: translateX(2px);
}

.back-link-center {
  align-self: center;
  margin-bottom: -8px;
}
.login-logo-admin {
  background: linear-gradient(135deg, #1e293b, #0f172a) !important;
}

/* ===== Admin pages ===== */
.admin-hero {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  border-color: rgba(15, 23, 42, 0.15);
}
.admin-hero .welcome-eyebrow { color: #334155; }
.admin-hero .flat-chip {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(15, 23, 42, 0.15);
  color: #1e293b;
}

.recent-flat {
  font-weight: 500;
  color: var(--text-soft);
  font-size: .8rem;
  margin-left: 6px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.admin-tab {
  flex: 1 1 0;
  min-width: 120px;
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.admin-tab:hover { background: var(--primary-50); color: var(--primary-dark); }
.admin-tab.is-active.metric-pending { background: var(--pending-soft); color: var(--pending); }
.admin-tab.is-active.metric-work    { background: var(--work-soft); color: var(--work); }
.admin-tab.is-active.metric-done    { background: var(--done-soft); color: var(--done); }
.admin-tab.is-active.metric-deleted { background: var(--danger-soft); color: var(--danger); }


.flat-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.flat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.flat-head h3 { font-size: 1rem; font-weight: 700; }
.flat-count {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.ticket-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ticket-list-flat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.ticket-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s ease;
}
.ticket-row:last-child { border-bottom: 0; }
.ticket-row:hover { background: var(--surface-2); }
.ticket-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.ticket-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.ticket-body { min-width: 0; }
.ticket-title {
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.ticket-date {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-soft);
}
.ticket-desc {
  color: var(--text-muted);
  font-size: .9rem;
  line-height: 1.4;
  margin-top: 2px;
}
.ticket-worker {
  margin-top: 6px;
  font-size: .82rem;
  color: var(--work);
}
.ticket-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.ticket-open {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--text-soft);
  background: var(--surface-2);
  transition: background .12s ease, color .12s ease, transform .12s ease;
}
.ticket-row:hover .ticket-open {
  background: var(--primary-soft);
  color: var(--primary-dark);
  transform: translateX(2px);
}

/* ===== Modal ===== */
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 200;
  animation: fadeIn .14s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 60px -20px rgba(15, 23, 42, 0.45);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  animation: popIn .18s cubic-bezier(.2,.8,.2,1.04);
}
.modal-wide { max-width: 640px; }
@keyframes popIn {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-head-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.modal-eyebrow {
  color: var(--text-soft);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.modal-head h2 { font-size: 1.25rem; line-height: 1.2; }
.modal-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.modal-status-row .muted { font-size: .82rem; }
.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}
.modal-close:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-soft);
}
.modal-body {
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-section { display: flex; flex-direction: column; gap: 6px; }
.modal-section-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-soft);
}
.modal-desc {
  color: var(--text);
  font-size: .98rem;
  line-height: 1.6;
}
.modal-foot {
  padding: 18px 24px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
/* A form sitting directly inside .modal supplies its own gutters; inside
   .modal-foot the footer already provides them, so don't double up. */
.modal > .modal-form {
  padding: 20px 24px 22px;
}
.modal-foot > .modal-form {
  padding: 0;
}
.modal-form h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.modal-form > .muted {
  font-size: .85rem;
  margin-bottom: 14px;
}
/* The last field before the action row shouldn't add to the footer gap. */
.modal-form > .field:last-of-type {
  margin-bottom: 0;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}
/* Destructive action pinned left, the rest right. */
.modal-actions-spacer { flex: 1 1 auto; }
@media (max-width: 560px) {
  .modal-actions-split { flex-direction: column-reverse; }
  .modal-actions-split .btn { width: 100%; justify-content: center; }
  .modal-actions-spacer { display: none; }
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-2);
}
.worker-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.worker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
/* Keep enough room for the name; when the phone chip no longer fits beside it
   the row wraps instead of squeezing the name out of its box. */
.worker-info { flex: 1 1 140px; min-width: 140px; }
@media (max-width: 480px) {
  .worker-row .worker-phone { width: 100%; }
}
.worker-block .worker-name { font-weight: 700; font-size: 1rem; }
.worker-block .worker-prof { color: var(--text-muted); font-size: .85rem; }

/* ===== Responsive tweaks ===== */
@media (min-width: 640px) {
  .view { padding: 32px 32px 100px; }
  h1 { font-size: 1.75rem; }
  .login-card { padding: 28px; }
  .login-hero h1 { font-size: 2rem; }
  .welcome-card { padding: 28px 32px; }
  .welcome-name { font-size: 2.25rem; }
  .action-card { padding: 22px; min-height: 130px; }
  .action-title { font-size: 1.05rem; }
  .filter-bar { padding: 16px 18px; }
  .stat-value { font-size: 2.2rem; }
  .stat-card { padding: 18px; min-height: 130px; }
  .page-title h1 { font-size: 1.85rem; }
}

@media (max-width: 720px) {
  .topbar-user { display: none; }
}

@media (max-width: 480px) {
  .topbar-inner { padding: 10px 16px; }
  .view { padding: 18px 16px 80px; }
  .welcome-card { padding: 20px; }
  .welcome-name { font-size: 1.7rem; }
  .stats-row { gap: 8px; }
  .stat-card { padding: 12px; min-height: 100px; }
  .stat-value { font-size: 1.6rem; }
  .stat-label { font-size: .8rem; }
  .stat-cta { display: none; }
  .filter-bar {
    grid-template-columns: 1fr 1fr;
    grid-auto-flow: row;
  }
  /* The admin bars include a free-text search, which needs the full width
     more than the two side-by-side selects on the complaints page do. */
  .filter-bar-single,
  .filter-bar-admin {
    grid-template-columns: 1fr;
  }
  .filter-clear {
    grid-column: 1 / -1;
    height: 40px;
  }
  .recent-item { padding: 12px 14px; }
  .recent-sub { font-size: .8rem; }
  .form-card { padding: 18px; }
  .role-card {
    grid-template-columns: 48px 1fr auto;
    padding: 18px;
  }
  .role-icon { width: 48px; height: 48px; }
  .admin-tab { font-size: .82rem; padding: 8px 10px; min-width: 0; }
  .ticket-row { grid-template-columns: 1fr; gap: 8px; padding: 14px; }
  .ticket-row .ticket-end {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    align-items: center;
  }
  .modal-wide, .modal { max-width: 100%; }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
  .field-grid { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .topbar-inner { padding: 10px 12px; }
  .brand-text { display: none; }
  .logout-text { display: none; }
  .logout-btn { padding: 8px 10px; }
  .topbar-btn-text { display: none; }
  .topbar-btn { padding: 8px 10px; }
  /* The panel would overflow the viewport if it stayed anchored to the bell,
     so on a narrow screen it spans the width of the topbar instead. */
  .bell-wrap { position: static; }
  .bell-panel { width: auto; left: 12px; right: 12px; }
  .menu-wrap { position: static; }
  .menu-panel { left: 12px; right: 12px; min-width: 0; }
  .view { padding: 16px 12px 80px; }
  .card, .complaint-card, .form-card { padding: 16px; }
  .welcome-name { font-size: 1.5rem; }
  .stat-icon { width: 30px; height: 30px; }
  .stat-value { font-size: 1.4rem; }
  .stat-card { min-height: 88px; padding: 10px; }
  .recent-meta .recent-date { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== Batch 4a: loading, error, inline form errors, admin tables ===== */
.loading-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--text-muted);
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: cm-spin 0.8s linear infinite;
}
.loading-text {
  font-size: .95rem;
  color: var(--text-muted);
  margin: 0;
}
@keyframes cm-spin {
  to { transform: rotate(360deg); }
}

.error-block {
  text-align: center;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.error-block .error-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.error-block h3 { margin: 0; }

.login-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  font-size: .9rem;
  margin: 0;
}

.btn-small {
  padding: 6px 12px;
  font-size: .85rem;
  border-radius: 8px;
}

.data-card { padding: 0; overflow: hidden; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.data-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--primary-50); }
.row-actions-head { text-align: right; }
.row-actions {
  text-align: right;
  white-space: nowrap;
}
.row-actions .btn + .btn { margin-left: 6px; }

/* Destructive actions: a red-tinted ghost in table rows, solid in dialogs. */
.btn-danger-ghost {
  color: var(--danger);
  border-color: var(--danger-soft);
}
.btn-danger-ghost:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.confirm-message {
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1.55;
  margin: 0 0 4px;
}
.confirm-message strong { color: var(--text); }

.admin-shortcut-grid {
  margin-bottom: 12px;
}
/* Two shortcuts fit a tablet; the third only earns a column on a wide screen,
   below which a 3-up row squeezes the sub-text into three or four lines. */
@media (min-width: 720px) {
  .admin-shortcut-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1040px) {
  .admin-shortcut-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Resident suggestions ===== */

/* Counter under the suggestion textarea. */
.char-count {
  margin: -4px 2px 0;
  font-size: .78rem;
  color: var(--text-soft);
  text-align: right;
}

.suggestion-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
/* Inside a flat group the cards drop their own chrome: the group heading is
   already a card, and a card within a card reads as clutter. */
.suggestion-list-grouped {
  margin-top: 0;
  gap: 0;
}
.suggestion-list-grouped .suggestion-card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  border-bottom: 1px solid var(--border);
}
.suggestion-list-grouped .suggestion-card:last-child { border-bottom: none; }

.suggestion-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.suggestion-who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.suggestion-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 999px;
  background: var(--primary-50);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: .95rem;
}
.suggestion-flat {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
}
.suggestion-name {
  font-size: .82rem;
  color: var(--text-muted);
}
.suggestion-phone { color: var(--primary-dark); }
.suggestion-date {
  flex: none;
  font-size: .8rem;
  color: var(--text-soft);
  white-space: nowrap;
}
.suggestion-text {
  margin-top: 12px;
  color: var(--text);
  font-size: .95rem;
  line-height: 1.6;
  /* Suggestions are free text, so a resident can paste a paragraph with their
     own line breaks - keep them rather than collapsing it into one block. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assign-pro-meta {
  margin: 6px 2px 0;
  font-size: .82rem;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: .9rem;
  color: var(--text);
}

@media (max-width: 540px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
  }
  .data-table tbody tr:last-child { border-bottom: none; }
  .data-table tbody td {
    padding: 4px 0;
    border: none;
  }
  .row-actions {
    text-align: left;
    margin-top: 6px;
    /* Three actions will not fit on one phone-width line. */
    white-space: normal;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .row-actions .btn + .btn { margin-left: 0; }
}
