:root {
  color-scheme: light;
  --bg: #f7f2ea;
  --surface: #ffffff;
  --surface-alt: #fff7ef;
  --ink: #1c1b1b;
  --muted: #5c5852;
  --border: #e4d9ce;
  --accent: #0c6b63;
  --accent-strong: #05524b;
  --accent-soft: rgba(12, 107, 99, 0.12);
  --warning: #b45309;
  --success: #166534;
  --danger: #9f1239;
  --shadow: 0 18px 40px rgba(20, 20, 20, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #fce9d7 0%, transparent 55%),
    radial-gradient(circle at 15% 70%, #d9f3ea 0%, transparent 45%),
    var(--bg);
  min-height: 100vh;
}

h1,
h2,
strong {
  font-family: "Sora", sans-serif;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 30px;
}

.app-footer {
  max-width: 1200px;
  margin: 0 auto 36px;
  padding: 0 24px;
}

.footer-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  padding: 16px 18px;
}

.footer-badge {
  display: flex;
  justify-content: center;
  width: 100%;
}

.footer-badge img {
  width: min(250px, 100%);
  height: auto;
}

.footer-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.footer-note {
  margin: 0;
  color: var(--muted);
}

.pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.footer-credit {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  text-align: center;
  padding-bottom: 20px;
}

.footer-credit a {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
}

.footer-credit a:hover {
  text-decoration: underline;
}

.heart {
  color: var(--danger);
  font-size: 1.1rem;
}

.install-prompt {
  position: fixed;
  inset: auto 0 16px 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding: 0 16px;
  z-index: 30;
}

.install-prompt[hidden] {
  display: none !important;
}

.install-card {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
}

.install-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.install-title {
  margin: 0;
  font-weight: 700;
  font-family: "Sora", sans-serif;
}

.install-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.install-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.install-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 540px) {
  .install-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .install-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .footer-card {
    align-items: center;
  }
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 8px;
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 3vw, 2.8rem);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 560px;
}

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

.tabs {
  margin-bottom: 20px;
}

.tablist {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  flex-wrap: nowrap;
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tablist::-webkit-scrollbar {
  display: none;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 18px;
  font-family: "Sora", sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  box-shadow: none;
  flex: 0 0 auto;
}

.tab:hover {
  transform: none;
  background: var(--surface-alt);
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tab-panels {
  margin-top: 18px;
}

.tab-panel[hidden] {
  display: none;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.settings-currency {
  display: grid;
  gap: 8px;
  max-width: 360px;
  margin-bottom: 14px;
}

.settings-currency .note {
  margin: 0;
}

button {
  font-family: "Sora", sans-serif;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 12px 20px rgba(12, 107, 99, 0.2);
}

button:hover {
  transform: translateY(-2px);
  background: var(--accent-strong);
}

button.ghost {
  background: var(--surface);
  color: var(--accent-strong);
  border: 1px solid var(--border);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--surface-alt);
}

button.danger {
  color: var(--danger);
  border-color: rgba(159, 18, 57, 0.35);
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 22px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: fadeUp 0.6s ease both;
}

.metric strong {
  font-size: 1.6rem;
}

.metric .label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.section-title {
  margin-bottom: 18px;
}

.section-title.inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-title h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

.section-title p {
  margin: 0;
  color: var(--muted);
}

.form-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.date-field {
  flex: 1 1 260px;
}

.date-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.date-input button {
  padding: 10px 16px;
  white-space: nowrap;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

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

.field-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}

.toggle-group .toggle {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  font-family: "Sora", sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.toggle-group .toggle:hover {
  transform: none;
  background: rgba(12, 107, 99, 0.08);
}

.toggle-group .toggle.active {
  color: #fff;
}

.toggle-group .toggle[data-type="buy"].active {
  background: var(--success);
}

.toggle-group .toggle[data-type="sell"].active {
  background: var(--danger);
}

.toggle-group .toggle.is-disabled {
  opacity: 0.5;
}

input,
select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: "Source Sans 3", sans-serif;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.grow {
  flex: 1 1 20px;
}

.coin-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 8px 0;
}

.coin-result {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  background: #fff;
  text-align: left;
  box-shadow: none;
  color: var(--ink);
  font-family: "Source Sans 3", sans-serif;
}

.coin-result:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.coin-result strong {
  font-family: "Sora", sans-serif;
  margin-right: 6px;
}

.coin-cell strong {
  display: block;
}

.coin-cell span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.coin-result .note {
  margin: 0;
  display: inline;
  font-size: 0.75rem;
}

.sell-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.sell-fields>* {
  margin: 0;
}

.sell-fields select {
  max-width: 320px;
}

.sell-fields .note {
  margin: 6px 0 0 0;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.form-footer strong {
  font-size: 1.3rem;
}

.form-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
}

.note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: "Sora", sans-serif;
}

.badge.buy {
  background: rgba(22, 101, 52, 0.12);
  color: var(--success);
}

.badge.sell {
  background: rgba(159, 18, 57, 0.12);
  color: var(--danger);
}

.tx-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  line-height: 1;
  box-shadow: none;
}

.icon-button:hover {
  transform: none;
}

.icon-button .material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
  font-variation-settings:
    "FILL" 0,
    "wght" 400,
    "GRAD" 0,
    "opsz" 24;
}

.row-editing {
  background: var(--surface-alt);
}

.inline-input {
  width: 100%;
  min-width: 90px;
  padding: 8px 10px;
  font-size: 0.88rem;
}

.inline-select {
  min-width: 84px;
  text-transform: uppercase;
}

.inline-number {
  min-width: 100px;
}

.inline-date {
  min-width: 192px;
}

.inline-note {
  min-width: 160px;
}

.positive {
  color: var(--success);
  font-weight: 600;
}

.negative {
  color: var(--danger);
  font-weight: 600;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .app {
    padding: 28px 18px 48px;
  }

  .section-title.inline {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
