:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --bg: #071d20;
  --panel: #102f34;
  --line: rgba(246, 240, 232, 0.14);
  --ink: #f6f0e8;
  --muted: #b7c5c0;
  --teal: #18b9ad;
  --purple: #a78bfa;
  --amber: #e9b45d;
  --coral: #ed7566;
  --green: #7fd66b;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 86% 6%, rgba(233, 180, 93, 0.16), transparent 30%),
    linear-gradient(135deg, #071d20 0%, #102f34 56%, #241f2a 100%);
  color: var(--ink);
}

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

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), #8ad9cb);
  color: #042326;
  cursor: pointer;
  font-weight: 800;
  padding: 0 12px;
}

button:hover,
button:focus-visible {
  background: linear-gradient(135deg, #35c9be, #f0d08d);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(246, 240, 232, 0.17);
  border-radius: 8px;
  outline: 0;
  background: rgba(5, 18, 21, 0.66);
  color: var(--ink);
  padding: 8px 10px;
}

input,
select {
  min-height: 38px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(233, 180, 93, 0.86);
  box-shadow: 0 0 0 4px rgba(233, 180, 93, 0.14);
}

label {
  color: #dbe3df;
  font-size: 0.78rem;
  font-weight: 750;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.55rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.02rem;
  letter-spacing: 0;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 29, 32, 0.84);
  padding: 14px 26px;
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 820;
  text-decoration: none;
}

.brand-lockup img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.section-nav {
  display: flex;
  gap: 8px;
}

.nav-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 9px 12px;
  text-decoration: none;
}

.nav-link.active,
.nav-link:hover,
.nav-link:focus-visible {
  border-color: rgba(233, 180, 93, 0.72);
  color: var(--ink);
}

.accounting-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 22px 40px;
}

.module-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 10px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--amber);
  font-size: 0.68rem;
  font-weight: 820;
  text-transform: uppercase;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin: 8px 0 0;
  border: 1px solid rgba(24, 185, 173, 0.34);
  border-radius: 8px;
  background: rgba(24, 185, 173, 0.1);
  color: #d6f5ef;
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.25;
  padding: 4px 9px;
}

.sync-status::before {
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(24, 185, 173, 0.14);
  content: "";
  flex: 0 0 auto;
}

.sync-status.waiting {
  border-color: rgba(233, 180, 93, 0.36);
  background: rgba(233, 180, 93, 0.1);
  color: #f3dfbd;
}

.sync-status.waiting::before {
  background: var(--amber);
}

.sync-status.error {
  border-color: rgba(237, 117, 102, 0.38);
  background: rgba(237, 117, 102, 0.1);
  color: #ffd3cc;
}

.sync-status.error::before {
  background: var(--coral);
}

.summary-grid,
.workspace-grid {
  display: grid;
  gap: 10px;
}

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

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

.summary-tile,
.panel,
.subscription-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    rgba(9, 31, 35, 0.8);
  box-shadow: var(--shadow);
}

.summary-tile {
  min-width: 0;
  padding: 12px 14px;
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
}

.summary-tile strong {
  display: block;
  margin: 6px 0 4px;
  color: var(--ink);
  font-size: clamp(1.1rem, 1.9vw, 1.62rem);
  line-height: 1;
}

.summary-tile p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.action-tile {
  align-content: center;
  display: grid;
  gap: 5px;
}

.summary-action {
  width: fit-content;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: clamp(1.1rem, 1.9vw, 1.62rem);
  font-weight: 880;
  line-height: 1;
  padding: 0;
  text-align: left;
}

.summary-action:hover,
.summary-action:focus-visible {
  background: transparent;
  color: #f0d08d;
  text-decoration: underline;
  text-underline-offset: 4px;
}

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

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
}

.panel-actions .secondary-button {
  white-space: nowrap;
}

.subscription-list {
  display: grid;
  gap: 3px;
}

.empty-state {
  border: 1px dashed rgba(246, 240, 232, 0.2);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
}

.subscription-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.35fr) minmax(150px, 0.6fr) minmax(116px, 0.46fr) 48px 50px minmax(148px, auto);
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 8px;
  font-size: 0.82rem;
}

.subscription-header {
  min-height: 20px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0;
  padding: 0 8px 2px;
  justify-items: start;
  text-transform: uppercase;
}

.subscription-title {
  display: grid;
  gap: 0;
  min-width: 0;
}

.subscription-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  line-height: 1.12;
}

.subscription-title small,
.subscription-meta,
.subscription-cost,
.subscription-due {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.08;
}

.subscription-due,
.subscription-cost {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.subscription-due strong,
.subscription-cost strong {
  display: inline;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.1;
  white-space: nowrap;
}

.subscription-due span:not(.badge),
.subscription-cost span:not(.badge) {
  white-space: nowrap;
}

.badge-row,
.card-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.subscription-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
}

.subscription-dialog::backdrop {
  background: rgba(3, 13, 15, 0.78);
  backdrop-filter: blur(8px);
}

.subscription-dialog .form-panel {
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px;
}

.dialog-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.dialog-heading h2 {
  margin-bottom: 0;
}

.dialog-close {
  min-height: 28px;
  border: 1px solid rgba(246, 240, 232, 0.14);
  background: rgba(246, 240, 232, 0.06);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 0 10px;
}

.dialog-close:hover,
.dialog-close:focus-visible {
  border-color: rgba(233, 180, 93, 0.62);
  background: rgba(233, 180, 93, 0.12);
  color: var(--ink);
}

.badge {
  width: fit-content;
  border: 1px solid rgba(246, 240, 232, 0.14);
  border-radius: 999px;
  background: rgba(246, 240, 232, 0.07);
  color: #dbe3df;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  padding: 3px 6px;
}

.badge.good {
  border-color: rgba(127, 214, 107, 0.34);
  background: rgba(127, 214, 107, 0.12);
}

.badge.warn {
  border-color: rgba(233, 180, 93, 0.42);
  background: rgba(233, 180, 93, 0.13);
}

.badge.danger {
  border-color: rgba(237, 117, 102, 0.42);
  background: rgba(237, 117, 102, 0.13);
}

.card-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.card-actions button,
.secondary-button {
  min-height: 26px;
  border: 1px solid rgba(246, 240, 232, 0.14);
  background: rgba(246, 240, 232, 0.06);
  color: var(--muted);
  font-size: 0.7rem;
  padding: 0 7px;
}

.card-actions button:hover,
.card-actions button:focus-visible,
.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: rgba(233, 180, 93, 0.62);
  background: rgba(233, 180, 93, 0.12);
  color: var(--ink);
}

.stack-form {
  display: grid;
  gap: 8px;
}

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

.inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  align-items: end;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  min-height: 38px;
  gap: 10px;
  border: 1px solid rgba(246, 240, 232, 0.17);
  border-radius: 8px;
  background: rgba(5, 18, 21, 0.44);
  padding: 0 12px;
}

.toggle-row input {
  width: auto;
  min-height: 0;
}

@media (max-width: 1080px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .app-topbar,
  .module-intro,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .app-topbar {
    gap: 12px;
    padding: 14px 18px;
  }

  .section-nav {
    width: 100%;
  }

  .nav-link {
    flex: 1;
    text-align: center;
  }

  .accounting-shell {
    padding: 22px 18px 36px;
  }

  .summary-grid,
  .money-row,
  .inline-fields {
    grid-template-columns: 1fr;
  }

  .subscription-row {
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 10px;
  }

  .subscription-header {
    display: none;
  }

  .card-actions {
    justify-content: stretch;
  }

  .card-actions button {
    flex: 1;
  }

  .panel-actions {
    justify-content: stretch;
  }

  .panel-actions .secondary-button {
    width: 100%;
  }
}
