* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0b0e14;
  --surface: #121620;
  --surface-2: #171c28;
  --border: #232a38;
  --border-2: #2f3849;
  --text: #e6e9ef;
  --muted: #8b94a7;
  --faint: #5a6377;
  --accent: #4f9dff;
  --accent-soft: rgba(79, 157, 255, 0.12);
  --green: #4ade80;
  --yellow: #facc15;
  --radius: 12px;
  --ease: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79, 157, 255, 0.13), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(192, 132, 252, 0.07), transparent);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  padding: 32px 20px 60px;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1040px;
  margin: 0 auto;
}

/* ===== Header ===== */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.header h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff, #9fb6d9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ===== Search ===== */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  opacity: 0.55;
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 15px 46px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

#search::placeholder { color: var(--faint); }

#search:focus {
  border-color: var(--accent);
  background: var(--surface-2);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.clear {
  position: absolute;
  right: 12px;
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--ease);
}

.clear:hover { background: #2a3244; color: var(--text); }
.clear.visible { display: flex; }

/* ===== Chips ===== */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  padding: 7px 15px;
  font: 500 0.82rem/1 inherit;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--ease);
}

.chip:hover {
  color: var(--text);
  border-color: var(--border-2);
  background: var(--surface-2);
}

.chip.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(79, 157, 255, 0.45);
}

/* ===== Status ===== */
.status {
  padding: 14px 4px 10px;
  font-size: 0.82rem;
  color: var(--faint);
}

/* ===== Table ===== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

thead {
  background: var(--surface-2);
}

th {
  padding: 14px 16px;
  text-align: left;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--ease);
}

th.sortable:hover { color: var(--text); }

th .arrow {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity var(--ease);
}

th.asc .arrow::after  { content: "▲"; color: var(--accent); }
th.desc .arrow::after { content: "▼"; color: var(--accent); }
th.asc .arrow, th.desc .arrow { opacity: 1; }

td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(35, 42, 56, 0.6);
  vertical-align: middle;
}

tbody tr { transition: background var(--ease); }
tbody tr:hover { background: rgba(79, 157, 255, 0.055); }
tbody tr:last-child td { border-bottom: none; }

.flag-col { width: 60px; text-align: center; }

.flag {
  font-size: 1.5rem;
  line-height: 1;
  display: inline-block;
}

.name {
  font-weight: 600;
}

.name-vi {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--faint);
  margin-top: 2px;
}

.code {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.code-alpha2 {
  display: inline-block;
  padding: 4px 10px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(79, 157, 255, 0.25);
  border-radius: 6px;
}

.code-alpha3 { color: var(--green); }
.code-numeric { color: var(--yellow); }

mark {
  background: rgba(250, 204, 21, 0.22);
  color: #ffe98a;
  border-radius: 3px;
  padding: 0 2px;
}

/* ===== Empty ===== */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  font-size: 2.4rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.hidden { display: none !important; }

/* ===== Footer ===== */
.footer {
  margin-top: 22px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--faint);
}

.footer strong { color: var(--muted); }

/* ===== Responsive ===== */
@media (max-width: 720px) {
  body { padding: 22px 12px 40px; }

  th, td { padding: 11px 10px; }

  .flag-col { width: 46px; }

  th:nth-child(4), td:nth-child(4) { display: none; }

  .flag { font-size: 1.25rem; }
  .name { font-size: 0.88rem; }
}

@media (max-width: 460px) {
  .chip { padding: 6px 12px; font-size: 0.76rem; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: #2a3244;
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #3a4459; }