:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #b45309;
  --bad: #b42318;
  --ok: #15803d;
  --shadow: 0 10px 24px rgba(24, 39, 75, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hidden {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.auth-gate {
  display: grid;
  min-height: 100vh;
  align-items: start;
  justify-items: center;
  padding: 18px;
}

.auth-panel {
  width: min(720px, 100%);
  margin-top: min(8vh, 42px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lead {
  margin: 8px 0 16px;
  color: var(--muted);
}

.consent-box {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.consent-row {
  display: flex;
  gap: 10px;
  align-items: start;
  color: #27364a;
  min-width: 0;
  line-height: 1.4;
}

.consent-row input {
  flex: 0 0 auto;
  margin-top: 3px;
}

.consent-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.consent-row a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.auth-actions {
  display: grid;
  gap: 10px;
}

.primary-action,
.secondary-action {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}

.primary-action {
  border: 0;
  background: var(--accent);
  color: white;
}

.primary-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondary-action {
  border: 1px solid var(--line);
  background: #f2f5f8;
  color: var(--muted);
}

.telegram-widget {
  min-height: 0;
}

.legal-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.legal-page {
  width: min(860px, 100%);
  margin: 0 auto;
  padding: 24px 18px 48px;
}

.legal-page section {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 6vw, 44px);
  line-height: 1.02;
}

h2 {
  font-size: 18px;
}

.profile-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  margin-bottom: 14px;
}

.profile-strip > div {
  min-width: 0;
  background: var(--panel);
  padding: 13px;
}

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

.upload-panel {
  display: grid;
  grid-template-columns: 1fr minmax(210px, 280px);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.upload-panel p {
  max-width: 620px;
  margin: 6px 0 0;
  color: var(--muted);
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 104px;
  padding: 14px;
  border: 1px dashed #9aa8b7;
  border-radius: 8px;
  background: #fbfcfe;
  cursor: pointer;
  text-align: center;
}

.upload-box input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-title {
  color: var(--accent-strong);
  font-weight: 800;
}

.upload-hint {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 14px 0;
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e7f5f3;
  color: var(--accent-strong);
  font-weight: 800;
}

.analysis-list,
.plans-list {
  display: grid;
  gap: 10px;
}

.analysis-card,
.plan-card,
.chart-wrap,
.marker-info {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.analysis-main {
  display: grid;
  width: 100%;
  gap: 4px;
  padding: 14px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.file-name {
  font-weight: 800;
}

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

.markers {
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  padding: 0 14px 14px;
}

.analysis-card.open .markers {
  display: grid;
}

.marker {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.marker-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.marker small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.status-normal {
  color: var(--ok);
}

.status-low,
.status-high {
  color: var(--warn);
}

.chart-wrap {
  padding: 12px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

select {
  min-height: 40px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

.marker-info,
.plan-card {
  padding: 14px;
}

.plan-card {
  display: grid;
  gap: 8px;
}

.plan-card button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

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

  .upload-panel,
  .profile-strip {
    grid-template-columns: 1fr;
  }

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