:root {
  color-scheme: dark;
  --bg: #080c11;
  --bg-soft: #0b1118;
  --card: #101821;
  --card-2: #131d28;
  --card-3: #172331;
  --border: #223142;
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #e8eff7;
  --muted: #8fa3b8;
  --muted-2: #6f8398;
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.12);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.12);
  --orange: #fb923c;
  --orange-soft: rgba(251, 146, 60, 0.12);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --yellow: #facc15;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --radius-sm: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

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

.small {
  font-size: 0.82rem;
  line-height: 1.5;
}

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

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.app-body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(74, 222, 128, 0.07), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(96, 165, 250, 0.06), transparent 55%),
    var(--bg);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  background: rgba(8, 12, 17, 0.78);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.05rem;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--green), #22c55e);
  color: #052e16;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 8px 24px rgba(74, 222, 128, 0.22);
}

.brand-mark.large {
  width: 3rem;
  height: 3rem;
  border-radius: 14px;
  font-size: 1.6rem;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: 160ms ease;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--card-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sync-status {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-soft);
}

.sync-status.syncing {
  color: var(--blue);
  border-color: rgba(96, 165, 250, 0.3);
  background: var(--blue-soft);
}

.sync-status.error {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.3);
  background: var(--red-soft);
}

.main {
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
}

.tab-panel {
  display: none;
  animation: fade-in 220ms ease;
}

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

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid-chart {
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
}

.card {
  position: relative;
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.card-hero {
  background:
    radial-gradient(500px 240px at 10% 0%, rgba(74, 222, 128, 0.14), transparent 65%),
    linear-gradient(180deg, #121e25, #0f171f);
  border-color: rgba(74, 222, 128, 0.18);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-head h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.card-head p {
  margin: 0.25rem 0 0;
}

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

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.55rem;
}

.big-money {
  font-size: clamp(1.8rem, 2.4vw, 2.55rem);
  font-weight: 750;
  letter-spacing: -0.045em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin: 0.15rem 0 0.35rem;
}

.medium-money {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.subline {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
}

.mini-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-2);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.mini-value {
  font-size: 0.95rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-green {
  color: var(--green);
  background: var(--green-soft);
  border-color: rgba(74, 222, 128, 0.22);
}

.badge-blue {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: rgba(96, 165, 250, 0.22);
}

.badge-orange {
  color: var(--orange);
  background: var(--orange-soft);
  border-color: rgba(251, 146, 60, 0.22);
}

.badge-red {
  color: var(--red);
  background: var(--red-soft);
  border-color: rgba(248, 113, 113, 0.22);
}

.badge-muted {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-soft);
}

.badge-purple {
  color: var(--purple);
  background: var(--purple-soft);
  border-color: rgba(167, 139, 250, 0.22);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--card-3);
  color: var(--text);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 650;
  text-decoration: none;
  transition: 150ms ease;
  white-space: nowrap;
}

.btn:hover {
  border-color: #33475f;
  background: #1b2939;
}

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

.btn-primary {
  background: linear-gradient(145deg, #53e88d, #2ecb6c);
  border-color: transparent;
  color: #052e16;
  box-shadow: 0 10px 30px rgba(74, 222, 128, 0.18);
}

.btn-primary:hover {
  background: linear-gradient(145deg, #6cf3a0, #3ad97a);
  border-color: transparent;
}

.btn-ghost {
  background: transparent;
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
}

.filters {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.inline-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.select,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
select {
  background: #0c141d;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 9px;
  padding: 0.48rem 0.6rem;
  outline: none;
  min-width: 0;
  transition: 150ms ease;
}

.select:focus,
input:focus,
select:focus {
  border-color: rgba(96, 165, 250, 0.65);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
}

.select {
  padding-right: 1.6rem;
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 3px;
  display: inline-block;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.breakdown-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.breakdown-chart {
  position: relative;
  width: 150px;
  height: 150px;
  flex: 0 0 auto;
}

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.4rem;
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.42rem 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.84rem;
}

.breakdown-row:last-child {
  border-bottom: 0;
}

.breakdown-row .name {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.breakdown-row .value {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.breakdown-row.total {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  margin-top: 0.3rem;
  padding-top: 0.6rem;
  font-weight: 700;
}

.breakdown-row.total .name {
  color: var(--text);
}

.segmented {
  display: inline-flex;
  padding: 0.18rem;
  gap: 0.15rem;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 9px;
  flex-wrap: wrap;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  padding: 0.3rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 650;
}

.segmented button.active {
  background: var(--card-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin: 0.8rem 0 0.5rem;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--red));
}

.progress.green > span {
  background: linear-gradient(90deg, var(--green), #22c55e);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.82rem;
}

.list-row .left {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.list-row .date {
  color: var(--muted);
  font-size: 0.75rem;
}

.empty {
  padding: 1.4rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -0.2rem;
}

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

th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-2);
  font-weight: 700;
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.72rem 0.7rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.86rem;
  vertical-align: middle;
}

th.num,
td.num {
  text-align: right;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover td {
  background: rgba(255, 255, 255, 0.025);
}

tr.total-row td {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  font-weight: 700;
  padding-top: 0.85rem;
}

.table-sub {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.status-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.35rem;
}

.dot-green {
  background: var(--green);
}

.dot-orange {
  background: var(--orange);
}

.dot-blue {
  background: var(--blue);
}

.dot-muted {
  background: var(--muted-2);
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field > label {
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--muted);
}

.field .hint {
  font-size: 0.7rem;
  color: var(--muted-2);
  line-height: 1.4;
}

.field input,
.field select {
  width: 100%;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
  padding-top: 1.45rem;
}

.checkbox-field input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--green);
}

.settings-section {
  margin-bottom: 1rem;
}

.settings-section .card-head {
  margin-bottom: 0.9rem;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
  padding: 0.8rem 0;
}

.dynamic-rows {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.dynamic-row {
  display: grid;
  gap: 0.55rem;
  align-items: end;
  padding: 0.65rem;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.018);
}

.dynamic-row.rate-row {
  grid-template-columns: 1fr 1fr auto;
}

.dynamic-row.deduction-row {
  grid-template-columns: 1.4fr 0.8fr 0.8fr auto auto auto;
}

.dynamic-row.earning-row {
  grid-template-columns: 1.5fr 0.8fr 0.8fr auto;
}

.dynamic-row .field > label {
  font-size: 0.68rem;
}

.remove-row {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.remove-row:hover {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.4);
}

.form-error {
  color: var(--red);
  font-size: 0.8rem;
  margin: 0.2rem 0 0;
}

.form-success {
  color: var(--green);
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 60;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #101a24;
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  max-width: min(420px, calc(100vw - 2.4rem));
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.4);
  color: #fecaca;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 11, 0.72);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: linear-gradient(180deg, #131e29, #0f1720);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
  animation: modal-in 180ms ease;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  z-index: 2;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Login */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(800px 500px at 10% 10%, rgba(74, 222, 128, 0.1), transparent 60%),
    radial-gradient(900px 600px at 90% 90%, rgba(96, 165, 250, 0.1), transparent 55%),
    var(--bg);
}

.orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.5;
}

.orb-one {
  width: 360px;
  height: 360px;
  top: -120px;
  left: -100px;
  background: rgba(74, 222, 128, 0.2);
}

.orb-two {
  width: 420px;
  height: 420px;
  right: -140px;
  bottom: -160px;
  background: rgba(96, 165, 250, 0.18);
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100% - 2rem));
}

.login-card {
  background: linear-gradient(180deg, rgba(19, 30, 41, 0.96), rgba(13, 20, 28, 0.98));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 1.5rem;
}

.login-card h1 {
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  margin-bottom: 0.4rem;
}

.login-card > p {
  margin-bottom: 1.3rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.login-form label {
  font-size: 0.75rem;
  font-weight: 650;
  color: var(--muted);
}

.login-form input {
  width: 100%;
  padding: 0.75rem 0.8rem;
  font-size: 1rem;
  background: #0a121a;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
}

.login-form .btn {
  margin-top: 0.45rem;
  padding: 0.7rem 0.8rem;
  font-size: 0.9rem;
}

.login-note {
  margin: 1.1rem 0 0;
  font-size: 0.72rem;
  color: var(--muted-2);
  line-height: 1.5;
  text-align: center;
}

/* Responsive */
@media (max-width: 1180px) {
  .hero-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    gap: 0.7rem;
  }

  .tabs {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .topbar-actions {
    margin-left: auto;
  }

  .sync-status {
    display: none;
  }

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

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

  .dynamic-row.deduction-row {
    grid-template-columns: 1fr 1fr;
  }

  .dynamic-row.deduction-row .remove-row {
    justify-self: end;
  }
}

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

  .main {
    padding: 0.8rem;
  }

  .card {
    padding: 1rem;
    border-radius: 16px;
  }

  .topbar {
    padding: 0.7rem 0.8rem;
  }

  .topbar-actions .btn {
    padding: 0.42rem 0.55rem;
    font-size: 0.75rem;
  }

  .brand {
    font-size: 0.98rem;
  }

  .big-money {
    font-size: 2rem;
  }

  .breakdown-top {
    flex-direction: column;
  }

  .breakdown-chart {
    width: 130px;
    height: 130px;
  }

  .chart-wrap {
    height: 260px;
  }

  .dynamic-row.rate-row,
  .dynamic-row.deduction-row {
    grid-template-columns: 1fr;
  }
}
