:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;

  --agree: #059669;
  --agree-bg: #ecfdf5;
  --agree-border: #a7f3d0;

  --disagree: #dc2626;
  --disagree-bg: #fef2f2;
  --disagree-border: #fecaca;

  --abstain: #d97706;
  --abstain-bg: #fffbeb;
  --abstain-border: #fde68a;

  --unvoted: #64748b;
  --unvoted-bg: #f8fafc;
  --unvoted-border: #e2e8f0;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 36px rgba(15, 23, 42, 0.16);
  --header-height: 60px;
  --bottom-nav-height: 62px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.hidden {
  display: none !important;
}

/* ---------- Layout & Header ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1280px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.25);
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-tab:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.role-badge.admin {
  background: #ede9fe;
  color: #6d28d9;
}

.role-badge.rep {
  background: #e0f2fe;
  color: #0369a1;
}

.main-container {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
}

/* Mobile bottom nav */
.bottom-nav {
  display: none;
}

/* ---------- Cards & Surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}

.card + .card {
  margin-top: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.card-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

.btn-lg {
  padding: 11px 20px;
  font-size: 15px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-subtle);
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}
.btn-danger:hover:not(:disabled) {
  background: #fecaca;
}

.btn-danger-solid {
  background: #dc2626;
  color: #fff;
}
.btn-danger-solid:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-subtle);
  color: var(--text);
}

.btn-ghost-light {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}
.btn-ghost-light:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.room-inline-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.room-inline-row .select {
  padding: 9px 6px;
  font-size: 13.5px;
  min-width: 0;
}

.ocr-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
}

.ocr-status.running {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.ocr-status.done {
  background: var(--agree-bg);
  border-color: var(--agree-border);
  color: var(--agree);
}

.ocr-status.error {
  background: var(--abstain-bg);
  border-color: var(--abstain-border);
  color: #92400e;
}

.ocr-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(29, 78, 216, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input, .select, .textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.help-text {
  font-size: 12px;
  color: var(--text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ---------- Login Screen ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #dbeafe 0%, #f3f5f9 45%, #e2e8f0 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.25);
}

.login-header h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
}

.login-header p {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.demo-accounts {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-strong);
}

.demo-accounts-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.demo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.demo-chip {
  flex: 1;
  min-width: 105px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.demo-chip:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.demo-chip strong {
  display: block;
  font-size: 12.5px;
  color: var(--text);
}

.demo-chip span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- Topic Banner ---------- */
.topic-banner {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 60%, #0284c7 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 6px 20px rgba(29, 78, 216, 0.2);
}

.topic-banner h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
}

.topic-banner p {
  margin: 0;
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.88);
  max-width: 720px;
}

.topic-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.topic-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.topic-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- KPI & Stats ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border);
}

.kpi-card.primary::before { background: var(--primary); }
.kpi-card.agree::before { background: var(--agree); }
.kpi-card.disagree::before { background: var(--disagree); }
.kpi-card.abstain::before { background: var(--abstain); }

.kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}

.kpi-card.agree .kpi-value { color: var(--agree); }
.kpi-card.disagree .kpi-value { color: var(--disagree); }
.kpi-card.abstain .kpi-value { color: var(--abstain); }

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.dashboard-split {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.phase-compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}

.phase-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.phase-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.phase-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.phase-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.phase-card-title {
  font-size: 15px;
  color: var(--text);
}

.phase-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.phase-card-metrics > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
}

@media (max-width: 560px) {
  .phase-card-metrics {
    grid-template-columns: 1fr;
  }
}

.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.donut-legend {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  font-size: 12.5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

/* Progress Bars */
.progress-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.progress-seg.agree { background: var(--agree); }
.progress-seg.disagree { background: var(--disagree); }
.progress-seg.abstain { background: var(--abstain); }
.progress-seg.primary { background: var(--primary); }

.metric-bar-block + .metric-bar-block {
  margin-top: 14px;
}

.metric-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-agree {
  background: var(--agree-bg);
  color: var(--agree);
  border-color: var(--agree-border);
}

.badge-disagree {
  background: var(--disagree-bg);
  color: var(--disagree);
  border-color: var(--disagree-border);
}

.badge-abstain {
  background: var(--abstain-bg);
  color: var(--abstain);
  border-color: var(--abstain-border);
}

.badge-unvoted {
  background: var(--unvoted-bg);
  color: var(--unvoted);
  border-color: var(--unvoted-border);
}

.badge-neutral {
  background: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

/* ---------- Filter Bar & Building Pills ---------- */
.filter-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.building-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pill-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-controls .input {
  max-width: 240px;
}

.filter-controls .select {
  width: auto;
  min-width: 126px;
}

.view-switcher {
  margin-left: auto;
  display: inline-flex;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.view-switcher button {
  border: none;
  background: transparent;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.view-switcher button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* ---------- Room Grid Matrix ---------- */
.building-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.building-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.building-section-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
}

.floor-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.floor-row {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 10px;
  align-items: stretch;
}

.floor-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.floor-rooms {
  display: grid;
  grid-template-columns: repeat(var(--floor-cols, 6), minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 900px) {
  .floor-rooms {
    grid-template-columns: repeat(min(var(--floor-cols, 6), 3), minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .floor-row {
    grid-template-columns: 36px 1fr;
    gap: 6px;
  }
  .floor-rooms {
    grid-template-columns: repeat(min(var(--floor-cols, 6), 3), minmax(0, 1fr));
    gap: 6px;
  }
  .floor-rooms .room-tile {
    padding: 7px 6px;
  }
  .floor-rooms .room-tile-number {
    font-size: 14px;
  }
}

.room-tile {
  position: relative;
  border: 1.5px solid var(--unvoted-border);
  background: var(--unvoted-bg);
  border-radius: var(--radius-sm);
  padding: 10px 10px 9px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.room-tile.status-agree {
  background: var(--agree-bg);
  border-color: var(--agree-border);
}

.room-tile.status-disagree {
  background: var(--disagree-bg);
  border-color: var(--disagree-border);
}

.room-tile.status-abstain {
  background: var(--abstain-bg);
  border-color: var(--abstain-border);
}

.room-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.room-tile-number {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.room-tile-img-tag {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-secondary);
}

.room-tile-status {
  font-size: 12px;
  font-weight: 700;
}

.room-tile.status-agree .room-tile-status { color: var(--agree); }
.room-tile.status-disagree .room-tile-status { color: var(--disagree); }
.room-tile.status-abstain .room-tile-status { color: var(--abstain); }
.room-tile.status-unvoted .room-tile-status { color: var(--text-muted); font-weight: 500; }

.room-tile-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.thumb-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.thumb-mini {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  cursor: zoom-in;
  transition: transform 0.15s;
}

.thumb-mini:hover {
  transform: scale(1.08);
}

/* ---------- Modal / Vote Drawer ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
}

.modal-box {
  width: 100%;
  max-width: 580px;
  max-height: 92vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.16s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Choice selector cards */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.choice-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: all 0.15s;
}

.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-card-icon {
  font-size: 22px;
  margin-bottom: 4px;
}

.choice-card-label {
  font-size: 15px;
  font-weight: 700;
}

.choice-card.agree.selected {
  border-color: var(--agree);
  background: var(--agree-bg);
  color: var(--agree);
}

.choice-card.disagree.selected {
  border-color: var(--disagree);
  background: var(--disagree-bg);
  color: var(--disagree);
}

.choice-card.abstain.selected {
  border-color: var(--abstain);
  background: var(--abstain-bg);
  color: var(--abstain);
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  text-align: center;
  background: var(--surface-subtle);
  cursor: pointer;
  transition: all 0.15s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.screenshot-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0f172a;
  aspect-ratio: 1 / 1;
}

.screenshot-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
}

.screenshot-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screenshot-remove:hover {
  background: #dc2626;
}

.screenshot-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(29, 78, 216, 0.88);
  color: #fff;
}

.alert-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid transparent;
}

.alert-info {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: #1e40af;
}

.alert-warning {
  background: var(--abstain-bg);
  border-color: var(--abstain-border);
  color: #92400e;
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 94vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
}

.lightbox-caption {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-actions {
  display: flex;
  gap: 8px;
}

.lightbox-content img {
  max-width: 92vw;
  max-height: 82vh;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: #000;
  box-shadow: var(--shadow-lg);
}

/* ---------- Toast ---------- */
.toast-root {
  position: fixed;
  top: 72px;
  right: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 380px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: #0f172a;
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.18s ease-out;
}

.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Empty State & Subtabs ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 6px;
}

.subtabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.subtab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.subtab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.building-check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.building-check-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  cursor: pointer;
  font-size: 13px;
}

.building-check-pill:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* ---------- Responsive Mobile ---------- */
@media (max-width: 960px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .topbar-inner {
    padding: 0 12px;
  }
  .nav-tabs {
    display: none;
  }
  .user-pill .user-name-text {
    display: none;
  }
  .main-container {
    padding: 14px 12px calc(var(--bottom-nav-height) + 20px);
  }
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    height: var(--bottom-nav-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
  }
  .bottom-nav-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 4px;
    cursor: pointer;
  }
  .bottom-nav-btn .nav-emoji {
    font-size: 18px;
    line-height: 1.1;
  }
  .bottom-nav-btn.active {
    color: var(--primary);
  }
  .filter-controls .input {
    max-width: 100%;
    flex: 1 1 100%;
  }
  .view-switcher {
    margin-left: 0;
  }
  .room-matrix {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  }
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal-box {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
  }
}

/* Print Styles */
@media print {
  .topbar, .bottom-nav, .topic-actions, .btn, .filter-bar {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .card, .kpi-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
