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

:root {
  --lov-blue: #004b87;
  --lov-navy: #00335d;
  --lov-green: #006b4f;
  --lov-green-accent: #008060;
  --ink: #0f172a;
  --muted: #334155;
  --bg: #f4f7fa;
  --surface: #ffffff;
  --border: #cbd5e1;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --ok-bg: #ecfdf5;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  font-size: 15px;
  overflow-x: hidden;
}

a { color: var(--lov-blue); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex="0"]:focus-visible {
  outline: 3px solid #0b57d0;
  outline-offset: 2px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #0a0a0a;
  color: #ffffff;
  padding: 10px 16px;
  z-index: 4000;
  font-weight: 700;
}
.skip-link:focus { left: 8px; top: 8px; }

/* Top Bar */
.topbar {
  background: var(--lov-navy);
  color: #ffffff;
  border-bottom: 4px solid var(--lov-green-accent);
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-crest {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--lov-green-accent);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-text strong { font-size: 1rem; line-height: 1.2; color: #ffffff; }
.brand-text span { font-size: 0.8rem; color: #dbeafe; }

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.role-switch-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.role-label { font-size: 0.85rem; color: #e2e8f0; font-weight: 600; }
.role-switch-wrap select {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid #94a3b8;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.88rem;
  font-weight: 600;
  max-width: 240px;
  min-height: 36px;
}

/* Dismissible Role Tip (WELCOME-06) */
.rfs-role-tip {
  background: #fff200;
  color: #0f172a;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid #0f172a;
}
.rfs-role-tip[hidden] { display: none; }
.btn-tip-close {
  background: #0f172a;
  color: #ffffff;
  border: 0;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 28px;
}

/* Shell Layout */
.app-shell {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 16px 40px;
  align-items: start;
}
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  min-width: 0;
}
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: #ffffff;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}
.nav-btn:hover { background: #eff6ff; border-color: #bfdbfe; }
.nav-btn.is-active {
  background: var(--lov-blue);
  color: #ffffff;
  border-color: var(--lov-navy);
}
.sidebar-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}
.sidebar-meta strong { display: block; color: var(--ink); margin-bottom: 2px; }

main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Cards & Grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card h1, .card h2, .card h3 { margin: 0 0 6px; color: var(--lov-navy); }
.card h1 { font-size: 1.45rem; }
.card h2 { font-size: 1.18rem; }
.card h3 { font-size: 1rem; }
.subtext { margin: 0; color: var(--muted); font-size: 0.9rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 12px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--lov-blue);
  border-radius: 8px;
  padding: 12px 14px;
  min-width: 0;
}
.stat-card.green { border-left-color: var(--lov-green); }
.stat-val { font-size: 1.5rem; font-weight: 800; color: var(--lov-navy); line-height: 1.2; }
.stat-lbl { font-size: 0.82rem; color: var(--muted); font-weight: 600; margin-top: 2px; }

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

/* Buttons & Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--lov-blue);
  color: #ffffff;
  border: 1px solid var(--lov-navy);
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  min-height: 38px;
  line-height: 1.2;
}
.btn:hover { background: var(--lov-navy); }
.btn-green { background: var(--lov-green); border-color: #004d39; color: #ffffff; }
.btn-green:hover { background: #004d39; }
.btn-secondary { background: #ffffff; color: var(--lov-navy); border: 1px solid var(--lov-blue); }
.btn-secondary:hover { background: #eff6ff; }
.btn-ghost { background: transparent; color: #ffffff; border: 1px solid rgba(255, 255, 255, 0.55); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }
.btn-danger { background: var(--danger); border-color: #7f1d1d; color: #ffffff; }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; min-height: 32px; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: #e2e8f0;
  color: #0f172a;
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
}
.badge-blue { background: #dbeafe; color: #00335d; }
.badge-green { background: #d1fae5; color: #064e3b; }
.badge-warn { background: #fef3c7; color: #78350f; }
.badge-conf { background: #b91c1c; color: #ffffff; padding: 3px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.field-full { grid-column: 1 / -1; }
.field label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid #94a3b8;
  border-radius: 7px;
  font: inherit;
  font-size: 0.92rem;
  background: #ffffff;
  color: var(--ink);
  min-height: 38px;
}
.field textarea { min-height: 76px; resize: vertical; }
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}
.check-row input { width: auto; min-height: 18px; }

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: #ffffff;
}
th, td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  word-break: break-word;
}
th {
  background: #f1f5f9;
  color: var(--lov-navy);
  font-weight: 700;
  font-size: 0.82rem;
}

/* Speaker Timer & Touch Voting */
.timer-box {
  border: 2px solid var(--lov-green);
  border-radius: 10px;
  padding: 14px;
  background: var(--ok-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.timer-box.is-warn { border-color: #b45309; background: var(--warn-bg); }
.timer-box.is-expired { border-color: var(--danger); background: var(--danger-bg); }
.timer-clock { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }

.vote-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.vote-btn {
  min-height: 54px;
  font-size: 1rem;
  font-weight: 800;
  border-radius: 10px;
  border: 2px solid var(--lov-navy);
  cursor: pointer;
  padding: 10px 8px;
}
.vote-aye { background: #006b4f; color: #ffffff; border-color: #004d39; }
.vote-nay { background: #b91c1c; color: #ffffff; border-color: #7f1d1d; }
.vote-abstain { background: #1e40af; color: #ffffff; border-color: #1e3a8a; }
.vote-absent { background: #475569; color: #ffffff; border-color: #334155; }

/* CableCast Video Panel */
.video-panel {
  background: #0f172a;
  color: #f8fafc;
  border-radius: 10px;
  padding: 14px;
}
.video-panel strong { color: #ffffff; }
.video-panel .subtext { color: #cbd5e1; }
.video-panel a { color: #93c5fd; text-decoration: underline; }
.video-panel a:hover, .video-panel a:focus-visible { color: #ffffff; }
.ts-chip {
  background: #1e293b;
  color: #ffffff;
  border: 1px solid #64748b;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 32px;
}
.ts-chip:hover { background: var(--lov-green); border-color: #ffffff; }

/* Offline Minutes Banner (MI12) */
.offline-banner {
  background: var(--warn-bg);
  border: 2px solid #b45309;
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  margin-bottom: 12px;
}
.item-card.is-conf { border-left: 4px solid var(--danger); background: #fffafa; }
.item-card.is-active-min { border-left: 4px solid var(--lov-green); background: #f4fdf9; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 14px; }
.mb-2 { margin-bottom: 8px; }
.divider { margin: 18px 0; border: 0; border-top: 1px solid #cbd5e1; }

/* Toast */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #0a0a0a;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 3000;
  max-width: calc(100vw - 32px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}
.toast[hidden] { display: none; }

/* WELCOME-06: Frozen Choose Your View Modal (Mobile Centered + Compact) */
.rfs-role-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(10, 14, 24, 0.74);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}
.rfs-role-backdrop[hidden] { display: none; }
.rfs-role-dialog {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  max-width: 760px;
  width: 100%;
  margin: auto;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.rfs-role-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.rfs-role-head h2 { margin: 0 0 4px; font-size: 1.22rem; color: var(--lov-navy); }
.rfs-role-sub { margin: 0; font-size: 0.88rem; color: #334155; }
.rfs-role-close {
  background: #f1f5f9;
  color: #0f172a;
  border: 1px solid #94a3b8;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.rfs-role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.rfs-role-option {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  text-decoration: none;
  min-width: 0;
}
.rfs-role-option:hover { border-color: var(--lov-blue); background: #eff6ff; }
.rfs-role-option.is-current { border: 2px solid var(--lov-blue); background: #eff6ff; }
.rfs-role-option-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.rfs-role-option-head strong { font-size: 0.94rem; color: var(--lov-navy); }
.rfs-role-badge {
  background: var(--lov-green);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
.rfs-role-option-meta { font-size: 0.8rem; font-weight: 600; color: var(--lov-blue); }
.rfs-role-option-desc { font-size: 0.82rem; color: #334155; line-height: 1.38; }
.rfs-role-foot {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

/* Print Document Views */
.print-doc { background: #ffffff; }
.doc-container { max-width: 900px; margin: 0 auto; padding: 28px 20px; }
.doc-header { border-bottom: 3px solid var(--lov-blue); padding-bottom: 14px; margin-bottom: 20px; }
.doc-kicker { font-size: 0.8rem; font-weight: 800; letter-spacing: 0.08em; color: var(--lov-green); margin: 0 0 6px; }
.agenda-item { border-bottom: 1px solid #cbd5e1; padding: 14px 0; }
.motion-box { background: #f8fafc; border-left: 4px solid var(--lov-green); padding: 10px 12px; margin-top: 8px; }

/* Responsive & 320px Reflow */
@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; padding: 12px 10px 32px; gap: 12px; }
  .nav-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .nav-btn { width: auto; flex: 1 1 130px; padding: 8px 10px; font-size: 0.85rem; }
  .two-col, .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .rfs-role-backdrop {
    align-items: center;
    justify-content: center;
    padding: 14px;
  }
  .rfs-role-dialog {
    margin: auto;
    max-width: min(360px, calc(100vw - 28px));
    max-height: calc(100dvh - 36px);
    overflow-y: auto;
    padding: 14px;
    border-radius: 12px;
  }
  .rfs-role-grid { grid-template-columns: 1fr; gap: 8px; }
  .rfs-role-option { padding: 9px 10px; }
  .rfs-role-option-desc { display: none; }
  .rfs-role-head { margin-bottom: 10px; }
  .rfs-role-head h2 { font-size: 1.08rem; }
  .vote-pad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .topbar-inner { padding: 8px 10px; }
  .role-switch-wrap select { max-width: 170px; font-size: 0.82rem; }
  .card { padding: 12px; }
  .stat-grid { grid-template-columns: 1fr; }
}

.meeting-video {
  display: block;
  width: 100%;
  max-height: 360px;
  border-radius: 8px;
  background: #0a0a0a;
  margin: 10px 0;
}
