:root {
  color-scheme: dark;
  --bg: #101624;
  --panel: #182235;
  --ink: #f8fafc;
  --muted: #bac7d8;
  --line: #334259;
  --brand: #fb2f8c;
  --brand-dark: #ff7ac2;
  --cyan: #22d3ee;
  --lime: #a3e635;
  --warn: #fb923c;
  --danger: #fb7185;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(34, 211, 238, 0.25), transparent 30%),
    radial-gradient(circle at 88% 0%, rgba(251, 47, 140, 0.32), transparent 34%),
    linear-gradient(145deg, #0f172a 0%, #191329 48%, #072331 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: 0;
  color: #ffffff;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(251, 113, 133, 0.45);
  border-radius: 8px;
  background: #2a1724;
  color: var(--danger);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.icon-button svg,
.search-box svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.sync-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(34, 211, 238, 0.34);
  border-radius: 8px;
  background: rgba(7, 48, 66, 0.76);
  box-shadow: var(--shadow);
}

.sync-panel span {
  display: block;
  margin-bottom: 4px;
  color: #a5f3fc;
  font-size: 12px;
  font-weight: 800;
}

.sync-panel strong {
  display: block;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.2;
}

.summary-tile {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(251, 47, 140, 0.44);
  border-radius: 8px;
  background: linear-gradient(135deg, #24142c 0%, #172033 100%);
  box-shadow: var(--shadow);
}

.summary-tile span {
  display: block;
  margin-bottom: 8px;
  color: #f9a8d4;
  font-size: 13px;
  font-weight: 650;
}

.summary-tile strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 23px;
  line-height: 1.05;
  color: #ffffff;
}

.summary-tile.accent {
  border-color: rgba(34, 211, 238, 0.5);
  background: linear-gradient(135deg, #073042 0%, #172033 100%);
}

.summary-tile.accent strong {
  color: #67e8f9;
}

.entry-form,
.toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 34, 53, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.entry-form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #475569;
  border-radius: 8px;
  background: #0f172a;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #475569;
  border-radius: 8px;
  background-color: #0f172a;
  color: var(--ink);
  padding: 11px 36px 11px 12px;
  outline: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #f9a8d4 50%), linear-gradient(135deg, #f9a8d4 50%, transparent 50%);
  background-position: calc(100% - 18px) 20px, calc(100% - 12px) 20px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(251, 47, 140, 0.24);
}

.money-field,
.percent-field,
.listing-field {
  display: grid;
  align-items: center;
  gap: 8px;
}

.money-field,
.percent-field {
  grid-template-columns: 1fr auto;
}

.listing-field {
  grid-template-columns: 1fr auto;
}

.money-field span,
.percent-field span {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.secondary-button {
  min-height: 48px;
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: 8px;
  background: #073042;
  color: #a5f3fc;
  padding: 0 13px;
  font-weight: 800;
}

.secondary-button:disabled {
  opacity: 0.55;
}

.fetch-status {
  display: block;
  min-height: 18px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.fetch-status.ok {
  color: #86efac;
}

.fetch-status.error {
  color: #fb7185;
}

.fetch-status.loading {
  color: #67e8f9;
}

.rate-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, #14351f 0%, #09313d 100%);
  color: #86efac;
}

.rate-preview.engine {
  background: linear-gradient(135deg, #3f2512 0%, #3a2b0b 100%);
  color: var(--warn);
}

.rate-preview.custom {
  background: linear-gradient(135deg, #35204a 0%, #2a1730 100%);
  color: #f0abfc;
}

.rate-preview span {
  font-size: 13px;
  font-weight: 700;
}

.rate-preview strong {
  font-size: 18px;
}

.primary-button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #fb2f8c 0%, #f97316 100%);
  color: white;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(236, 72, 153, 0.28);
}

.toolbar {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 10px;
}

.month-filter span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--brand-dark);
}

.search-box input {
  border: 0;
  background: transparent;
  padding-left: 0;
  min-height: 40px;
  box-shadow: none;
}

.entries {
  margin-top: 14px;
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 28px 14px;
  border: 1px dashed #f472b6;
  border-radius: 8px;
  color: #f9a8d4;
  text-align: center;
  background: rgba(24, 34, 53, 0.56);
}

.empty-state strong {
  color: var(--ink);
}

.entry-list {
  display: grid;
  gap: 10px;
}

.entry-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, #182235 0%, #10283a 100%);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.26);
}

.entry-main {
  min-width: 0;
}

.entry-title {
  margin: 0 0 6px;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 800;
}

.entry-meta,
.entry-money {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.entry-money {
  margin-top: 10px;
  color: var(--ink);
}

.listing-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: #67e8f9;
  font-weight: 800;
  text-decoration: none;
}

.listing-link:active,
.listing-link:hover {
  color: #f9a8d4;
  text-decoration: underline;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #164e63;
  color: #a5f3fc;
  white-space: nowrap;
}

.badge.half {
  background: #7c2d12;
  color: #fed7aa;
}

.delete-entry {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(251, 113, 133, 0.45);
  border-radius: 8px;
  background: #2a1724;
  color: var(--danger);
}

.delete-entry svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 34px;
  }

  .entry-form {
    grid-template-columns: 1.2fr 1fr 0.8fr 0.8fr;
    align-items: end;
  }

  .rate-preview,
  .primary-button {
    grid-column: span 1;
  }
}

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

  h1 {
    font-size: 28px;
  }
}
