:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-2: #eef6f4;
  --text: #172026;
  --muted: #65717d;
  --line: #dbe3e7;
  --brand: #0f766e;
  --brand-2: #155e75;
  --danger: #b42318;
  --warning: #b45309;
  --ok: #15803d;
  --shadow: 0 18px 48px rgba(31, 41, 55, 0.12);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101418;
  --panel: #171d22;
  --panel-2: #1d2a2c;
  --text: #edf3f6;
  --muted: #9ba8b3;
  --line: #2b3840;
  --brand: #2dd4bf;
  --brand-2: #38bdf8;
  --danger: #fb7185;
  --warning: #fbbf24;
  --ok: #4ade80;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 8%, rgba(45, 212, 191, 0.16), transparent 32%),
    radial-gradient(circle at 88% 14%, rgba(56, 189, 248, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
  animation: slideIn 420ms ease both;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(15, 118, 110, 0.28);
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.brand p,
.small {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.nav button,
.icon-btn,
.ghost,
.primary {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.nav button {
  text-align: left;
  padding: 0 12px;
}

.nav button.active,
.primary {
  border-color: var(--brand);
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.22);
}

.nav button:hover,
.ghost:hover,
.primary:hover {
  transform: translateY(-1px);
  border-color: var(--brand);
}

.sidebar-foot {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 10px;
}

.main {
  min-width: 0;
  padding: 26px;
}

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

.topbar h2,
.auth-card h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
}

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

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

.card {
  grid-column: span 12;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: cardUp 420ms ease both;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  box-shadow: 0 22px 58px rgba(31, 41, 55, 0.16);
}

.card.pad {
  padding: 18px;
}

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.metric {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  right: -26px;
  bottom: -52px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand) 15%, transparent);
}

.metric .value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--brand-2);
  font-size: 13px;
  font-weight: 700;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
  transform: translateY(-1px);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

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

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--brand) 8%, transparent);
}

a {
  color: var(--brand-2);
  font-weight: 700;
}

.type-debt {
  color: var(--warning);
}

.type-collection {
  color: var(--ok);
}

.type-expense {
  color: var(--danger);
}

.chart {
  display: grid;
  gap: 12px;
}

.bar {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 96px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}

.bar-fill {
  height: 100%;
  width: var(--w);
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

.accent-card {
  position: relative;
  overflow: hidden;
}

.accent-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand));
  background-size: 200% 100%;
  animation: shine 3.2s linear infinite;
}

.pulse-line {
  height: 8px;
  margin-top: 20px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-2);
}

.pulse-line::before {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  animation: scan 2.4s ease-in-out infinite;
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.auth-card {
  width: min(460px, 100%);
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.switch-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.alert {
  padding: 11px 12px;
  border-radius: 8px;
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
}

.success {
  padding: 11px 12px;
  border-radius: 8px;
  background: rgba(21, 128, 61, 0.12);
  color: var(--ok);
}

.mobile-tabs {
  display: none;
}

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

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes shine {
  to {
    background-position: 200% 0;
  }
}

@keyframes scan {
  0%, 100% {
    transform: translateX(-8%);
  }
  50% {
    transform: translateX(150%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 18px 14px 86px;
  }

  .span-3,
  .span-4,
  .span-5,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }

  .mobile-tabs {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    grid-auto-flow: column;
    gap: 8px;
    padding: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 10;
  }

  .mobile-tabs button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
  }

  .mobile-tabs button.active {
    background: var(--brand);
    color: #fff;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .auth-card {
    padding: 20px;
  }

  .metric .value {
    font-size: 24px;
  }
}
