:root {
  --bg: #f5f7fb; --surface: #fff; --ink: #0f172a; --muted: #475569; --line: #e2e8f0;
  --brand: #3730a3; --brand-ink: #fff; --accent: #0ea5e9; --ok: #15803d; --err: #b91c1c;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --pad-x: clamp(.75rem, 4vw, 2.5rem);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { height: 100%; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  height: 100dvh; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr);
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .35rem var(--pad-x); background: var(--surface); border-bottom: 1px solid var(--line); min-width: 0;
}
.brand { font-weight: 700; font-size: 1.25rem; letter-spacing: -.01em; color: var(--brand); }
.langs { display: flex; gap: .25rem; padding: .2rem; background: var(--bg); border-radius: 999px; }
.langs button {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; transition: background .15s, color .15s;
}
.langs button:hover { background: var(--line); }
.langs button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
nav { display: flex; flex-wrap: wrap; gap: .5rem; padding: .25rem var(--pad-x); min-width: 0; }
nav a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 1rem;
  border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 600; transition: background .15s;
}
nav a:hover { background: var(--line); }
nav a[aria-current="page"] { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
main {
  min-height: 0; min-width: 0; width: 100%; max-width: 1100px; justify-self: center;
  padding: clamp(.5rem, 2.5vh, 2rem) var(--pad-x); overflow: auto;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; gap: clamp(.5rem, 2vh, 1.25rem);
}
main:has(> .hero) { overflow: hidden; }
h1 { font-size: clamp(1.35rem, min(5vw, 5.5vh), 3rem); line-height: 1.12; margin: 0 0 .4rem; letter-spacing: -.02em; overflow-wrap: anywhere; }
.lead { font-size: clamp(.9rem, min(2.5vw, 2.6vh), 1.25rem); line-height: 1.4; color: var(--muted); max-width: 60ch; margin: 0; overflow-wrap: anywhere; }
.hero { padding: 0; min-width: 0; animation: rise .5s ease-out both; }
.cards {
  display: grid; min-height: 0; min-width: 0; gap: clamp(.5rem, 1.5vw, 1rem);
  grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(.5rem, 2vmin, 1.25rem); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
  min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: center;
  overflow-wrap: anywhere; hyphens: auto;
}
.card:hover { transform: translateY(-2px); }
.card h2 { font-size: clamp(.9rem, min(3.6vw, 2.6vh), 1.1rem); line-height: 1.25; margin: 0 0 .3rem; }
.card p { margin: 0; color: var(--muted); font-size: clamp(.78rem, min(3vw, 2.3vh), 1rem); line-height: 1.35; }
.status { display: flex; align-items: center; gap: .5rem; margin: 0; min-height: 1.5rem; color: var(--muted); font-size: .875rem; }
.status::before { content: ""; flex: none; width: .7rem; height: .7rem; border-radius: 50%; background: var(--line); }
.status[data-state="ok"]::before { background: var(--ok); }
.status[data-state="down"]::before { background: var(--err); }
.msg { padding: .75rem 1rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.msg.error { color: var(--err); border-color: var(--err); }
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
form { display: grid; gap: 1rem; max-width: 420px; }
label { display: grid; gap: .25rem; font-weight: 600; }
input { min-height: 44px; padding: 0 .75rem; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
form button { min-height: 44px; border: 0; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; cursor: pointer; }
@media (min-width: 900px) {
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
}
@media (max-height: 500px) {
  body { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  header { grid-column: 1; grid-row: 1; padding: .25rem .75rem; border-bottom: 1px solid var(--line); gap: 1rem; }
  nav { grid-column: 2; grid-row: 1; align-items: center; flex-wrap: nowrap; padding: .25rem .75rem; background: var(--surface); border-bottom: 1px solid var(--line); }
  main { grid-column: 1 / -1; grid-row: 2; }
  .brand { font-size: 1.1rem; }
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
}
.swap { animation: fade .18s ease-out both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
