:root {
  color-scheme: light;
  --ink: #18212b;
  --muted: #66717d;
  --line: #dfe4e8;
  --soft: #f5f7f8;
  --accent: #16634a;
  --accent-dark: #0f4f3a;
  --danger: #9d2f2f;
  --danger-bg: #fff3f3;
  --card: #ffffff;
}

* { box-sizing: border-box; }

html { min-width: 300px; }

body {
  margin: 0;
  min-height: 100vh;
  background: #eef1f3;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { cursor: pointer; }

.page-shell {
  width: min(1060px, calc(100% - 32px));
  margin: 40px auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  letter-spacing: -0.035em;
}

.status {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.header-actions form { margin: 0; }

.refresh-button,
.login-form button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  padding: 10px 15px;
}

.refresh-button:hover,
.login-form button:hover { background: var(--accent-dark); }
.refresh-button:disabled { opacity: 0.55; cursor: wait; }

.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.table-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 8px 26px rgba(28, 39, 49, 0.06);
}

table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.coin-column { width: 16%; }

th, td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 14px;
  text-align: right;
  vertical-align: middle;
}

th:last-child, td:last-child { border-right: 0; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }

thead th {
  background: #1d2935;
  color: white;
  font-size: 0.79rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

thead th:first-child,
tbody th,
tfoot th { text-align: left; }

.compact-label { display: none; }

tbody th {
  background: #fbfcfc;
  font-size: 1rem;
}

tbody td strong {
  display: block;
  font-size: clamp(0.86rem, 1.7vw, 1.08rem);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tfoot td {
  font-size: clamp(0.86rem, 1.7vw, 1.08rem);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-quantity,
.coin-price {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quantity-symbol { margin-left: 0.28em; }

tbody tr:hover td,
tbody tr:hover th { background: #f7faf8; }

tfoot th,
tfoot td {
  border-top: 2px solid #b9c4cc;
  border-bottom: 0;
  background: #edf5f1;
  color: #123d30;
  font-weight: 800;
}

tfoot th { letter-spacing: 0.04em; }

.error-box {
  margin: 0 0 16px;
  border: 1px solid #efc4c4;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  padding: 11px 13px;
  font-size: 0.9rem;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 0.76rem;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(390px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 30px;
  box-shadow: 0 12px 34px rgba(28, 39, 49, 0.09);
}

.login-card h1 { text-align: center; }
.login-card > p { margin: 7px 0 24px; color: var(--muted); text-align: center; }

.coin-mark {
  display: grid;
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 50%;
  background: #1d2935;
  color: white;
  font-size: 1.3rem;
  font-weight: 800;
}

.login-form { display: grid; gap: 8px; }
.login-form label { margin-top: 5px; color: #3d4854; font-size: 0.84rem; font-weight: 700; }
.login-form input {
  width: 100%;
  border: 1px solid #cbd3d9;
  border-radius: 8px;
  background: white;
  padding: 11px 12px;
  outline: none;
}
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 99, 74, 0.13); }
.login-form button { margin-top: 12px; padding: 12px 16px; }
.login-card .error-box { margin: 0 0 12px; }

@media (max-width: 680px) {
  .page-shell { width: min(100% - 16px, 1060px); margin: 18px auto; }
  .page-header { align-items: flex-start; gap: 12px; }
  .header-actions { gap: 9px; }
  .refresh-button { padding: 8px 10px; }
  .coin-column { width: 18%; }
  th, td { padding: 13px 7px; }
  thead th { font-size: clamp(0.58rem, 2.4vw, 0.74rem); letter-spacing: 0; text-transform: none; }
  tbody th { font-size: 0.86rem; }
  tbody td strong, tfoot td { font-size: clamp(0.68rem, 3vw, 0.9rem); }
  .cell-quantity, .coin-price { font-size: clamp(0.56rem, 2.4vw, 0.7rem); }
  footer { flex-direction: column; gap: 3px; }
}

@media (max-width: 430px) {
  .page-header { display: block; }
  .header-actions { margin-top: 12px; justify-content: space-between; }
  .status { min-height: 1.25em; }
  .table-card { border-radius: 9px; }
  th, td { padding: 11px 4px; }
  .wide-label { display: none; }
  .compact-label { display: inline; }
  .coin-price { display: none; }
  .cell-quantity {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    letter-spacing: -0.02em;
  }
  .cell-quantity > span { display: block; }
  .quantity-symbol { margin: 1px 0 0; }
}
