:root {
  --bg: #0b1220;
  --panel: #111a2e;
  --panel-2: #132443;
  --line: #263554;
  --text: #eaf1ff;
  --muted: #8fa4c7;
  --ok: #cbefff;
  --card: #ffffff;
  --card-text: #1a2333;
  --soft: #eef5ff;
  --accent: #7cc4ff;
  --green: #4dd6b7;
  --danger: #d05050;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #09101c 0%, #0d1526 100%);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input { font: inherit; }
.hidden { display: none !important; }
.container { width: min(1480px, calc(100% - 40px)); margin: 24px auto 48px; }

.hero, .filter-panel, .brief-shell, .nav-panel, .login-panel {
  background: linear-gradient(135deg, #0f1a30 0%, #132443 50%, #0f1b33 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
}
.hero { padding: 26px; }
.hero-top { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: 34px; line-height: 1.15; }
.lead { max-width: 1120px; color: var(--ok); font-size: 15px; line-height: 1.6; }

.account-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(143, 164, 199, 0.25);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
.ghost-button, .reset-button, .primary-button, .nav-tab, .filter-chip, .pdf-button {
  border: 1px solid rgba(124, 196, 255, 0.3);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}
.ghost-button {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}
.primary-button, .reset-button, .pdf-button {
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(124, 196, 255, 0.2), rgba(77, 214, 183, 0.18));
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primary-button { background: linear-gradient(135deg, #2b81bd, #239f88); }
.danger-button {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(208, 80, 80, 0.5);
  background: rgba(208, 80, 80, 0.12);
  color: #ffd6d6;
  cursor: pointer;
  font-weight: 800;
}

.dashboard { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}
.label, label, .filter-title, .metric-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.value { margin-top: 8px; font-size: 28px; font-weight: 800; line-height: 1.1; }
.sub { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.45; }

.nav-panel { display: flex; gap: 8px; margin-top: 16px; padding: 10px; }
.nav-tab {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}
.nav-tab.active { background: linear-gradient(135deg, rgba(124, 196, 255, 0.3), rgba(77, 214, 183, 0.18)); }

.filter-panel, .brief-shell { margin-top: 16px; padding: 16px; }
.filter-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
label { display: block; margin-bottom: 6px; }
input {
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  border-radius: 13px;
  border: 1px solid rgba(143, 164, 199, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  outline: none;
}
input::placeholder { color: #aac0e2; }
input[type="file"] { padding: 9px 12px; }

.filter-group { display: grid; gap: 8px; margin-top: 14px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 7px; min-width: 0; }
.filter-chips-tags { max-height: 170px; overflow: auto; padding-right: 4px; }
.filter-chip {
  min-width: 0;
  max-width: 100%;
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: left;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.filter-chip.active {
  border-color: rgba(124, 196, 255, 0.95);
  background: linear-gradient(135deg, rgba(124, 196, 255, 0.28), rgba(77, 214, 183, 0.16));
  transform: translateY(-1px);
}
.chip-count { flex: 0 0 auto; padding: 1px 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); font-size: 11px; }

.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 13px;
}
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.news-card {
  min-width: 0;
  background: var(--card);
  color: var(--card-text);
  border-radius: 22px;
  padding: 20px;
  border: 1px solid #dde6f5;
  box-shadow: var(--shadow);
}
.card-top, .meta-left, .meta-right, .impact-meta, .detail-links {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card-top { justify-content: space-between; margin-bottom: 14px; }
.source, .score-pill, .impact-pill, .main-tag, .version-pill {
  max-width: 100%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}
.source { background: #eef5ff; color: #22446f; padding: 7px 11px; font-size: 12px; }
.version-pill { background: #f5f0ff; color: #493878; padding: 7px 11px; font-size: 12px; }
.source-date, .card-index { color: #7b8ea8; font-size: 12px; font-weight: 700; }
.score-pill { background: #e9fbf5; color: #146b54; padding: 7px 11px; font-size: 12px; }
.news-card h3 { margin-bottom: 10px; font-size: 21px; line-height: 1.25; }
.main-tag {
  margin-bottom: 10px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #eaf4ff, #e8fbf4);
  color: #214364;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.preview { margin: 12px 0 0; color: #2b3951; line-height: 1.65; font-size: 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tag { display: inline-flex; align-items: center; padding: 7px 10px; border-radius: 999px; background: #f3f7fd; color: #2f4767; font-size: 12px; font-weight: 700; }
.news-card details { margin-top: 14px; border-top: 1px solid #e7edf7; padding-top: 14px; }
.news-card summary { list-style: none; cursor: pointer; user-select: none; font-weight: 800; }
.news-card summary::-webkit-details-marker { display: none; }
.news-card summary::before { content: "▸"; display: inline-block; margin-right: 8px; transition: transform 0.2s ease; }
.news-card details[open] summary::before { transform: rotate(90deg); }
.detail-block h4 { margin: 14px 0 8px; font-size: 13px; color: #395173; text-transform: uppercase; letter-spacing: 0.04em; }
.card-list { margin: 0 0 8px; padding-left: 18px; }
.card-list li { margin: 6px 0; line-height: 1.55; color: #273347; font-size: 14px; }
.impact-pill { padding: 7px 10px; background: #f1f6ff; color: #345175; font-size: 12px; }
.file-path { margin: 8px 0 0; color: #5c6f8a; font-size: 12px; overflow-wrap: anywhere; }
.empty-state {
  margin-top: 18px;
  padding: 24px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.section-title { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.map-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(143, 164, 199, 0.25);
  background: rgba(255, 255, 255, 0.03);
}
.metric-value { font-size: 22px; font-weight: 800; line-height: 1; }
.map-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.map-layout.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; }
.map-block {
  border: 1px solid rgba(143, 164, 199, 0.25);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  overflow: auto;
}
.map-block h2 { margin-bottom: 10px; font-size: 15px; }
.map-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.map-table th, .map-table td { border-bottom: 1px solid rgba(143, 164, 199, 0.22); padding: 8px; text-align: left; vertical-align: top; }
.map-table th { color: var(--ok); font-weight: 800; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr auto; gap: 8px; align-items: center; margin: 8px 0; font-size: 13px; }
.bar { height: 9px; border-radius: 999px; background: rgba(124, 196, 255, 0.16); overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); }

.admin-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.upload-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 1fr) auto; gap: 12px; align-items: end; }
.status-line { color: var(--ok); min-height: 20px; }
.versions-table-wrap { margin-top: 12px; overflow: auto; }
.versions-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.versions-table th, .versions-table td { padding: 10px; border-bottom: 1px solid rgba(143, 164, 199, 0.22); text-align: left; }
.versions-table th { color: var(--ok); }
.status-active { color: #9df4dc; font-weight: 800; }
.status-rolled { color: #f0a4a4; font-weight: 800; }

.login-shell { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.login-panel { width: min(460px, 100%); padding: 28px; }
.login-form { display: grid; gap: 12px; }
.form-error { color: #ffb3b3; min-height: 20px; margin: 0; }

@media (max-width: 1100px) {
  .dashboard, .cards, .map-layout, .map-layout.compact { grid-template-columns: 1fr 1fr; }
  .map-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .container { width: min(100% - 24px, 1480px); margin-top: 12px; }
  .hero-top, .results-bar, .admin-header { flex-direction: column; align-items: flex-start; }
  .dashboard, .cards, .filter-toolbar, .map-layout, .map-layout.compact, .map-grid, .upload-form { grid-template-columns: minmax(0, 1fr); }
  .nav-panel { flex-wrap: wrap; }
}
