:root {
  color-scheme: dark;
  --bg: #131416;
  --surface: #1b1d20;
  --line: #2e3136;
  --text: #e8e9eb;
  --muted: #a0a4ab;
  --accent: #7fb0ff;
  --good: #63c58f;
  --warn: #e3b75b;
  --critical: #f28b82;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

h1 { margin: 0; font-size: 18px; font-weight: 600; }
h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--critical); font-size: 14px; }

button, input { font: inherit; color: inherit; }
button {
  min-height: 40px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #10141b; font-weight: 600; }
button.danger { border-color: var(--critical); color: var(--critical); }
input {
  min-height: 40px;
  width: 100%;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.login { width: min(360px, 100% - 32px); margin: 12vh auto 0; }
.login form { display: grid; gap: 6px; margin-top: 20px; }
.login label { margin-top: 8px; font-size: 13px; color: var(--muted); }
.login button { margin-top: 14px; }

.panel { max-width: 1440px; margin: 0 auto; padding: 12px 16px 32px; display: grid; gap: 16px; }
.topbar { display: flex; align-items: center; gap: 12px; }
.topbar h1 { margin-right: auto; }
.banner { padding: 8px 12px; border: 1px solid var(--critical); border-radius: 8px; }

.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile, .plan { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.value { font-size: 20px; font-weight: 600; }
.value.good { color: var(--good); }
.value.bad { color: var(--critical); }

#plan { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px 24px; }
.window { display: grid; gap: 4px; }
.window-head { display: flex; justify-content: space-between; gap: 12px; }
.window progress {
  display: block;
  width: 100%;
  height: 8px;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--line);
}
.window progress::-webkit-progress-bar { background: var(--line); border-radius: 4px; }
.window progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
.window progress::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
.window.tight progress::-webkit-progress-value { background: var(--critical); }
.window.tight progress::-moz-progress-bar { background: var(--critical); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.cell-name { font-weight: 600; overflow-wrap: anywhere; min-width: 90px; }
.cell-usage { min-width: 112px; }
.cell-seen { min-width: 92px; }
.lines { display: block; }
.badge {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.badge.active { color: var(--good); }
.badge.pending { color: var(--warn); }
.badge.blocked { color: var(--critical); }

.actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 124px; }
.actions button, .limit-form button { min-height: 36px; padding: 0 10px; font-size: 14px; }
.limit-form { display: grid; gap: 6px; min-width: 170px; }
.limit-form label { font-size: 12px; color: var(--muted); }
.limit-buttons { display: flex; gap: 6px; }
.confirm-text { width: 100%; font-size: 13px; }

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; margin-bottom: 8px; }
.section-head h2 { margin: 0; }

/* iPad in beiden Lagen und schmaler: jedes Konto als Karte statt zehn enger Spalten. */
@media (max-width: 1200px) {
  .table-wrap { background: none; border: 0; overflow: visible; }
  #users thead { display: none; }
  #users, #users tbody { display: block; }
  #users tr {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px 16px;
    margin-bottom: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
  }
  #users td { display: block; padding: 0; border: 0; min-width: 0; }
  #users td::before {
    content: attr(data-label);
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
  }
  #users td.cell-name { grid-column: 1 / -1; font-size: 16px; order: -1; }
  #users td.cell-usage { order: 1; }
  #users td.cell-actions { order: 2; }
  #users td.cell-name::before, #users td.cell-actions::before { content: none; }
  #users td.cell-actions { grid-column: 1 / -1; }
  .limit-form { max-width: 320px; }
}

@media (max-width: 840px) {
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary .tile:last-child { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  #users tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .panel { padding: 10px 12px 24px; }
  .summary { grid-template-columns: minmax(0, 1fr); }
}
