:root {
  --bg: #edf7ff;
  --bg-deep: #031432;
  --bg-mid: #072a5d;
  --ink: #0c2344;
  --muted: #5f7898;
  --line: #d5e8fa;
  --panel: #ffffff;
  --soft: #f7fbff;
  --blue: #1f8cff;
  --blue-light: #dff1ff;
  --cyan: #62f0d1;
  --aqua: #36c7ff;
  --danger: #c33c54;
  --shadow: 0 18px 48px rgba(3, 20, 50, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, rgba(54, 199, 255, 0.26), transparent 33rem),
    radial-gradient(circle at top right, rgba(98, 240, 209, 0.2), transparent 28rem),
    linear-gradient(180deg, #f7fcff 0, var(--bg) 38rem, #f8fbff 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.app-header {
  position: relative;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background:
    radial-gradient(circle at 28% 42%, rgba(54, 199, 255, 0.22), transparent 16rem),
    radial-gradient(circle at 72% 35%, rgba(98, 240, 209, 0.16), transparent 18rem),
    linear-gradient(135deg, #020b1c, var(--bg-deep) 54%, var(--bg-mid));
  box-shadow: var(--shadow);
  isolation: isolate;
  overflow: hidden;
}

.app-header::after {
  content: "";
  position: absolute;
  inset: -38px auto auto 46%;
  width: 150px;
  height: 150px;
  background: url("wavecalc-brand.png") center / cover no-repeat;
  opacity: 0.035;
  pointer-events: none;
  z-index: 0;
}

.app-header > * {
  position: relative;
  z-index: 1;
}

.app-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: #fff;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(98, 240, 209, 0.28);
  border-radius: 8px;
  background: #031432;
  box-shadow:
    0 0 0 1px rgba(31, 140, 255, 0.18),
    0 16px 34px rgba(0, 0, 0, 0.22);
  object-fit: cover;
}

.app-brand small,
.app-brand strong {
  display: block;
}

.app-brand small {
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-brand strong {
  color: #fff;
  font-size: 1.65rem;
  line-height: 1;
}

.app-nav {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-nav a {
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.86rem;
  font-weight: 850;
  text-decoration: none;
}

.app-nav a:hover,
.app-nav a.is-active {
  border-color: rgba(98, 240, 209, 0.52);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.page-hero {
  display: flex;
  gap: 20px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.page-hero .eyebrow {
  color: var(--blue);
}

.page-hero h1 {
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 3.4rem);
  text-shadow: none;
}

.page-hero p {
  max-width: 560px;
  color: var(--muted);
  font-weight: 750;
}

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

.page[hidden] {
  display: none;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  color: #fff;
  font-size: clamp(2.35rem, 5.6vw, 4.4rem);
  line-height: 0.95;
  text-shadow: 0 0 28px rgba(54, 199, 255, 0.24);
}

h2 {
  color: var(--ink);
  font-size: 1.02rem;
}

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

.categorized-settings {
  align-items: stretch;
}

.setup-group {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 251, 255, 0.96));
}

.setup-group legend {
  padding: 0 7px;
  color: var(--bg-deep);
  font-size: 0.88rem;
  font-weight: 900;
}

.group-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

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

.account-routing-group {
  grid-column: span 1;
}

.currency-group {
  max-width: 220px;
}

label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.action-row {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.save-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.setup-panel {
  margin-bottom: 12px;
}

.profile-page-panel {
  max-width: 760px;
}

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

.profile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.danger-button {
  border-color: #f0c7d0;
  background: #fff7f9;
  color: var(--danger);
}

.danger-button:hover {
  border-color: #e99aac;
  background: #ffeef2;
}

.accounts-layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.setup-panel .money-input {
  border-color: var(--line);
}

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

input {
  padding: 0 12px;
}

select {
  padding: 0 28px 0 10px;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 140, 255, 0.16);
}

.money-input {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  height: 46px;
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.money-input span {
  padding-left: 12px;
  color: var(--blue);
  font-weight: 900;
}

.money-input input {
  height: 44px;
  border: 0;
  border-radius: 0;
  padding-left: 6px;
}

.money-input.compact {
  width: 128px;
  margin: 0;
  border-color: var(--line);
}

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

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

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

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--blue), var(--aqua), var(--cyan));
}

.metric span,
.metric small,
.panel p {
  color: var(--muted);
}

.metric span {
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  margin: 12px 0 4px;
  color: var(--ink);
  font-size: clamp(1.55rem, 3vw, 2.42rem);
  line-height: 1;
}

.metric.primary {
  color: #fff;
  background:
    radial-gradient(circle at 80% 20%, rgba(98, 240, 209, 0.22), transparent 9rem),
    linear-gradient(135deg, #0c5ed8, #04265b);
  border-color: rgba(255, 255, 255, 0.18);
}

.metric.primary::before {
  background: rgba(255, 255, 255, 0.38);
}

.metric.primary span,
.metric.primary small,
.metric.primary strong {
  color: #fff;
}

.metric.warning.is-short {
  border-color: rgba(195, 60, 84, 0.36);
  background: #fff7f9;
}

.metric.warning.is-short::before {
  background: var(--danger);
}

.metric.warning.is-short strong {
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.subscriptions {
  background:
    radial-gradient(circle at 96% 8%, rgba(98, 240, 209, 0.16), transparent 13rem),
    rgba(255, 255, 255, 0.92);
}

.credit-cards {
  background:
    radial-gradient(circle at 96% 8%, rgba(31, 140, 255, 0.14), transparent 13rem),
    rgba(255, 255, 255, 0.92);
}

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

.panel-head {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 14px;
}

.panel-head p {
  margin-top: 4px;
  font-size: 0.86rem;
}

.button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.button {
  min-width: 104px;
  height: 38px;
  padding: 0 12px;
  background: linear-gradient(135deg, var(--blue), #0e61d8);
  border-color: #1477ef;
  color: #fff;
}

.button:hover {
  background: linear-gradient(135deg, #36a2ff, #146eea);
  border-color: #36a2ff;
}

.button.secondary {
  background: #ffffff;
  border-color: rgba(255, 255, 255, 0.62);
  color: var(--bg-deep);
}

.button.secondary:hover {
  background: var(--blue-light);
  border-color: var(--blue-light);
}

.panel .button.secondary {
  border-color: var(--line);
}

.button.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.36);
  color: #fff;
}

.button.ghost:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.5);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  min-width: 0;
  background: #fff;
}

.subscriptions-table {
  table-layout: fixed;
}

.subscriptions-table th:nth-child(1),
.subscriptions-table td:nth-child(1) {
  width: 27%;
}

.subscriptions-table th:nth-child(2),
.subscriptions-table td:nth-child(2) {
  width: 15%;
}

.subscriptions-table th:nth-child(3),
.subscriptions-table td:nth-child(3) {
  width: 16%;
}

.subscriptions-table th:nth-child(4),
.subscriptions-table td:nth-child(4) {
  width: 13%;
}

.subscriptions-table th:nth-child(5),
.subscriptions-table td:nth-child(5),
.subscriptions-table th:nth-child(6),
.subscriptions-table td:nth-child(6) {
  width: 12%;
  font-weight: 850;
}

.subscriptions-table th:nth-child(7),
.subscriptions-table td:nth-child(7) {
  width: 5%;
}

.credit-table th:nth-child(1),
.credit-table td:nth-child(1) {
  width: 16%;
}

.credit-table th:nth-child(2),
.credit-table td:nth-child(2),
.credit-table th:nth-child(3),
.credit-table td:nth-child(3) {
  width: 12%;
}

.credit-table th:nth-child(4),
.credit-table td:nth-child(4) {
  width: 9%;
}

.credit-table th:nth-child(5),
.credit-table td:nth-child(5) {
  width: 15%;
}

.credit-table th:nth-child(6),
.credit-table td:nth-child(6) {
  width: 14%;
}

.credit-table th:nth-child(7),
.credit-table td:nth-child(7),
.credit-table th:nth-child(8),
.credit-table td:nth-child(8) {
  width: 9%;
  font-weight: 850;
}

.credit-table th:nth-child(9),
.credit-table td:nth-child(9) {
  width: 4%;
}

.stacked-money {
  display: grid;
  gap: 6px;
}

.stacked-money .money-input {
  width: 100%;
}

.credit-utilisation.is-high,
#creditUtilisationTotal.is-high {
  color: var(--danger);
}

th,
td {
  height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 7px;
  text-align: left;
  vertical-align: middle;
}

thead th {
  background: var(--soft);
  color: #4f6d91;
  font-size: 0.72rem;
  text-transform: uppercase;
}

thead th small {
  display: block;
  margin-top: 2px;
  color: #7d93af;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: none;
}

tbody tr:hover td {
  background: #fbfdff;
}

tbody td:nth-child(4),
tfoot td:nth-child(4),
tfoot td:nth-child(3) {
  font-weight: 850;
}

tfoot th,
tfoot td {
  border-bottom: 0;
  background: #f5faff;
  font-size: 1rem;
}

tfoot .automated-row th,
tfoot .automated-row td {
  border-bottom: 1px solid var(--line);
  background: #f6fbff;
}

.automated-row th {
  border-left: 4px solid var(--blue);
  color: var(--bg-deep);
}

.automated-row td:nth-child(2),
.automated-row td:nth-child(4),
.automated-row td:nth-child(5),
.automated-row td:nth-child(7) {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.row-name {
  min-width: 0;
}

.row-type,
.row-frequency,
.row-account {
  min-width: 0;
}

.row-due-day {
  width: 100%;
}

.plan-table td:nth-child(1),
.plan-table th:nth-child(1) {
  width: 21%;
}

.plan-table td:nth-child(2),
.plan-table th:nth-child(2) {
  width: 12%;
}

.plan-table td:nth-child(3),
.plan-table th:nth-child(3) {
  width: 12%;
}

.plan-table td:nth-child(4),
.plan-table th:nth-child(4) {
  width: 13%;
}

.plan-table td:nth-child(5),
.plan-table th:nth-child(5) {
  width: 10%;
}

.plan-table td:nth-child(6),
.plan-table th:nth-child(6) {
  width: 12%;
}

.plan-table td:nth-child(7),
.plan-table th:nth-child(7) {
  width: 15%;
}

.plan-table td:nth-child(8),
.plan-table th:nth-child(8) {
  width: 5%;
}

td input,
td select {
  min-width: 0;
}

.due-hint {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.icon-button {
  width: 34px;
  height: 34px;
  font-size: 1.2rem;
  line-height: 1;
}

.bucket-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.account-editor {
  display: grid;
  gap: 8px;
}

.account-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
}

.account-row input {
  height: 40px;
}

.account-row input[readonly] {
  border-color: rgba(98, 240, 209, 0.5);
  background: #f4fffc;
  color: var(--bg-deep);
}

.account-row button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.bucket {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, #fff, #f7fbff);
}

.bucket-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.bucket h3 {
  margin: 0;
  color: #173f73;
  font-size: 0.94rem;
}

.bucket strong {
  color: var(--blue);
  font-size: 1.35rem;
}

.bucket dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.bucket dd {
  margin: 0;
  color: var(--ink);
  font-weight: 750;
}

.paydays {
  margin-top: 12px;
}

.segmented {
  display: flex;
  gap: 4px;
  height: 38px;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segmented label {
  position: relative;
  color: var(--ink);
}

.segmented input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
}

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

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

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

.payday-card time {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.payday-card strong {
  display: block;
  margin-top: 6px;
  color: var(--blue);
  font-size: 1.5rem;
}

.paycheck-line {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.paycheck-line b {
  color: var(--ink);
}

.payday-card ul {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.payday-card li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid #e9f2fd;
}

.payday-card b {
  color: var(--ink);
}

.payday-card em {
  color: #7f93ad;
  font-size: 0.74rem;
  font-style: normal;
}

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

  .app-header,
  .page-hero {
    align-items: stretch;
    flex-direction: column;
  }

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

  .currency-group {
    max-width: none;
  }

  .summary-grid,
  .payday-list,
  .accounts-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1200px);
    padding-top: 10px;
  }

  .app-header,
  .page-hero {
    padding: 14px;
  }

  .app-nav {
    justify-content: stretch;
  }

  .app-nav a {
    flex: 1 1 44%;
  }

  .settings,
  .summary-grid,
  .payday-list,
  .accounts-layout,
  .profile-grid {
    grid-template-columns: 1fr;
  }

  .group-fields.two-up {
    grid-template-columns: 1fr;
  }

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

  .brand-mark {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
  }

  .panel-head {
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .segmented label {
    flex: 1;
  }
}
