@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800;900&display=swap");

:root {
  --ink: #182022;
  --muted: #647174;
  --line: #d9e1e3;
  --paper: #f7faf9;
  --panel: #ffffff;
  --teal: #27b9d3;
  --green: #1f7a4d;
  --amber: #d89720;
  --red: #b7433f;
  --shadow: 0 16px 40px rgba(28, 41, 45, 0.08);
  --body-font: Montserrat, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --header-font: "Californian FB", Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--body-font);
}

button,
select,
a {
  font: inherit;
}

button,
.toolbar a {
  font-family: var(--header-font);
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-family: var(--header-font);
  font-size: 29px;
  font-weight: 900;
  line-height: 1.15;
}

h2 {
  font-family: var(--header-font);
  font-size: 18px;
  font-weight: 900;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar a,
.toolbar button {
  min-height: 38px;
  border: 1px solid rgba(24, 32, 34, 0.28);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  padding: 9px 13px;
  text-decoration: none;
  font-size: 16px;
  font-weight: 900;
}

.toolbar .action-primary {
  background: var(--teal);
  color: #071014;
}

.toolbar .action-secondary {
  background: var(--amber);
  color: #14100a;
}

.toolbar .action-protected {
  background: #1f7a4d;
  color: white;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
}

.upload-progress {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(240px, 1.4fr) minmax(320px, 1fr);
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(24, 32, 34, 0.16);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.progress-copy span,
.progress-stats span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.progress-copy strong {
  display: block;
  margin-top: 5px;
  font-family: var(--header-font);
  font-weight: 900;
  font-size: 24px;
}

.progress-track {
  height: 18px;
  border: 1px solid rgba(24, 32, 34, 0.16);
  border-radius: 999px;
  background: #e9eef0;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--green));
  transition: width 180ms ease;
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.progress-stats div {
  border-left: 1px solid var(--line);
  padding-left: 12px;
}

.progress-stats strong {
  display: block;
  margin-top: 5px;
  font-family: var(--header-font);
  font-weight: 900;
  font-size: 23px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-grid article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.summary-grid article {
  padding: 16px;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-grid strong {
  display: block;
  margin-top: 8px;
  font-family: var(--header-font);
  font-weight: 900;
  font-size: 32px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
  gap: 14px;
  margin-bottom: 14px;
}

.workspace.bottom {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.panel-head p {
  color: var(--muted);
  font-size: 13px;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: min(420px, 48vh);
  padding: 8px 12px 12px;
}

.party-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.party-row {
  display: grid;
  grid-template-columns: 54px 1fr 80px;
  align-items: center;
  gap: 10px;
}

.party-code {
  font-family: var(--header-font);
  font-size: 17px;
  font-weight: 900;
}

.bar-track {
  height: 12px;
  border-radius: 6px;
  background: #e9eef0;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--teal);
}

.party-votes {
  font-family: var(--header-font);
  font-size: 17px;
  font-weight: 900;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow: auto;
  max-height: 430px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.detail-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-item strong,
.detail-item a {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: var(--header-font);
  font-size: 17px;
  font-weight: 900;
  overflow-wrap: anywhere;
  text-decoration-color: var(--teal);
}

.detail-empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f7faf9;
  padding: 18px;
}

.detail-empty strong {
  display: block;
  font-family: var(--header-font);
  font-weight: 900;
  font-size: 21px;
}

.detail-empty p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.detail-select-label {
  margin-top: 14px;
  text-align: left;
}

.detail-select-label select {
  margin-top: 6px;
  text-transform: none;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 18, 20, 0.72);
}

.modal-panel,
.login-panel {
  width: min(960px, 100%);
  max-height: min(94vh, 980px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.login-panel {
  width: min(520px, 100%);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal button {
  min-height: 38px;
  border: 1px solid rgba(24, 32, 34, 0.28);
  border-radius: 6px;
  background: var(--teal);
  color: #071014;
  cursor: pointer;
  font-weight: 800;
  padding: 8px 12px;
}

.modal-head button {
  background: #ffffff;
  color: var(--ink);
}

.login-copy {
  display: grid;
  gap: 8px;
  padding: 20px;
}

.login-copy strong {
  font-size: 20px;
}

.login-copy p {
  color: var(--muted);
  line-height: 1.5;
}

.preview-frame {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background: #eef4f5;
  text-align: center;
}

.preview-frame img {
  display: inline-block;
  max-width: min(100%, 720px);
  max-height: 74vh;
  background: white;
  box-shadow: 0 16px 52px rgba(20, 33, 37, 0.22);
}

@media (max-width: 900px) {
  .topbar,
  .workspace,
  .workspace.bottom {
    grid-template-columns: 1fr;
    display: grid;
  }

  .filters,
  .summary-grid,
  .upload-progress {
    grid-template-columns: 1fr 1fr;
  }

  .progress-track {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .filters,
  .summary-grid,
  .detail-grid,
  .upload-progress,
  .progress-stats {
    grid-template-columns: 1fr;
  }

  .progress-stats div {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 10px 0 0;
  }

  h1 {
    font-size: 21px;
  }
}
