@font-face {
  font-family: 'KOMedia';
  src: url('./assets/fonts/alfont_com_KOMedia-Black.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --primary: #2c8091;
  --primary-dark: #176b7a;
  --bg: #faf7f5;
  --alert: #e76f51;
  --soft: #f3f6f8;
  --text: #1f2937;
  --muted: #64748b;
  --white: #ffffff;
  --card: #ffffff;
  --header-bg: linear-gradient(135deg, #ffffff, #eef7f8);
  --border: rgba(31, 41, 55, 0.07);
  --input-border: #d8e2e8;
  --table-head: #f8fbfc;
  --row-hover: #fbfdfd;
  --progress-track: #D9E3E8;
  --close-bg: #eef2f5;
  --danger: #c2410c;
  --success: #17845f;
  --shadow: 0 18px 45px rgba(23, 107, 122, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(44, 128, 145, 0.08), transparent 38%),
    var(--bg);
  color: var(--text);
  font-family: Tahoma, Arial, sans-serif;
  letter-spacing: 0;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

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

.site-header {
  display: grid;
  grid-template-columns: 170px 1fr 170px;
  align-items: center;
  gap: 18px;
  padding: 22px;
  background: var(--header-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.logo-slot {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 112px;
  padding: 6px;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: var(--primary-dark);
  font-weight: 700;
  text-align: center;
}

.logo-slot img {
  display: block;
  width: 100%;
  max-width: 158px;
  height: 96px;
  object-fit: contain;
}

.logo-slot.donor img {
  max-width: 128px;
  height: 78px;
}

.logo-slot span {
  display: none;
  color: var(--muted);
  font-size: 0.78rem;
}

.logo-slot img:not([src]),
.logo-slot img[src=""] {
  display: none;
}

.logo-slot img:not([src]) + span,
.logo-slot img[src=""] + span {
  display: block;
}

.header-copy {
  text-align: center;
}

.admin-access {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
  padding-inline-end: 8px;
}

.sarcode-line {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto minmax(28px, 72px);
  align-items: center;
  gap: 10px;
  flex: 1;
  opacity: 0.86;
}

.sarcode-line span,
.sarcode-line i {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(44, 128, 145, 0.14), #2C8091 52%, #E76F51);
}

.sarcode-line i {
  height: 2px;
  background: linear-gradient(90deg, #E76F51, rgba(23, 107, 122, 0.18));
}

.sarcode-line strong {
  color: rgba(23, 107, 122, 0.72);
  font-family: Tahoma, Arial, sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
}

.admin-icon-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(44, 128, 145, 0.64);
  font-size: 1.05rem;
  line-height: 1;
  box-shadow: none;
  transition: transform 0.2s ease, color 0.2s ease;
}

.admin-icon-button:hover,
.admin-icon-button:focus-visible {
  transform: translateY(-1px);
  color: var(--primary-dark);
  background: transparent;
  outline: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2,
.kpi-card span,
.kpi-card strong,
.panel-heading h2,
.modal-card h2 {
  font-family: 'KOMedia', Tahoma, Arial, sans-serif;
}

h1 {
  margin-bottom: 0;
  color: var(--primary-dark);
  font-size: clamp(1.65rem, 3vw, 2.75rem);
  line-height: 1.25;
}

.header-copy p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

main {
  margin-top: 18px;
}

.site-footer {
  margin-top: 28px;
  padding: 18px 12px 4px;
  border-top: 1px solid rgba(44, 128, 145, 0.14);
  text-align: center;
}

.site-footer p {
  margin: 0;
  color: rgba(31, 41, 55, 0.58);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.6;
}

.state-panel,
.upload-panel,
.error-panel,
.panel,
.toolbar,
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(31, 41, 55, 0.07);
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.state-panel,
.upload-panel,
.error-panel {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 260px;
  padding: 28px;
  text-align: center;
}

.error-panel {
  color: #8a250e;
  background: #fff7ed;
  border-color: rgba(194, 65, 12, 0.2);
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid #d7edf1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

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

.upload-panel {
  grid-template-columns: 1fr auto;
  align-items: center;
  text-align: right;
}

.upload-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.file-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-picker span,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.file-picker span,
.primary-button {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(44, 128, 145, 0.24);
}

.secondary-button {
  background: color-mix(in srgb, var(--card) 72%, var(--primary) 28%);
  color: var(--primary-dark);
}

.danger-button {
  width: 100%;
  background: color-mix(in srgb, var(--card) 78%, var(--alert) 22%);
  color: var(--danger);
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.file-picker span:hover {
  transform: translateY(-1px);
}

.dashboard {
  display: grid;
  gap: 18px;
}

.dashboard > *,
.chart-grid > *,
.panel,
.toolbar {
  min-width: 0;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(260px, 320px);
  align-items: end;
  justify-content: start;
  gap: 14px;
  padding: 16px;
}

.field,
.modal-card label,
.program-form label,
.admin-list label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 128, 145, 0.14);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  min-height: 124px;
  padding: 18px;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 5px;
  height: 100%;
  background: var(--primary);
}

.kpi-card.accent::before {
  background: var(--primary);
}

.kpi-card span {
  color: var(--muted);
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin-top: 18px;
  color: var(--primary-dark);
  font-size: clamp(1.5rem, 2.6vw, 2.35rem);
}

.chart-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 0;
  color: var(--primary-dark);
  font-size: 1.15rem;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.chart-panel {
  min-height: 360px;
}

.chart-panel canvas {
  width: 100% !important;
  max-height: 295px;
}

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

.section-item {
  padding: 14px;
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.section-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-meta strong {
  color: var(--text);
}

.section-meta span {
  color: var(--primary-dark);
  font-weight: 800;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  background: var(--progress-track);
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--progress-gradient, linear-gradient(90deg, var(--primary), var(--primary-dark)));
  border-radius: inherit;
  box-shadow: 0 2px 8px rgba(44, 128, 145, 0.25);
  transition: width 0.6s ease, background 0.3s ease;
}

.progress-low {
  --progress-gradient: linear-gradient(90deg, #EF4444, #F97316);
}

.progress-mid {
  --progress-gradient: linear-gradient(90deg, #F97316, #06B6D4);
}

.progress-good {
  --progress-gradient: linear-gradient(90deg, #06B6D4, #2C8091);
}

.progress-excellent {
  --progress-gradient: linear-gradient(90deg, #2C8091, #10B981);
}

.section-values {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

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

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--table-head);
  font-size: 0.86rem;
}

tbody tr:hover {
  background: var(--row-hover);
}

.table-progress {
  display: grid;
  gap: 7px;
  min-width: 130px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.82rem;
}

.badge.not-started {
  color: #b91c1c;
  background: #fee2e2;
}

.badge.active {
  color: #c2410c;
  background: #ffedd5;
}

.badge.done {
  color: #047857;
  background: #d1fae5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(7px);
}

.modal {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  border: 0;
  background: transparent;
}

.large-modal {
  width: min(920px, calc(100% - 28px));
}

.modal::backdrop {
  background: transparent;
}

.modal-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);
  color: var(--text);
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.modal-card h2 {
  margin-bottom: 0;
  color: var(--primary-dark);
}

.modal-note {
  margin: 0;
  color: var(--muted);
}

.icon-close {
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--close-bg);
  color: var(--text);
  font-size: 1.4rem;
}

.full {
  width: 100%;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.admin-head,
.admin-layout,
.form-row {
  display: grid;
  gap: 14px;
}

.admin-head {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding-inline-start: 44px;
}

.admin-layout {
  grid-template-columns: minmax(220px, 0.78fr) 1.22fr;
}

.admin-list,
.program-form {
  display: grid;
  gap: 12px;
}

#adminProgramSelect {
  min-height: 270px;
  padding: 8px;
}

.form-row {
  grid-template-columns: 1fr 1fr;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  transform: translateY(120%);
  padding: 14px 18px;
  background: var(--primary-dark);
  color: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-weight: 700;
  transition: transform 0.25s ease;
}

.toast.show {
  transform: translateY(0);
}

@media (max-width: 1000px) {
  .site-header {
    grid-template-columns: 132px 1fr 132px;
  }

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

  .chart-grid {
    grid-template-columns: 1fr;
  }
}

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

  .site-header {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 18px 16px 20px;
    width: 100%;
  }

  .header-copy {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 0;
  }

  .admin-access {
    justify-content: flex-end;
    margin-top: 8px;
    padding-inline-end: 8px;
  }

  .sarcode-line {
    gap: 8px;
  }

  .sarcode-line strong {
    font-size: 0.66rem;
  }

  .sarcode-line span {
    height: 3px;
  }

  .logo-slot {
    min-height: 92px;
    padding: 4px 8px;
    font-size: 0.95rem;
  }

  .logo-slot img {
    max-width: 146px;
    height: 86px;
  }

  .logo-slot.donor img {
    max-width: 118px;
    height: 70px;
  }

  h1 {
    margin-bottom: 0;
    font-size: 1.9rem;
    line-height: 1.32;
  }

  .toolbar,
  .upload-panel,
  .admin-head,
  .admin-layout,
  .form-row {
    grid-template-columns: 1fr;
  }

  .toolbar {
    gap: 12px;
    padding: 14px;
    justify-content: stretch;
  }

  .toolbar .section-field {
    order: 1;
  }

  .toolbar .program-field {
    order: 2;
  }

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

  .chart-panel {
    min-height: 320px;
  }

  .modal-card {
    max-height: 88vh;
    overflow-y: auto;
    padding: 20px;
  }

  .site-footer {
    margin-top: 22px;
    padding: 16px 10px 2px;
  }

  .site-footer p {
    font-size: 0.84rem;
  }
}

@media (max-width: 460px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.68rem;
  }

  .site-header {
    padding: 16px 14px 18px;
  }

  .logo-slot {
    min-height: 82px;
    font-size: 0.88rem;
  }

  .logo-slot img {
    max-width: 136px;
    height: 78px;
  }

  .logo-slot.donor img {
    max-width: 108px;
    height: 64px;
  }
}
