:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --accent: #003366;
  --accent-light: #e6f0ff;
  --border: #d1d5db;
  --success: #059669;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  text-align: center;
  margin-bottom: 1rem;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

header p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.search-wrap {
  position: relative;
  margin-bottom: 1rem;
}

.search-wrap input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.search-wrap .icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.1rem;
  pointer-events: none;
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  min-height: 1.25rem;
}

.status-bar .spinner {
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.status-bar.loading .spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

.results-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.result-item:hover, .result-item:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.result-item .row-top {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.result-item .code {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  white-space: nowrap;
}

.result-item .desc {
  font-size: 0.9rem;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-item .meta {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.result-item .badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  background: #e5e7eb;
  color: #374151;
}

.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.detail-panel .detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.detail-panel .detail-code {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.detail-panel .detail-desc {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  line-height: 1.55;
}

.detail-panel .detail-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.detail-panel .rates-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.detail-panel .rates-table th,
.detail-panel .rates-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.detail-panel .rates-table th {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.detail-panel .rates-table td:last-child {
  font-weight: 600;
  color: var(--success);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detail-panel .close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2rem;
  padding-bottom: 1rem;
}

@media (max-width: 480px) {
  .container { padding: 0.75rem; }
  header h1 { font-size: 1.1rem; }
  .result-item .desc { white-space: normal; }
}
