/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #f4f6fa;
  --surface:    #ffffff;
  --surface2:   #f0f2f7;
  --border:     rgba(0,0,0,0.1);
  --text:       #1a1d27;
  --text2:      #5a6070;
  --text3:      #8a90a0;
  --blue:       #2563eb;
  --blue-bg:    #eff6ff;
  --green:      #16a34a;
  --green-bg:   #f0fdf4;
  --red:        #dc2626;
  --red-bg:     #fef2f2;
  --amber:      #d97706;
  --amber-bg:   #fffbeb;
  --shadow:     0 1px 4px rgba(0,0,0,0.08);
  --radius:     12px;
  --radius-sm:  8px;
  --transition: 0.2s ease;
}

/* Dark mode */
#app.dark {
  --bg:       #0f1117;
  --surface:  #1c1f2e;
  --surface2: #252838;
  --border:   rgba(255,255,255,0.1);
  --text:     #e8eaf0;
  --text2:    #9098b0;
  --text3:    #6070a0;
  --blue-bg:  #1e2d4a;
  --green-bg: #0f2a1a;
  --red-bg:   #2a1010;
  --amber-bg: #2a2000;
  --shadow:   0 1px 4px rgba(0,0,0,0.4);
}

/* ── Fonts ──────────────────────────────────────────────────── */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}

/* ── Layout ─────────────────────────────────────────────────── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
}
.brand-title { font-size: 17px; font-weight: 700; color: var(--text); }
.brand-sub   { font-size: 11px; color: var(--text3); }

.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.last-update { font-size: 12px; color: var(--text3); }

.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
  width: 100%;
}

/* ── Stat row ──────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text3); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-value.green { color: var(--green); }
.stat-value.red   { color: var(--red); }

/* ── Action row ────────────────────────────────────────────── */
.action-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: all var(--transition);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-icon { padding: 8px 10px; font-size: 16px; }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-primary:hover { background: #1d4ed8; }

.btn-info {
  background: var(--blue-bg);
  color: var(--blue);
  border-color: rgba(37,99,235,.25);
}

.btn-warn {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: rgba(217,119,6,.3);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: rgba(220,38,38,.3);
}

.btn-full { width: 100%; justify-content: center; margin-top: 0.75rem; padding: 12px; font-size: 14px; }

/* ── Grid ──────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-title   { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 0.25rem; }
.card-subtitle { font-size: 12px; color: var(--text3); margin-bottom: 1rem; }

/* ── Form ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 0.875rem; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 5px;
}
.form-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--blue); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* ── Fee alert ─────────────────────────────────────────────── */
.fee-alert {
  background: var(--amber-bg);
  border: 1px solid rgba(217,119,6,.4);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--amber);
  margin-bottom: 0.75rem;
  animation: slideDown .25s ease;
}
@keyframes slideDown { from { opacity:0; transform: translateY(-6px); } to { opacity:1; transform:translateY(0); } }

/* ── Result box ────────────────────────────────────────────── */
.result-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
  margin-bottom: 0.75rem;
}
.result-empty { color: var(--text3); font-size: 13px; padding: 1.5rem; }
.result-amount { font-size: 28px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.result-meta { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ── Rate table ────────────────────────────────────────────── */
.rate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 0.75rem;
}
.rate-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.rate-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.rate-table tr:last-child td { border: none; }
.rate-table .row-flash { animation: flash .5s ease; }
@keyframes flash { 0%,100%{background:transparent} 50%{background: var(--blue-bg)} }

.cur-flag { margin-right: 6px; }
.cur-name { color: var(--text3); font-size: 12px; margin-left: 4px; }
.mono { font-family: 'Courier New', monospace; }

.change-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.change-badge.up   { background: var(--green-bg); color: var(--green); }
.change-badge.down { background: var(--red-bg);   color: var(--red); }
.change-badge.flat { background: var(--surface2); color: var(--text3); }

.rate-note { font-size: 11px; color: var(--text3); margin-top: 0.5rem; }
.red  { color: var(--red)!important; }
.green{ color: var(--green)!important; }

/* ── History ────────────────────────────────────────────────── */
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.history-count {
  font-size: 12px;
  color: var(--text3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 10px;
}
.history-empty {
  text-align: center;
  padding: 2.5rem;
  color: var(--text3);
  font-size: 14px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
}
.history-list { max-height: 360px; overflow-y: auto; }
.history-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border: none; }
.history-item.high-fee { background: var(--amber-bg); border-radius: var(--radius-sm); padding: 0.75rem; margin-bottom: 4px; }

.tx-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.tx-from  { font-weight: 700; font-size: 14px; color: var(--text); }
.tx-arrow { color: var(--text3); }
.tx-to    { font-weight: 700; font-size: 14px; color: var(--green); }
.tx-meta  { display: flex; gap: 1.5rem; font-size: 12px; color: var(--text3); flex-wrap: wrap; }
.tx-fee   { }
.tx-time  { margin-left: auto; }

/* ── Footer ─────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 1rem;
  font-size: 12px;
  color: var(--text3);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner { padding: 0.75rem 1rem; }
  .main { padding: 1rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .row-2 { grid-template-columns: 1fr; }
  .action-row { gap: 0.5rem; }
  .btn { padding: 7px 12px; font-size: 12px; }
  .last-update { display: none; }
  .tx-meta { gap: 0.75rem; }
  .tx-time { margin-left: 0; }
}
