:root {
  color-scheme: dark;
  --bg: #0c1410;
  --surface: #142019;
  --surface-soft: #1b2a21;
  --text: #edf5ef;
  --muted: #a4b4a8;
  --border: #314239;
  --accent: #64d39d;
  --accent-2: #72a8d5;
  --warning: #efb451;
  --danger: #ee8178;
  --success: #63d39c;
  --input: #101b15;
  --header-start: #08100c;
  --header-end: #142b20;
  --shadow: 0 10px 28px rgba(0, 0, 0, .28);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --text: #202420;
  --muted: #667066;
  --border: #dfe5dd;
  --accent: #176b4d;
  --accent-2: #285f8f;
  --warning: #b26a00;
  --danger: #b03b33;
  --success: #16744f;
  --input: #ffffff;
  --header-start: #101a14;
  --header-end: #193328;
  --shadow: 0 8px 22px rgba(26, 36, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.admin-header {
  min-height: 72px;
  padding: 12px 22px;
  background: linear-gradient(110deg, var(--header-start) 0%, #17261d 60%, var(--header-end) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #fff;
  font-weight: 750;
  font-size: 17px;
  letter-spacing: -.2px;
  white-space: nowrap;
}

.brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #63d39c;
  box-shadow: 0 0 0 4px rgba(99,211,156,.13);
}

.admin-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.nav-group {
  position: relative;
}

.nav-group summary {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}

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

.nav-group summary::after {
  content: "⌄";
  margin-left: 7px;
  color: rgba(255,255,255,.42);
  font-size: 10px;
  transform: translateY(-1px);
}

.nav-title strong {
  color: #76dba9;
  font-weight: 800;
}

.nav-group.active summary,
.nav-group[open] summary,
.nav-group summary:hover {
  color: #fff;
  border-color: rgba(118,219,169,.2);
  background: rgba(255, 255, 255, 0.075);
  text-decoration: none;
}

.nav-group.active summary {
  background: rgba(99,211,156,.13);
}

.nav-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(300px, calc(100vw - 32px));
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(7,22,13,.24), 0 3px 9px rgba(7,22,13,.08);
}

.nav-group:nth-last-child(-n+2) .nav-menu {
  right: 0;
  left: auto;
}

.nav-menu p {
  margin: 3px 8px 9px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.nav-menu a {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
}

.nav-menu a span {
  min-width: 29px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.admin-nav a,
.admin-account a,
.logout-form button {
  color: rgba(255, 255, 255, 0.84);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}

.admin-nav a.active,
.admin-nav a:hover,
.admin-account a:hover,
.logout-form button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  text-decoration: none;
}

.admin-nav .nav-menu a {
  min-height: 39px;
  padding: 8px 10px;
  color: var(--text);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
}

.admin-nav .nav-menu a:hover,
.admin-nav .nav-menu a.active {
  color: var(--accent);
  background: var(--surface-soft);
  text-decoration: none;
}

.admin-nav .nav-menu a.active {
  box-shadow: inset 3px 0 #2ca56d;
}

.admin-account {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  white-space: nowrap;
}

.theme-switch {
  min-height: 36px;
  padding: 6px 10px;
  gap: 6px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 12px;
}

.theme-switch:hover,
.theme-switch:focus-visible {
  background: rgba(255,255,255,.16);
}

.logout-form {
  margin: 0;
}

.logout-form input {
  display: none;
}

.logout-form button {
  min-height: auto;
  border: 0;
  background: transparent;
}

.logout-form button {
  border: 1px solid rgba(255,255,255,.13);
}

.admin-main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

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

h1,
h2,
h3 {
  margin: 0 0 14px;
  line-height: 1.18;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
}

.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  font-size: 30px;
  line-height: 1;
  font-weight: 700;
}

.metric p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.layout-two,
.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.65fr);
  gap: 18px;
}

.summary-grid {
  grid-template-columns: 1fr 0.9fr;
}

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

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

.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

.table small,
small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.score {
  min-width: 40px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  padding: 5px 8px;
  font-weight: 700;
  font-size: 13px;
}

.score.big {
  width: 76px;
  height: 76px;
  font-size: 28px;
}

.score-good {
  color: #0f4f39;
  background: #dff2e9;
}

.score-watch {
  color: #6b4300;
  background: #fff2d8;
}

.score-risk {
  color: #8b271f;
  background: #ffe2df;
}

.status {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.decision-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.facts div,
.mini-score {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
}

.facts dt {
  color: var(--muted);
  font-size: 12px;
}

.facts dd {
  margin: 3px 0 0;
  font-weight: 700;
}

.mini-score span {
  display: block;
  font-size: 20px;
  font-weight: 700;
}

.mini-score p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

textarea {
  resize: vertical;
}

label {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 13px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.button-link:hover {
  text-decoration: none;
  filter: brightness(0.95);
}

.secondary-button {
  background: var(--accent-2);
}

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

.button-link.secondary {
  background: var(--accent-2);
}

.row-action {
  font-weight: 700;
}

.form-grid,
.score-grid,
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.score-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.form-stack {
  display: grid;
  gap: 16px;
}

.actions,
.filter-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form {
  display: inline-flex;
  margin: 0 5px 6px 0;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: 0 0 auto;
}

.check-grid,
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.score-evidence-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.score-evidence-card,
.list-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

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

.check-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
}

.check-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.compact-form {
  margin-top: 8px;
  min-width: 200px;
}

.radar-queue-panel {
  display: grid;
  gap: 18px;
}

.candidate-filters {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.candidate-batch-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(210px, .45fr) auto;
  gap: 14px;
  align-items: end;
  margin: 0;
  background: linear-gradient(135deg, var(--surface-soft), var(--surface));
}

.candidate-batch-selector {
  width: fit-content;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.how-to-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.how-to-intro h2 { margin: 0 0 6px; }

.how-to-guide {
  --guide-muted: var(--muted);
  --guide-soft: var(--surface-soft);
  --guide-line: var(--border);
  max-width: 1040px;
  margin: 0 auto 32px;
  padding: 40px 48px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 16px;
  line-height: 1.58;
}

.how-to-guide h1 { font-size: 2.15rem; line-height: 1.15; color: var(--text); }
.how-to-guide h2 { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--guide-line); color: var(--accent); }
.how-to-guide h3 { margin-top: 32px; color: var(--text); }
.how-to-guide p,
.how-to-guide li { max-width: 84ch; }
.how-to-guide code { padding: .12em .35em; border-radius: 5px; background: var(--surface-soft); }
.how-to-guide blockquote { margin: 22px 0; padding: 14px 20px; border-left: 5px solid var(--warning); background: var(--surface-soft); }
.how-to-guide figure { margin: 28px auto 46px; padding: 14px; border: 1px solid var(--guide-line); border-radius: 14px; background: var(--guide-soft); text-align: center; }
.how-to-guide figure img { max-width: 100%; max-height: 860px; object-fit: contain; border-radius: 9px; box-shadow: 0 4px 18px #0002; }
.how-to-guide figcaption { margin-top: 10px; color: var(--guide-muted); font-size: .92rem; }
.how-to-guide .table-wrap { overflow-x: auto; }
.how-to-guide table { width: 100%; margin: 24px 0; border-collapse: collapse; }
.how-to-guide th,
.how-to-guide td { padding: 10px 12px; border: 1px solid var(--guide-line); text-align: left; vertical-align: top; }
.how-to-guide th { background: var(--guide-soft); }
.how-to-guide pre { overflow: auto; padding: 18px; border-radius: 10px; background: #14231b; color: #eaf7ef; }

.filter-title {
  display: grid;
  align-content: center;
  gap: 4px;
}

.radar-queue {
  display: grid;
  gap: 16px;
}

.radar-candidate-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent-2);
  border-radius: 10px;
  background: var(--surface);
}

.radar-candidate-card.risk-critical { border-left-color: var(--danger); }
.radar-candidate-card.risk-attention { border-left-color: #b26b00; }
.radar-candidate-card.risk-none { border-left-color: var(--success); }

.radar-card-head,
.radar-card-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.radar-card-head h3 { margin: 0 0 4px; }

.radar-card-identity {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  min-width: 0;
  flex: 1;
}

.radar-card-identity > div:last-child {
  min-width: 0;
}

.radar-product-image {
  display: grid;
  place-items: center;
  flex: 0 0 112px;
  width: 112px;
  height: 112px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.radar-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.radar-product-image.image-placeholder {
  padding: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.translation-waiting {
  background: #fff1d6;
  color: #825000;
}

.radar-panel-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.radar-panel-tools form {
  margin: 0;
}

.translation-worker-status {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.25;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
}

.translation-worker-status small { color: var(--muted); }
.translation-worker-status.is-active { border-color: var(--success); }
.translation-worker-status.is-active strong { color: var(--success); }
.translation-worker-status.is-waiting { border-color: var(--warning); }
.translation-worker-status.is-waiting strong { color: var(--warning); }
.translation-worker-status.is-disabled strong,
.translation-worker-status.is-unavailable strong { color: var(--danger); }

.risk-badge {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 800;
  background: var(--surface-soft);
}

.risk-badge.risk-critical { color: var(--danger); }
.risk-badge.risk-attention { color: #8a5200; }
.risk-badge.risk-none { color: var(--success); }

.radar-card-section {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.radar-card-section p { margin: 6px 0; }

.radar-score-strip,
.radar-card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.radar-score-strip > div,
.radar-card-grid > div {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.radar-score-strip span {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
}

.candidate-source-details {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.candidate-source-details > summary {
  padding: 11px 13px;
  color: var(--accent);
}

.candidate-source-details > p {
  margin: 0;
  padding: 0 13px 10px;
}

.candidate-source-list {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.candidate-source-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.4fr) minmax(130px, .8fr) minmax(220px, 1.2fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.candidate-source-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.compact-list {
  margin: 7px 0 0;
  padding-left: 18px;
}

.timer-running { color: var(--accent); font-weight: 800; }
.timer-overdue { color: var(--danger); font-weight: 800; }
.timer-done { color: var(--success); font-weight: 800; }
.timer-idle { font-weight: 700; }

.empty-state {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  text-align: center;
}

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

.text-danger {
  color: var(--danger);
}

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

.compact-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
}

.notice {
  padding: 12px 14px;
  background: #fff2d8;
  border: 1px solid #f0cf91;
  border-radius: 8px;
  margin-bottom: 16px;
  color: #533400;
}

.notice.success {
  background: #dff2e9;
  border-color: #b8dfcb;
  color: #0f4f39;
}

.add-block {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.add-block summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
}

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

.login-page {
  background: linear-gradient(135deg, var(--bg), var(--surface-soft));
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-theme-switch {
  float: right;
  border-color: var(--border);
  background: var(--surface-soft);
  color: var(--text);
}

.login-theme-switch:hover,
.login-theme-switch:focus-visible {
  background: var(--bg);
}

.login-panel p {
  color: var(--muted);
}

.small {
  color: var(--muted);
  font-size: 12px;
}

.bilingual-source {
  display: block;
  margin: 5px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.translation-state {
  display: inline-flex;
  margin: 0 0 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8f1fb;
  color: #285f8f;
  font-size: 11px;
  font-weight: 700;
}

.bilingual-title-panel h2 {
  margin-bottom: 6px;
}

code {
  background: var(--surface-soft);
  border-radius: 6px;
  padding: 2px 5px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 860px) {
  .admin-header {
    padding: 16px;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .admin-nav {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .nav-group,
  .nav-group summary {
    width: 100%;
  }

  .nav-menu {
    position: static;
    right: auto;
    left: auto;
    width: 100%;
    margin-top: 4px;
    box-shadow: none;
    border-color: rgba(255,255,255,.1);
    background: var(--surface);
  }

  .admin-account {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .admin-nav a {
    padding: 10px;
  }

  .metric-grid,
  .layout-two,
  .summary-grid,
  .module-grid,
  .check-grid,
  .score-evidence-grid,
  .radar-score-strip,
  .radar-card-grid,
  .text-columns {
    grid-template-columns: 1fr;
  }

  .candidate-batch-toolbar {
    grid-template-columns: 1fr;
  }

  .how-to-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .how-to-guide {
    padding: 26px 20px;
  }

  .radar-card-identity {
    align-items: stretch;
    flex-direction: column;
  }

  .radar-product-image {
    width: 100%;
    height: min(260px, 65vw);
    flex-basis: auto;
  }

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

  .table {
    display: block;
    overflow-x: auto;
  }
}
