:root {
  --bg: #0b0f14;
  --surface: #121922;
  --surface-2: #182130;
  --border: #243041;
  --text: #e9eff5;
  --muted: #95a5b8;
  --accent: #35c48d;
  --accent-ink: #052a1d;
  --red: #f2707a;
  --red-bg: rgba(242, 112, 122, 0.14);
  --amber: #f2b04a;
  --amber-bg: rgba(242, 176, 74, 0.14);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(1100px 480px at 85% -120px, rgba(91, 141, 239, 0.13), transparent 60%),
    radial-gradient(900px 420px at -10% -80px, rgba(53, 196, 141, 0.1), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
  min-width: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---------------- header ---------------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(18, 25, 34, 0.92);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  width: 40px;
  height: 40px;
  flex: none;
  color: var(--accent);
}

.brand-text {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.2px;
}

.tagline {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------------- buttons and inputs ---------------- */

.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.4;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-accent:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  background: transparent;
  border-color: var(--red);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red-bg);
  border-color: var(--red);
}

.file-label {
  cursor: pointer;
}

input[type="search"],
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}

textarea {
  resize: vertical;
}

/* ---------------- layout ---------------- */

main.wrap {
  padding-top: 20px;
  padding-bottom: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.22);
}

.card-title {
  margin: 0 0 6px;
  font-size: 1.08rem;
}

.card-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.muted-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0 10px;
}

/* ---------------- hero ---------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(min(420px, 100%), 1.5fr) minmax(min(300px, 100%), 1fr);
  gap: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(53, 196, 141, 0.35);
  background: linear-gradient(120deg, #0d2b23 0%, #10303f 52%, #17263f 100%);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  min-width: 0;
}

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

.hero-spot {
  padding: 24px 26px;
  border-left: 1px solid rgba(233, 239, 245, 0.14);
  background: rgba(11, 15, 20, 0.28);
  min-width: 0;
}

.hero h2 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(233, 239, 245, 0.72);
  font-weight: 600;
}

.hero-values {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-amount {
  font-size: 2.9rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #7df0c0, #4ac8f2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-cur {
  color: rgba(233, 239, 245, 0.75);
  font-size: 0.95rem;
  font-weight: 600;
}

.hero-note {
  margin: 10px 0 0;
  color: rgba(233, 239, 245, 0.65);
  font-size: 0.9rem;
}

.spot-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.spot-main {
  flex: 1 1 auto;
  min-width: 0;
}

.spot-name {
  font-weight: 700;
  font-size: 1.12rem;
  overflow-wrap: anywhere;
}

.spot-meta {
  color: rgba(233, 239, 245, 0.7);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.spot-side {
  flex: none;
  text-align: right;
}

.spot-amount {
  font-weight: 800;
  font-size: 1.3rem;
  white-space: nowrap;
}

.spot-none {
  color: rgba(233, 239, 245, 0.75);
  margin: 4px 0 0;
}

/* ---------------- stat cards ---------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.stat h2 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.stat-values {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 2.2rem;
}

.stat-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-amount {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.15;
}

.stat-cur {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.stat-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

section.card {
  margin-bottom: 14px;
}

.grid-2 section.card {
  margin-bottom: 0;
}

/* ---------------- monograms and category dots ---------------- */

.monogram {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: #0b0f14;
  font-weight: 800;
  font-size: 1.02rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.monogram-lg {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  font-size: 1.22rem;
}

.monogram-sm {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 0.82rem;
}

.cat-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  margin-right: 7px;
  flex: none;
  vertical-align: baseline;
}

/* ---------------- timeline ---------------- */

.timeline {
  margin-top: 8px;
  min-width: 0;
}

.timeline-track {
  position: relative;
  height: 96px;
  border-bottom: 2px solid var(--border);
  margin: 0 6px;
}

.tl-marker {
  position: absolute;
  bottom: -2px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 76px;
  text-align: center;
}

.tl-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
  order: 3;
}

.tl-amount {
  order: 1;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-date {
  order: 2;
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}

.tl-alt .tl-amount {
  transform: translateY(-4px);
}

.tl-axis {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 6px;
}

/* ---------------- banner and empty state ---------------- */

.banner {
  border: 1px solid var(--amber);
  background: var(--amber-bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.banner.success {
  border-color: var(--accent);
  background: rgba(53, 196, 141, 0.12);
}

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 34px 22px;
  text-align: center;
}

.empty h2 {
  margin: 0 0 8px;
}

.empty p {
  color: var(--muted);
  max-width: 560px;
  margin: 0 auto 18px;
}

.empty-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.quick-title {
  margin: 18px 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
}

.empty .quick-title {
  text-align: center;
}

.quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty .quick-row {
  justify-content: center;
}

.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 13px 5px 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.quick-chip:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ---------------- renewing soon ---------------- */

.soon-list,
.items-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.soon-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.soon-row:last-child {
  border-bottom: none;
}

.soon-main {
  flex: 1 1 auto;
  min-width: 0;
}

.soon-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.soon-meta {
  color: var(--muted);
  font-size: 0.87rem;
  overflow-wrap: anywhere;
}

.soon-amount {
  font-weight: 700;
  white-space: nowrap;
}

.badge {
  flex: none;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.badge-overdue {
  color: var(--red);
  background: var(--red-bg);
  border-color: var(--red);
}

.badge-soon {
  color: var(--amber);
  background: var(--amber-bg);
  border-color: var(--amber);
}

/* ---------------- breakdown bars ---------------- */

.bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

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

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.92rem;
  margin-bottom: 5px;
}

.bar-label {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.bar-head .bar-amount {
  color: var(--muted);
  white-space: nowrap;
}

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

.bar-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 999px;
  min-width: 2px;
  transition: width 0.5s ease;
}

.select-label,
.search-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.search-label {
  flex: 1 1 180px;
  min-width: 0;
}

.search-label input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

.select-label {
  min-width: 0;
}

/* ---------------- upcoming charges ---------------- */

.upcoming-group {
  margin-top: 10px;
}

.upcoming-group h3 {
  margin: 12px 0 4px;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.charge-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.charge-row:last-child {
  border-bottom: none;
}

.charge-date {
  flex: none;
  width: 86px;
  color: var(--muted);
  font-size: 0.9rem;
}

.charge-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.charge-amount {
  font-weight: 600;
  white-space: nowrap;
}

/* ---------------- statement import ---------------- */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  min-width: 0;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
}

.dropzone.dragging {
  border-color: var(--accent);
  background: rgba(53, 196, 141, 0.1);
}

.dropzone-title {
  margin: 0 0 4px;
  font-weight: 700;
}

.dropzone-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---------------- items list ---------------- */

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 6px;
}

.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.chip .cat-dot {
  margin-right: 6px;
}

.chip.active .cat-dot {
  background: var(--accent-ink) !important;
}

.item-row {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.item-row:last-child {
  border-bottom: none;
}

.item-row.is-paused {
  opacity: 0.55;
}

.item-main {
  flex: 1 1 auto;
  min-width: 0;
}

.item-top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.item-name {
  font-weight: 700;
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

.item-cat {
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
  font-weight: 600;
}

.item-paused-tag {
  font-size: 0.78rem;
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.price-tag {
  font-size: 0.78rem;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.item-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.item-notes {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.history-box {
  margin-top: 8px;
  border-left: 3px solid var(--border);
  padding-left: 12px;
  min-width: 0;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-amount {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.item-side {
  flex: none;
  text-align: right;
}

.item-amount {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}

.item-cycle {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.item-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* ---------------- data bar and footer ---------------- */

.data-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
}

.data-bar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1 1 260px;
  min-width: 0;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.site-footer p {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 14px 0 20px;
  margin: 0;
}

/* ---------------- modals ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 10, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 24px 12px;
  z-index: 50;
}

.overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 620px;
  min-width: 0;
  box-shadow: var(--shadow);
  animation: modal-in 0.18s ease;
}

.modal-small {
  max-width: 440px;
}

.modal-wide {
  max-width: 760px;
}

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

.modal h2 {
  margin: 0 0 14px;
}

.typical-hint {
  margin: -6px 0 12px;
  color: var(--amber);
  font-size: 0.9rem;
}

.renew-name {
  margin: 0 0 12px;
  font-weight: 600;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.9rem;
  color: var(--muted);
  min-width: 0;
}

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

.form-errors {
  margin-top: 14px;
  border: 1px solid var(--red);
  background: var(--red-bg);
  border-radius: 10px;
  padding: 10px 14px;
  white-space: pre-line;
  font-size: 0.92rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ---------------- statement review ---------------- */

.proposals {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.proposal {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  flex-wrap: wrap;
  min-width: 0;
  background: var(--surface-2);
}

.proposal-check {
  padding-top: 8px;
}

.proposal-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.proposal-fields {
  flex: 1 1 180px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.proposal-fields .p-name {
  font-weight: 600;
  width: 100%;
}

.proposal-meta {
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.tracked-tag {
  align-self: flex-start;
  font-size: 0.76rem;
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: 999px;
  padding: 1px 8px;
}

.proposal .p-amount {
  flex: 0 1 110px;
  min-width: 0;
}

.proposal .p-cycle {
  flex: 0 1 130px;
  min-width: 0;
}

.proposal .p-date {
  flex: 0 1 150px;
  min-width: 0;
}

/* ---------------- small screens ---------------- */

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

  .hero-spot {
    border-left: none;
    border-top: 1px solid rgba(233, 239, 245, 0.14);
  }
}

@media (max-width: 560px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: flex-start;
  }

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

  .hero-main,
  .hero-spot {
    padding: 18px;
  }

  .hero-amount {
    font-size: 2.2rem;
  }

  .item-row {
    flex-wrap: wrap;
  }

  .item-side {
    text-align: left;
    flex: 1 1 100%;
  }

  .item-actions {
    justify-content: flex-start;
  }

  .charge-date {
    width: 74px;
  }

  .card {
    padding: 14px;
  }

  .stat-amount {
    font-size: 1.4rem;
  }

  .tl-amount {
    font-size: 0.7rem;
  }
}

/* ---------------- reduced motion ---------------- */

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