:root {
  --bg: #f6fbff;
  --card: #ffffff;
  --muted: #6b7280;
  --accent: #0b74ff;
  --radius: 12px;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  font-family:
    Inter,
    system-ui,
    Segoe UI,
    Roboto,
    Arial;
}
body {
  background: linear-gradient(180deg, var(--bg), #eef6ff);
  color: #0f172a;
}
.app {
  max-width: 1100px;
  margin: 36px auto;
  padding: 20px;
}
.app-header {
  text-align: center;
  margin-bottom: 18px;
}
.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
}
.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}
.container {
  display: grid;
  grid-template-columns: 1fr 440px;
  gap: 18px;
  align-items: start;
}
.converter-card,
.chart-card {
  background: var(--card);
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(13, 38, 76, 0.06);
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}
.col {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.select-col {
  flex: 1.2;
}
.action-col {
  flex: 0 0 110px;
}
.select-with-flag {
  display: flex;
  align-items: center;
  gap: 8px;
}
.flag {
  width: 44px;
  height: 30px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e6eef8;
}
input[type="number"],
select {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #e6eef8;
  background: white;
  font-size: 1rem;
}
.swap-btn {
  background: transparent;
  border: 1px solid #e6eef8;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}
.swap-btn i {
  font-size: 22px;
  color: var(--accent);
}
.convert-btn {
  background: linear-gradient(90deg, var(--accent), #2563eb);
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}
.result-row {
  margin-top: 14px;
}
#resultDisplay {
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
}
.history {
  margin-top: 12px;
}
.history ul {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 160px;
  overflow: auto;
}
.history li {
  padding: 8px;
  border-radius: 8px;
  background: #fbfdff;
  margin-bottom: 8px;
  font-size: 0.95rem;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.app-footer {
  text-align: center;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- TABEL FOREX (Version A) --- */
.forex-table-box {
  margin-top: 20px;
}

#forexTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.95rem;
}

/* === BUAT LIST KURS FOREX SCROLLABLE === */
#forexTable thead {
  display: table;
  width: 100%;
  table-layout: fixed;
}

#forexTable tbody {
  display: block;
  max-height: 260px;  
  overflow-y: auto;
}

#forexTable tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

#forexTable th,
#forexTable td {
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

#forexTable tr:hover {
  background: #f8fafc;
}

/* Margin & mode row */
.margin-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.margin-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.margin-control input[type="number"] {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #e6eef8;
}

.mode-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mode-options {
  display: flex;
  gap: 12px;
  align-items: center;
}

.mode-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* Kotak rincian tarif*/
.rate-details {
  display: flex;
  gap: 18px;
  margin-top: 8px;
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

.rate-details div {
  background: #fbfdff;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #eef2f7;
}

/* hasil + detail terlihat seperti satu baris */
.result-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 12px;
  flex-wrap: wrap;
}

#resultDisplay {
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  min-width: 220px;
}

.chart-description {
  font-size: 13px;
  color: #555;
  margin-top: 12px;
  line-height: 1.6;
}

.chart-description h4 {
  margin-bottom: 6px;
  font-size: 14px;
}

.chart-description ul {
  padding-left: 18px;
}

.currency-dropdown {
  position: relative;
}

.currency-search {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #e6eef8;
  font-size: 1rem;
}

.currency-list {
  position: absolute;
  top: 110%;
  left: 0;
  right: 0;
  max-height: 180px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  z-index: 20;
  display: none;
}

.currency-item {
  padding: 8px 10px;
  cursor: pointer;
}

.currency-item:hover {
  background: #f1f5f9;
}

/* --- FIX LEBAR KOTAK SELECT DARI & KE --- */
.select-col {
  flex: 0 0 110px !important;    
  max-width: 110px !important;
}

.select-with-flag {
  width: 130px !important;
}

.select-with-flag select,
.select-with-flag input {
  width: 100% !important;
  min-width: 100% !important;
}

/* === OPSIONAL: SCROLLBAR HALUS KURS FOREX === */
#forexTable tbody::-webkit-scrollbar {
  width: 6px;
}

#forexTable tbody::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 6px;
}

/* === FIX CHART AGAR TAJAM === */
.chart-wrapper {
  width: 100%;
  position: relative;
}

#rateChart {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 16 / 9;
  display: block;
}