﻿:root {
  --bg: #f4f6f2;
  --surface: #ffffffd9;
  --surface-strong: #ffffff;
  --line: #d9e1d6;
  --line-strong: #c6d0c2;
  --text: #152018;
  --muted: #536257;
  --accent: #0f766e;
  --accent-strong: #0b4f66;
  --good: #0f766e;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 16px;
  --shadow: 0 14px 46px -26px rgba(15, 23, 42, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Manrope, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 8% 5%, #e5efe7 0%, #f4f6f2 42%, #eef2ef 100%);
  min-height: 100vh;
}

.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(64px);
  opacity: 0.52;
  z-index: -1;
}

.bg-shape-1 {
  width: 360px;
  height: 360px;
  background: #bfe9db;
  top: -110px;
  right: -90px;
}

.bg-shape-2 {
  width: 280px;
  height: 280px;
  background: #c4d8f8;
  bottom: -70px;
  left: -70px;
}

.topbar {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 28px) clamp(10px, 2vw, 22px) clamp(8px, 1.4vw, 14px);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: flex-start;
}

.eyebrow {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 8px 0 8px;
  font-family: Fraunces, Manrope, serif;
  font-size: clamp(1.45rem, 2.4vw, 2.2rem);
  line-height: 1.14;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-badge {
  align-self: center;
  font-size: 0.76rem;
  font-weight: 800;
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff7eb;
  color: #b45309;
  border: 1px solid #f7ddb7;
}

.auth-badge.ok {
  background: #e7f7f1;
  color: #0f766e;
  border-color: #b9ebda;
}

#import-tables-file,
#import-pgdas-file {
  display: none;
}

.btn {
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-file {
  display: inline-block;
}

.btn-ghost {
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--line);
}

.btn-memory {
  background: linear-gradient(135deg, #1d4ed8, #0f766e);
}

.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(8px, 1.2vw, 10px) clamp(10px, 2vw, 22px) clamp(14px, 2vw, 28px);
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(10px, 1.2vw, 16px);
}

body.app-locked .layout {
  filter: blur(2px);
  opacity: 0.65;
  pointer-events: none;
  user-select: none;
}

.panel {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(10px, 1.2vw, 16px);
}

h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: Fraunces, Manrope, serif;
}

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

.kpi-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.kpi {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.admin-kpi {
  margin-top: 10px;
}

.admin-kpi.hidden {
  display: none;
}

.admin-kpi .kpi {
  border-color: #bdd8f4;
  background: #f4f8ff;
}

.kpi strong {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi span {
  font-size: 1.12rem;
  font-weight: 800;
}

.health-checks {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.81rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.chip.good {
  background: #e7f7f1;
  color: #0f766e;
  border-color: #b9ebda;
}

.chip.warn {
  background: #fff7eb;
  color: #b45309;
  border-color: #f7ddb7;
}

.input-sections {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.tax-tables-view {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 10px;
}

.single-view {
  grid-template-columns: 1fr;
  padding: 8px 10px 12px;
  max-height: 68vh;
  overflow: auto;
}

.tax-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.tax-block h3 {
  margin: 0;
  padding: 7px 10px;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--line);
  background: #f6faf7;
}

.tax-dialog {
  width: min(980px, calc(100vw - 24px));
}

.tax-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 10px 0;
}

.tax-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.tax-tab.active {
  background: #e8f5f1;
  border-color: #b4dfd3;
  color: #0b625c;
}

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

.tax-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 0.78rem;
  table-layout: auto;
}

.tax-table th,
.tax-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #eef2ee;
  text-align: right;
  white-space: normal;
}

.tax-table th:first-child,
.tax-table td:first-child {
  text-align: left;
  width: 20%;
}

.tax-kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #eef2ee;
  font-size: 0.8rem;
}

.input-group {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.input-group h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-family: Fraunces, Manrope, serif;
}

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

.field {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.94rem;
}

.input-formatted {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.factor-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  padding: 12px;
}

.stat strong {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 5px;
}

.stat span {
  font-size: 1.12rem;
  font-weight: 800;
}

.status-good {
  color: var(--good);
}

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

.cards {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 8px;
}

.card {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.card.best {
  border-color: #a8decf;
  box-shadow: inset 0 0 0 1px #d0eee4;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.card .line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0;
  font-size: 0.88rem;
}

.card .line strong {
  font-size: 1rem;
}

.note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 8px;
  background: #fff;
}

.table-wrap table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f7f3;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  cursor: pointer;
}

.table-wrap tbody td {
  border-bottom: 1px solid #edf1ec;
  padding: 10px 8px;
}

.table-wrap tbody tr:hover td {
  background: #f4fbf9;
}

.regime-name {
  font-weight: 700;
}

.delta-low {
  color: var(--good);
  font-weight: 700;
}

.delta-high {
  color: var(--warn);
  font-weight: 700;
}

.memory-dialog {
  width: min(980px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
}

.memory-dialog::backdrop {
  background: rgba(14, 24, 18, 0.35);
}

.memory-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #f5faf7;
}

.memory-content {
  max-height: 70vh;
  overflow: auto;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.growth-dialog {
  width: min(1080px, calc(100vw - 24px));
}

.growth-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 220px 140px 150px;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.growth-controls label {
  display: grid;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.growth-controls input {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.9rem;
}

.growth-controls select {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.9rem;
  background: #fff;
}

.growth-canvas-wrap {
  padding: 12px;
  height: 60vh;
  min-height: 340px;
}

.memory-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.memory-block h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.memory-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.86rem;
  padding: 3px 0;
}

.auth-dialog {
  width: min(700px, calc(100vw - 24px));
}

.auth-content {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.auth-token-grid {
  grid-template-columns: 1fr;
  max-width: 220px;
}

.auth-grid label {
  display: grid;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.auth-grid input {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.92rem;
}

.auth-row {
  display: flex;
  gap: 8px;
}

.auth-admin-box {
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  margin-top: 2px;
}

.auth-admin-grid {
  grid-template-columns: minmax(200px, 320px);
}

@media (max-width: 1120px) {
  .growth-controls {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .topbar,
  .layout {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    flex-direction: column;
  }

  .actions {
    width: 100%;
    justify-content: flex-start;
  }

  .memory-dialog,
  .growth-dialog,
  .tax-dialog {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    margin: 0 auto;
  }

  .growth-controls {
    grid-template-columns: 1fr 1fr;
  }

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

  .growth-canvas-wrap {
    height: 52vh;
    min-height: 280px;
  }
}

@media (max-width: 560px) {
  .actions {
    gap: 6px;
  }

  .btn {
    padding: 8px 11px;
    font-size: 0.78rem;
  }

  .growth-controls {
    grid-template-columns: 1fr;
  }

  .tax-table {
    font-size: 0.74rem;
  }

  .tax-table th,
  .tax-table td {
    padding: 4px 5px;
  }
}
