:root {
  color-scheme: light;
  --ink: #18212b;
  --muted: #687382;
  --line: #dfe5ea;
  --panel: #ffffff;
  --page: #f4f6f8;
  --green: #16834f;
  --green-bg: #e8f6ef;
  --red: #b9363d;
  --red-bg: #fdebec;
  --grey: #6b7280;
  --grey-bg: #eef1f4;
  --blue: #275f9d;
  --blue-bg: #eaf2fb;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drop-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 131, 79, 0.22);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(22, 131, 79, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 131, 79, 0);
  }
}

@keyframes check-pop {
  from {
    opacity: 0;
    transform: scale(0.72);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

.sidebar {
  min-height: 100vh;
  background: #18212b;
  color: #e9eef3;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  width: 100%;
  max-width: 280px;
  overflow: hidden auto;
  z-index: 2;
}

.brand {
  display: grid;
  gap: 10px;
  align-items: start;
  margin-bottom: 24px;
  min-width: 0;
  overflow: hidden;
}

.brand-logo {
  display: block;
  width: min(180px, 100%);
  max-height: 44px;
  object-fit: contain;
  background: #fff;
  border-radius: 7px;
  padding: 6px;
}

.brand small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  color: #aab7c4;
}

.country-tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 22px;
}

.country-tabs a,
.nav a,
.logout button,
.nav-group summary {
  display: block;
  width: 100%;
  color: #dce5ed;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.country-tabs a {
  border: 1px solid #334150;
}

.country-tabs a.active,
.nav a:hover,
.logout button:hover,
.nav-group summary:hover {
  background: var(--green);
  color: #fff;
  transform: translateX(2px);
}

.nav {
  display: grid;
  gap: 5px;
}

.nav-group {
  border: 1px solid #334150;
  border-radius: 7px;
  overflow: hidden;
}

.nav-group summary {
  list-style: none;
  font-weight: 750;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary::after {
  content: "▾";
  float: right;
  transition: transform 180ms ease;
}

.nav-group[open] summary::after {
  transform: rotate(180deg);
}

.nav-group a {
  padding-left: 24px;
  border-radius: 0;
  font-size: 14px;
}

.nav-group a small {
  color: #aab7c4;
  float: right;
}

.nav-label {
  display: block;
  padding: 10px 12px 4px 24px;
  color: #aab7c4;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.flag,
.page-flag {
  display: inline-block;
  margin-right: 8px;
}

.page-flag {
  font-size: 0.9em;
  vertical-align: 0.04em;
}

.logout {
  margin-top: 28px;
}

.signed-in {
  display: block;
  color: #aab7c4;
  margin: 0 0 8px 12px;
}

.main {
  padding: 28px;
  min-width: 0;
  overflow: hidden;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

p {
  color: var(--muted);
  margin: 8px 0 0;
  overflow-wrap: anywhere;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 0;
  border-radius: 7px;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  transition: background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  transition: background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.button:hover,
button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(22, 131, 79, 0.16);
}

button:disabled {
  cursor: wait;
  opacity: 0.76;
  transform: none;
  box-shadow: none;
}

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

.button-row form {
  margin: 0;
}

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

.confirm-panel {
  border-color: #f1d590;
  background: #fffdf6;
  display: grid;
  gap: 18px;
}

.confirm-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 0;
}

.confirm-header > div {
  min-width: 0;
}

.confirm-header .status {
  flex: 0 0 auto;
  margin-top: 2px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
  animation: rise-in 220ms ease both;
}

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

.compact-title {
  align-items: center;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
}

.chip.active,
.chip:hover {
  border-color: #b7e2cb;
  background: var(--green-bg);
  color: var(--green);
}

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

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

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

.metric span {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 28px;
  line-height: 1.15;
}

.metric .small-value {
  font-size: 15px;
  word-break: break-word;
}

.metric.green {
  background: var(--green-bg);
  border-color: #b7e2cb;
}

.metric.green strong {
  color: var(--green);
}

.metric.red {
  background: var(--red-bg);
  border-color: #f3c0c5;
}

.metric.red strong {
  color: var(--red);
}

.metric.grey {
  background: var(--grey-bg);
}

.metric.grey strong {
  color: var(--grey);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: #35414f;
  font-weight: 650;
}

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

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

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.checkbox input {
  width: auto;
}

.upload-form {
  gap: 16px;
}

.upload-form .drop-zone {
  grid-column: 1 / -1;
}

.drop-zone {
  position: relative;
  overflow: hidden;
  min-height: 132px;
  display: grid;
  align-content: center;
  gap: 6px;
  grid-column: span 1;
  border: 2px dashed #b9c6d3;
  border-radius: 8px;
  padding: 18px;
  background: #f8fafc;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.drop-zone::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  pointer-events: none;
  transition: border-color 180ms ease, opacity 180ms ease;
  opacity: 0;
}

.drop-zone:hover,
.drop-zone.drag-over,
.drop-zone.file-hover {
  border-color: var(--green);
  background: var(--green-bg);
  transform: translateY(-2px) scale(1.006);
  box-shadow: 0 12px 28px rgba(22, 131, 79, 0.14);
}

.drop-zone.drag-over,
.drop-zone.file-hover {
  animation: drop-pulse 900ms ease infinite;
}

.drop-zone:hover::after,
.drop-zone.drag-over::after,
.drop-zone.file-hover::after {
  border-color: rgba(22, 131, 79, 0.38);
  opacity: 1;
}

.drop-zone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.drop-title {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
}

.drop-copy,
.file-name {
  color: var(--muted);
  font-weight: 600;
}

.file-name {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px auto auto auto;
  gap: 12px;
  align-items: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
}

.summary-grid span {
  background: #f6f8fa;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  color: var(--muted);
}

.summary-grid strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  margin-top: 4px;
}

.import-confirm-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.import-confirm-grid span {
  min-height: 92px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.confirm-panel .alert {
  margin: 0;
}

.confirm-panel .result-actions {
  margin-top: 2px;
}

.progress-panel {
  border-color: #bad2ed;
}

.success-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid #b7e2cb;
  border-radius: 8px;
  background: var(--green-bg);
  color: var(--green);
  margin-bottom: 16px;
  animation: rise-in 220ms ease both;
}

.success-card h2 {
  color: var(--ink);
  margin-bottom: 2px;
}

.success-card p {
  margin: 0;
}

.success-check {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
  animation: check-pop 220ms ease both;
}

.success-check.small {
  width: 28px;
  height: 28px;
  font-size: 17px;
}

.page-preloader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(244, 246, 248, 0.78);
  backdrop-filter: blur(4px);
}

.page-preloader[hidden] {
  display: none;
}

.loader-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(280px, calc(100vw - 40px));
  padding: 22px;
  border: 1px solid #b7e2cb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 55px rgba(24, 33, 43, 0.14);
  text-align: center;
}

.loader-card small {
  color: var(--muted);
}

.loader-ring {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 4px solid #d8efe4;
  border-top-color: var(--green);
  animation: spin 700ms linear infinite;
}

.loader-ring.large {
  width: 58px;
  height: 58px;
  border-width: 5px;
}

.loading-page {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
  padding: 46px 0;
}

.loading-card {
  width: min(360px, 100%);
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 34px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 55px rgba(24, 33, 43, 0.08);
  text-align: center;
}

.loading-card h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
}

.progress-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ecf4;
  margin: 18px 0 12px;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
  transition: width 260ms ease;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.progress-steps span {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.progress-steps span.active {
  color: var(--green);
}

.result-actions {
  align-items: center;
  margin-top: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
  background: #fff;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #edf0f3;
  vertical-align: top;
}

th {
  background: #fff;
  font-size: 12px;
  text-transform: uppercase;
  color: #45515f;
  border-bottom: 1px solid var(--line);
}

.contact-table tbody tr {
  background: #fff;
}

.contact-table tbody tr:hover {
  background: #f9fbfc;
}

.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.green {
  background: var(--green-bg);
  color: var(--green);
}

.status.red {
  background: var(--red-bg);
  color: var(--red);
}

.status.grey {
  background: var(--grey-bg);
  color: var(--grey);
}

details summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 700;
}

.edit-form {
  display: grid;
  gap: 8px;
  width: min(380px, 80vw);
  margin-top: 10px;
}

.delete-form {
  margin-top: 8px;
}

.alert {
  padding: 12px 14px;
  border-radius: 7px;
  background: var(--blue-bg);
  color: #234e83;
  border: 1px solid #bad2ed;
  margin-bottom: 14px;
}

.alert.warning {
  background: #fff6df;
  color: #7a5200;
  border-color: #f1d590;
}

.alert.danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: #f3c0c5;
}

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

pre {
  white-space: pre-wrap;
  background: #0f1720;
  color: #f0f4f8;
  padding: 14px;
  border-radius: 7px;
}

.login-page {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-logo {
  width: 180px;
  max-width: 100%;
  display: block;
  margin-bottom: 18px;
}

.login-panel form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .metric-grid,
  .summary-grid,
  .form-grid,
  .filters {
    grid-template-columns: 1fr;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .loading-card {
    padding: 24px;
  }

  .loading-card h1 {
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
