:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: rgba(255, 255, 255, 0.86);
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe4ec;
  --blue: #2563eb;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --shadow: 0 22px 60px rgba(15, 23, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="dark"] {
  --bg: #0b1220;
  --panel: rgba(15, 23, 42, 0.88);
  --ink: #e5edf7;
  --muted: #94a3b8;
  --line: #26364a;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.34);
  background:
    radial-gradient(circle at 18% 12%, rgba(37, 99, 235, 0.26), transparent 28%),
    radial-gradient(circle at 82% 8%, rgba(16, 185, 129, 0.18), transparent 26%),
    linear-gradient(135deg, #020617, var(--bg));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 12%, rgba(37, 99, 235, 0.16), transparent 28%),
    radial-gradient(circle at 84% 8%, rgba(16, 185, 129, 0.14), transparent 26%),
    linear-gradient(135deg, #f8fbfd, var(--bg));
}

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

button {
  cursor: pointer;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr minmax(320px, 430px);
  gap: 34px;
  align-items: center;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.auth-brand span,
.brand span,
.topbar p,
.metric span,
.mini-card span,
.section-head span,
.row span,
.hint {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.auth-brand h1 {
  margin: 14px 0;
  max-width: 740px;
  font-size: clamp(2.35rem, 7vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.auth-brand p {
  margin: 0;
  max-width: 560px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
}

.glass,
.panel,
.metric,
.sidebar,
.mobile-nav {
  background: var(--panel);
  border: 1px solid rgba(219, 228, 236, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card,
.form {
  display: grid;
  gap: 14px;
}

.auth-card {
  border-radius: 8px;
  padding: 28px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 2px;
}

label {
  display: grid;
  gap: 7px;
  color: #475569;
  font-size: 0.84rem;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .ghost,
body[data-theme="dark"] .mini,
body[data-theme="dark"] .row,
body[data-theme="dark"] .mini-card,
body[data-theme="dark"] .search-results button {
  background: #101b2d;
  color: var(--ink);
  border-color: var(--line);
}

body[data-theme="dark"] .nav span,
body[data-theme="dark"] .segmented span {
  background: #162238;
  color: var(--ink);
}

body[data-theme="dark"] .nav.active {
  background: rgba(37, 99, 235, 0.22);
}

select[multiple] {
  min-height: 138px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.13);
}

.primary,
.ghost,
.link,
.nav,
.mini {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  font-weight: 900;
}

.primary {
  background: linear-gradient(135deg, var(--blue), #14b8a6);
  color: #fff;
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.24);
}

.primary.compact {
  padding: 0 16px;
}

.top-actions {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-actions select {
  width: auto;
  min-width: 150px;
}

.global-search {
  min-width: 220px;
}

.ghost,
.mini {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.link {
  background: none;
  color: var(--blue);
}

.full {
  width: 100%;
}

.error {
  margin: 0;
  min-height: 18px;
  color: var(--red);
  font-weight: 800;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px 1fr;
  gap: 20px;
  padding: 18px;
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: grid;
  gap: 4px;
}

.brand strong {
  font-size: 1.35rem;
}

.workspace-select {
  font-size: 0.76rem;
}

.workspace-select select {
  min-height: 38px;
  padding: 8px 10px;
}

.top-workspace {
  display: none;
  margin-top: 10px;
  max-width: 360px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
}

.nav span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--ink);
}

.nav.active {
  color: var(--ink);
  background: #eaf1ff;
}

.main {
  min-width: 0;
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.98;
}

.view {
  animation: rise 260ms ease both;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric,
.panel {
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.4rem, 3vw, 2.15rem);
  word-break: break-word;
}

.metric.good {
  border-top: 4px solid var(--green);
}

.metric.bad {
  border-top: 4px solid var(--red);
}

.metric.warn {
  border-top: 4px solid var(--amber);
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.wide-left {
  grid-template-columns: minmax(330px, 0.85fr) minmax(0, 1.35fr);
}

.panel {
  min-width: 0;
  padding: 18px;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 44px;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
}

.segmented span {
  display: grid;
  place-items: center;
  height: 44px;
  background: #fff;
  color: var(--muted);
}

.segmented input:checked + span {
  background: var(--ink);
  color: #fff;
}

.check {
  display: flex;
  align-items: center;
}

.check input {
  width: 18px;
  min-height: 18px;
}

canvas {
  display: block;
  width: 100%;
  height: 280px;
}

.list,
.cards {
  display: grid;
  gap: 10px;
}

.roomy {
  margin-top: 12px;
}

.row,
.mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.row strong,
.row span,
.row em,
.row small {
  display: block;
}

.row em {
  margin-top: 4px;
  color: #b45309;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 800;
}

.row b {
  text-align: right;
}

.row small {
  color: var(--muted);
  font-size: 0.78rem;
}

.mini {
  min-height: 34px;
  padding: 0 10px;
}

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

.mini-card {
  padding: 15px;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.mini-card:hover,
.row:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.mini-card h3 {
  margin: 7px 0;
}

.mini-card strong {
  display: block;
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.mini-card p {
  color: var(--muted);
  min-height: 38px;
}

.good-text {
  color: var(--green);
}

.bad-text {
  color: var(--red);
}

.empty {
  margin: 0;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.search-results {
  display: grid;
  gap: 7px;
}

.search-results button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  text-align: left;
  font-weight: 900;
}

.search-results span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.recommendations {
  display: grid;
  gap: 8px;
}

.recommendations > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.recommendations > div {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.recommendations button {
  flex: 0 0 150px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px;
  text-align: left;
  font-weight: 900;
}

body[data-theme="dark"] .recommendations button {
  background: #101b2d;
}

.recommendations b,
.recommendations span {
  display: block;
}

.recommendations b {
  margin-top: 3px;
  color: var(--green);
}

.recommendations button span {
  color: var(--muted);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.statement {
  display: grid;
  gap: 16px;
  background: #fff;
  color: #0f172a;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.statement-cover {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 18px;
}

.statement-cover span,
.statement-grid span {
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.statement-cover h1 {
  margin: 8px 0;
}

.statement-cover strong {
  font-size: 2rem;
}

.statement-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.statement-grid article,
.statement-chart,
.statement-table {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
}

.statement-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.25rem;
}

.statement-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.statement-chart {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  align-items: center;
}

.statement-chart h3 {
  grid-column: 1 / -1;
}

.css-pie {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  position: relative;
}

.css-pie::after {
  content: "";
  position: absolute;
  inset: 42px;
  border-radius: 50%;
  background: #fff;
}

.statement-legend {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 800;
}

.statement-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.statement-legend i {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

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

.statement table {
  width: 100%;
  border-collapse: collapse;
}

.statement th,
.statement td {
  border-bottom: 1px solid #e2e8f0;
  padding: 9px;
  text-align: left;
  font-size: 0.86rem;
}

.statement th {
  color: #475569;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: 1fr;
    padding-bottom: 92px;
  }

  .sidebar {
    display: none;
  }

  .top-workspace {
    display: grid;
  }

  .mobile-nav {
    position: fixed;
    z-index: 10;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: flex;
    gap: 4px;
    border-radius: 8px;
    padding: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .mobile-nav .nav {
    flex: 0 0 74px;
    display: grid;
    place-items: center;
    gap: 3px;
    min-height: 54px;
    padding: 4px;
    font-size: 0.7rem;
  }

  .mobile-nav .nav span {
    width: 26px;
    height: 24px;
  }

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

@media (max-width: 820px) {
  .auth-shell,
  .two-col,
  .wide-left {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar .primary {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .global-search {
    min-width: 0;
  }

  .statement-actions,
  .statement-cover {
    align-items: stretch;
    flex-direction: column;
  }

  .statement-grid,
  .statement-two,
  .statement-chart {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff !important;
  }

  .sidebar,
  .mobile-nav,
  .topbar,
  .statement-actions {
    display: none !important;
  }

  .shell,
  .main,
  .view {
    display: block !important;
    padding: 0 !important;
  }

  .view > :not(.statement) {
    display: none !important;
  }

  .statement {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .statement-table,
  .statement-chart,
  .statement-grid article {
    break-inside: avoid;
  }
}

@media (max-width: 560px) {
  .auth-shell,
  .shell {
    padding: 12px;
  }

  .shell {
    padding-bottom: 92px;
  }

  .auth-card,
  .panel,
  .metric {
    padding: 14px;
  }

  .auth-brand h1 {
    font-size: 2.55rem;
  }

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

  .row {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .row b {
    text-align: left;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-actions,
  .inline-actions select {
    width: 100%;
  }

  canvas {
    height: 260px;
  }
}
