:root {
  color-scheme: light;
  --ink: #263238;
  --muted: #65727a;
  --line: #d8e0e3;
  --panel: #ffffff;
  --page: #f5f7f4;
  --soft: #eef3ef;
  --green: #2f6f4e;
  --green-soft: #e3efe8;
  --blue: #315f7c;
  --blue-soft: #e4edf2;
  --amber: #9a6a17;
  --amber-soft: #f4ead3;
  --red: #9d3b35;
  --red-soft: #f3dedb;
  --violet: #67507a;
  --violet-soft: #ece6f0;
  --shadow: 0 16px 48px rgba(43, 54, 58, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

body.auth-locked {
  background: #eef3ef;
}

body.auth-locked .app-shell {
  display: block;
}

body.auth-locked .sidebar,
body.auth-locked .topbar,
body.auth-locked .connection-panel {
  display: none !important;
}

body.auth-locked .main-panel {
  min-height: 100vh;
  padding: clamp(20px, 4vw, 48px);
  display: grid;
  place-items: center;
}

body.auth-locked .content-area {
  width: min(100%, 760px);
}

.auth-shell {
  width: 100%;
  display: grid;
  place-items: center;
}

.auth-card {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 36px);
}

.compact-auth-card {
  max-width: 580px;
  margin: 0 auto;
}

.auth-brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 24px;
}

.auth-brand h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.auth-brand p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 58ch;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-recovery {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.auth-recovery p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-status {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.92rem;
  min-height: 22px;
}

.sidebar {
  min-height: 100vh;
  background: #fbfcfa;
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  align-self: start;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  border: 1px solid #c9dccf;
  border-radius: 8px;
}

.brand-mark svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--green);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand span {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 3px;
}

.nav-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
  padding: 10px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button:hover {
  background: var(--soft);
}

.nav-button.active {
  color: #143322;
  background: var(--green-soft);
}

.main-panel {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar-title h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5d8;
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 10px;
  min-height: 40px;
}

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

.compact-field {
  min-width: 190px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid #cbd5d8;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.button {
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
  border-radius: 6px;
  min-height: 40px;
  padding: 9px 13px;
  font-weight: 700;
}

.button.secondary {
  background: #fff;
  color: var(--green);
}

.button.warning {
  background: var(--amber);
  border-color: var(--amber);
}

.button.danger {
  background: var(--red);
  border-color: var(--red);
}

.button.danger.subtle {
  background: #fff;
  color: var(--red);
}

.button.compact {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

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

.action-stack {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.edit-panel {
  border-color: #b7c9d2;
  background: #fbfdfc;
}

.connection-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.connection-panel h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.connection-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  max-width: 74ch;
}

.connection-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(220px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
}

.connection-status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.content-area {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.panel-header h2,
.section-title {
  margin: 0;
  font-size: 1rem;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric {
  display: grid;
  gap: 6px;
}

.metric strong {
  font-size: 1.8rem;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-size: 0.86rem;
}

.readiness {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.score-ring {
  width: 172px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--green) var(--score), #e4e8e2 0);
  position: relative;
}

.score-ring::after {
  content: "";
  width: 122px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--panel);
  position: absolute;
}

.score-ring strong,
.score-ring span {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
}

.score-ring strong {
  font-size: 2.1rem;
}

.score-ring span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.checklist {
  display: grid;
  gap: 9px;
}

.check-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e3e7e1;
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--green);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  background: #f8faf8;
}

tr:last-child td {
  border-bottom: 0;
}

.table-input,
.table-select {
  min-height: 34px;
  padding: 6px 8px;
  min-width: 126px;
}

.table-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.green {
  color: #1f4c36;
  background: var(--green-soft);
}

.pill.blue {
  color: #244c65;
  background: var(--blue-soft);
}

.pill.amber {
  color: #6f4b0e;
  background: var(--amber-soft);
}

.pill.red {
  color: #74302c;
  background: var(--red-soft);
}

.pill.violet {
  color: #4f3b5e;
  background: var(--violet-soft);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.84rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid .wide {
  grid-column: span 2;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 12px;
}

.filter-row .field {
  min-width: 180px;
}

.calendar-shell {
  display: grid;
  gap: 12px;
}

.calendar-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.calendar-head,
.calendar-day {
  min-height: 112px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 9px;
}

.calendar-head {
  min-height: auto;
  background: #f8faf8;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-day:nth-child(7n),
.calendar-head:nth-child(7n) {
  border-right: 0;
}

.calendar-day.outside {
  background: #f5f6f3;
  color: #99a4a8;
}

.calendar-date {
  font-weight: 800;
  margin-bottom: 6px;
}

.calendar-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-left: 3px solid var(--blue);
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--ink);
  padding: 5px 6px;
  margin-bottom: 5px;
  font-size: 0.76rem;
}

.calendar-item.election-day {
  border-left-color: var(--green);
  background: var(--green-soft);
  font-weight: 800;
}

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

.entity-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.entity-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.card-actions,
.note-card-header {
  display: flex;
  gap: 8px;
  align-items: start;
  justify-content: space-between;
}

.card-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.entity-card h3 {
  margin: 0;
  font-size: 1rem;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.detail-list div {
  min-width: 0;
}

.detail-list span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-list strong {
  display: block;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.supply-location {
  display: grid;
  gap: 10px;
}

.supply-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
}

.supply-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.supply-check input {
  width: auto;
  min-height: auto;
}

.note-list,
.issue-list {
  display: grid;
  gap: 10px;
}

.note-card,
.issue-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.note-card p,
.issue-card p {
  margin: 8px 0 0;
}

.issue-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.log-mode {
  border: 2px solid #d8b55d;
}

.fast-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, minmax(150px, 0.7fr));
  gap: 12px;
  align-items: end;
}

.report-output {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.report-output h2 {
  margin-top: 0;
}

.permission-grid {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.permission-grid div {
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.permission-grid div:nth-child(5n) {
  border-right: 0;
}

.permission-grid .head {
  background: #f8faf8;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #c6d1d4;
  border-radius: 8px;
  background: #fff;
  padding: 22px;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .connection-grid,
  .form-grid,
  .fast-grid,
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .main-panel {
    padding: 16px;
  }

  .topbar,
  .panel-header,
  .calendar-bar,
  .issue-card header,
  .note-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-controls,
  .button-row,
  .auth-recovery {
    justify-content: start;
  }

  .auth-brand,
  .auth-recovery {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .compact-field,
  .filter-row .field {
    min-width: 100%;
  }

  .connection-grid,
  .form-grid,
  .fast-grid,
  .grid.two,
  .grid.three,
  .grid.four,
  .readiness,
  .detail-list,
  .supply-item {
    grid-template-columns: 1fr;
  }

  .form-grid .wide {
    grid-column: auto;
  }

  .score-ring {
    margin: 0 auto;
  }

  .calendar-head,
  .calendar-day {
    min-height: 96px;
    padding: 7px;
  }

  .permission-grid {
    overflow-x: auto;
    min-width: 640px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .connection-panel,
  .panel:not(.printable),
  .no-print {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .main-panel {
    padding: 0;
  }

  .content-area {
    display: block;
  }

  .report-output {
    border: 0;
    padding: 0;
  }

  table {
    min-width: 0;
  }
}
