:root {
  --brand: #005b8f;
  --brand-strong: #00466f;
  --brand-soft: #e7f2f7;
  --ink: #17242d;
  --muted: #667581;
  --canvas: #f4f7f9;
  --surface: #ffffff;
  --line: #dce4e9;
  --line-strong: #c7d2da;
  --success: #237558;
  --success-soft: #e7f4ee;
  --warning: #996415;
  --warning-soft: #fff4da;
  --danger: #b33f4a;
  --danger-soft: #fbeaec;
  --gray-soft: #edf1f3;
  --shadow: 0 10px 28px rgba(21, 49, 67, 0.08);
  --sidebar-width: 252px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background: var(--canvas);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  min-height: 88px;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-lockup img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.brand-lockup div,
.account-copy {
  min-width: 0;
}

.brand-lockup strong,
.brand-lockup span,
.account-copy strong,
.account-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup strong {
  color: var(--brand-strong);
  font-size: 17px;
}

.brand-lockup span,
.account-copy span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 5px;
  padding: 22px 14px;
}

.nav-item {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #41525e;
  font-weight: 650;
}

.nav-item:hover {
  background: var(--gray-soft);
  color: var(--ink);
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.nav-item img,
.icon-button img,
.button img,
.inline-icon {
  width: 18px;
  height: 18px;
}

.nav-item img {
  opacity: 0.78;
}

.sidebar-account {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 15px 14px;
  border-top: 1px solid var(--line);
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-weight: 750;
}

.account-copy strong {
  font-size: 13px;
}

.app-frame {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 14px;
  padding: 10px 30px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  min-width: 0;
}

.topbar-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-title h1 {
  overflow: hidden;
  margin: 1px 0 0;
  font-size: 20px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.page {
  width: min(100%, 1440px);
  min-width: 0;
  margin: 0 auto;
  padding: 28px 30px 48px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-header h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1.25;
}

.page-header p {
  max-width: 680px;
  margin: 6px 0 0;
  color: var(--muted);
}

.page-actions,
.inline-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.button,
.icon-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  cursor: pointer;
}

.button {
  min-height: 40px;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 700;
}

.button.primary {
  background: var(--brand);
  color: white;
}

.button.primary:hover {
  background: var(--brand-strong);
}

.button.secondary {
  background: white;
  border-color: var(--line-strong);
  color: var(--ink);
}

.button.secondary:hover,
.icon-button:hover {
  background: var(--gray-soft);
}

.button.danger {
  background: white;
  border-color: #e6b8bd;
  color: var(--danger);
}

.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
}

.mobile-menu {
  display: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.metric-label img {
  width: 18px;
  height: 18px;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 29px;
  line-height: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(270px, 0.8fr);
  gap: 20px;
  align-items: start;
}

.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 18px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
}

.search-field {
  position: relative;
  width: min(100%, 360px);
}

.search-field img {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  opacity: 0.55;
}

.search-field input {
  width: 100%;
  padding-left: 36px;
}

.table-shell {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0 0 7px 7px;
}

.table-shell.standalone {
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #fafcfd;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  font-size: 14px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfdfe;
}

.cell-primary {
  font-weight: 700;
}

.cell-secondary {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}

.status-active {
  background: var(--success-soft);
  color: var(--success);
}

.status-draft {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-completed {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.status-disabled,
.status-inactive {
  background: var(--gray-soft);
  color: #596872;
}

.status-not_published,
.status-voting_closed {
  background: var(--gray-soft);
  color: #596872;
}

.status-upcoming {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.status-voting_open {
  background: var(--success-soft);
  color: var(--success);
}

.empty-state {
  padding: 44px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state img {
  width: 34px;
  height: 34px;
  margin-bottom: 8px;
  opacity: 0.45;
}

.summary-list {
  display: grid;
  gap: 0;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.summary-row:first-child {
  padding-top: 0;
}

.summary-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.summary-row span {
  color: var(--muted);
}

.summary-row strong {
  text-align: right;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.back-link {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: white;
}

.back-link img {
  width: 18px;
  height: 18px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  background: #e9eef1;
  border-radius: 7px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.tab-button {
  min-height: 34px;
  padding: 6px 13px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

.tab-button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(20, 45, 60, 0.1);
}

.tab-panel[hidden] {
  display: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 13px;
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
  background: white;
  color: var(--ink);
}

textarea {
  min-height: 104px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 91, 143, 0.12);
}

input[readonly],
input[disabled],
select[disabled] {
  background: var(--gray-soft);
  color: var(--muted);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  grid-column: 1 / -1;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13px;
}

.notice.warning {
  background: var(--warning-soft);
  color: #754d11;
}

.notice img {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.voting-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.voting-actions-panel {
  margin-top: 18px;
}

.control-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.control-action-row:first-child {
  padding-top: 0;
}

.control-action-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.control-action-row > div:first-child {
  display: grid;
  gap: 3px;
}

.control-action-row > div:first-child span {
  color: var(--muted);
  font-size: 13px;
}

.inline-actions form {
  margin: 0;
}

.readiness-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.readiness-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--danger);
  font-size: 13px;
}

.readiness-list img {
  width: 17px;
  height: 17px;
}

.public-path {
  overflow-wrap: anywhere;
}

.disabled-link {
  pointer-events: none;
  opacity: 0.5;
}

.category-list {
  display: grid;
  gap: 10px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(240px, 1.3fr) 36px;
  gap: 10px;
  align-items: start;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.image-grid a {
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--gray-soft);
}

.image-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

dialog {
  width: min(92vw, 620px);
  max-height: 88vh;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(19, 35, 45, 0.48);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h3 {
  margin: 0;
  font-size: 18px;
}

.dialog-body {
  padding: 18px;
}

.dialog-actions {
  justify-content: flex-end;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.confirmation-dialog {
  width: min(92vw, 460px);
}

.confirmation-dialog .dialog-body p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: 6px;
  background: #17242d;
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

.sidebar-backdrop {
  display: none;
}

.login-page {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(320px, 0.9fr) minmax(440px, 1.1fr);
  background: white;
}

.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px;
  background: var(--brand-strong);
  color: white;
}

.login-brand img {
  width: 150px;
  padding: 10px;
  border-radius: 7px;
  background: white;
}

.login-brand h1 {
  max-width: 500px;
  margin: 30px 0 10px;
  font-size: 38px;
  line-height: 1.15;
}

.login-brand p {
  max-width: 480px;
  color: #d4e6f0;
}

.login-brand small {
  color: #b9d3e1;
}

.login-main {
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-form {
  width: min(100%, 420px);
}

.login-form h2 {
  margin: 0;
  font-size: 28px;
}

.login-form > p {
  margin: 7px 0 26px;
  color: var(--muted);
}

.login-form .field {
  margin-bottom: 16px;
}

.login-form .button {
  width: 100%;
  margin-top: 8px;
}

.login-message {
  display: none;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

.login-message.visible {
  display: block;
}

.error-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background: var(--canvas);
}

.error-content {
  max-width: 520px;
  text-align: center;
}

.error-content img.logo {
  width: 110px;
}

.error-code {
  display: block;
  margin-top: 18px;
  color: var(--brand);
  font-size: 60px;
  font-weight: 800;
}

@media (max-width: 1050px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    border: 0;
    background: rgba(16, 31, 41, 0.42);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .app-frame {
    margin-left: 0;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar {
    padding: 10px 18px;
  }

  .topbar-identity {
    display: none;
  }

  .page {
    padding: 22px 18px 40px;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .voting-control-grid {
    grid-template-columns: 1fr;
  }

  .login-page {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 240px;
    padding: 28px;
  }

  .login-brand img {
    width: 104px;
  }

  .login-brand h1 {
    margin-top: 22px;
    font-size: 28px;
  }

  .login-brand small {
    display: none;
  }
}

@media (max-width: 620px) {
  .metric-grid,
  .form-grid,
  .image-grid {
    grid-template-columns: 1fr;
  }

  .category-row {
    grid-template-columns: 1fr 36px;
  }

  .detail-header {
    min-width: 0;
    align-items: flex-start;
  }

  .detail-header > div {
    min-width: 0;
  }

  .category-row .category-description {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .page-actions .button {
    flex: 1 1 auto;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .control-action-row {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .control-action-row .inline-actions,
  .control-action-row .button {
    width: 100%;
  }

  .search-field {
    width: 100%;
  }

  .login-main {
    padding: 28px 20px;
  }
}
