:root {
  --bg: #0c0d0f;
  --panel: #111316;
  --panel-2: #15181b;
  --panel-3: #0f1113;
  --line: #262a2f;
  --line-soft: #1c2024;
  --text: #e8e7e2;
  --muted: #8b908d;
  --dim: #5d625f;
  --accent: #d7a15c;
  --accent-strong: #efb973;
  --good: #79c89d;
  --bad: #df7a72;
  --shadow: 0 24px 80px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; height: 100dvh; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(215,161,92,.08), transparent 28%),
    radial-gradient(circle at 100% 100%, rgba(121,200,157,.045), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { overscroll-behavior: none; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.014) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.014) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.55), transparent 80%);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
[hidden] { display: none !important; }

.view {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100svh;
}

.login-view {
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.login-panel {
  width: min(410px, 100%);
  padding: 28px;
  background: rgba(17, 19, 22, .96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-symbol {
  width: 22px;
  display: grid;
  gap: 3px;
  flex: 0 0 auto;
}
.brand-symbol span {
  display: block;
  height: 3px;
  background: var(--accent);
}
.brand-symbol span:nth-child(2) { width: 70%; opacity: .7; }
.brand-symbol span:nth-child(3) { width: 43%; opacity: .4; }
.brand-title {
  font: 700 14px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .12em;
}

.open-view {
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.open-panel {
  width: min(410px, 100%);
  padding: 28px;
  background: rgba(17, 19, 22, .96);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.open-content {
  margin-top: 48px;
  display: grid;
  gap: 22px;
}

.open-content h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -.04em;
  font-weight: 600;
}

.open-button {
  width: 100%;
}

.login-content { margin-top: 48px; }
.login-content h1 {
  margin: 0 0 18px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: -.04em;
  font-weight: 600;
}
.login-form { display: grid; gap: 10px; }
.login-form input[type="password"] {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: #0c0e10;
  color: var(--text);
  outline: none;
}
.login-form input[type="password"]::placeholder { color: #5a5f5c; }
.login-form input[type="password"]:focus {
  border-color: rgba(215,161,92,.65);
  box-shadow: 0 0 0 3px rgba(215,161,92,.08);
}

.button {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #15110b;
}
.button-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.button-quiet { background: var(--panel-2); color: #b8bbb7; }
.button-quiet:hover { border-color: #3a4046; color: var(--text); }

.error {
  margin: 2px 0 0;
  color: var(--bad);
  font-size: 12px;
}

.dashboard {
  width: min(1500px, calc(100vw - 28px));
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 0 max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.dashboard-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.summary {
  min-width: 0;
  color: var(--muted);
  font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions { display: flex; gap: 7px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.stat {
  min-width: 0;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.stat:last-child { border-right: 0; }
.stat span {
  color: var(--dim);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.stat strong {
  color: var(--text);
  font: 600 16px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}

.message {
  flex: 0 0 auto;
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid rgba(215,161,92,.22);
  background: rgba(215,161,92,.06);
  color: #c4b9aa;
  font-size: 11px;
}

.table-panel {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 17, 19, .82);
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
}

.account-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
}

.account-table th,
.account-table td {
  text-align: left;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.account-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #121417;
  color: var(--dim);
  font: 700 9px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.account-table tbody tr:hover { background: rgba(255,255,255,.018); }
.account-table tbody tr:last-child td { border-bottom: 0; }
.account-table th[data-sort-key] { cursor: pointer; user-select: none; }
.account-table th[data-sort-key]:hover,
.account-table th[data-sort-key]:focus-visible { color: #c7c8c3; outline: none; }
.sort-indicator { margin-left: 5px; color: #40454a; font-size: 8px; }
.account-table th[aria-sort="ascending"] .sort-indicator,
.account-table th[aria-sort="descending"] .sort-indicator { color: var(--accent); }

.account-cell { min-width: 260px; }
.email {
  color: #e2e1dc;
  font: 600 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}
.account-id {
  margin-top: 3px;
  color: #505652;
  font: 9px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid transparent;
  font: 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-ok { color: var(--good); background: rgba(121,200,157,.06); border-color: rgba(121,200,157,.14); }
.status-low { color: var(--accent-strong); background: rgba(215,161,92,.07); border-color: rgba(215,161,92,.18); }
.status-bad { color: var(--bad); background: rgba(223,122,114,.06); border-color: rgba(223,122,114,.14); }

.plan-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid #2a2f34;
  border-radius: 999px;
  color: #c9cbc6;
  background: #16191c;
  font: 600 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.plan-free { color: #b8bdb8; }
.plan-go { color: #93c9b8; border-color: rgba(121,200,157,.18); background: rgba(121,200,157,.05); }
.plan-plus { color: #d8b4e8; border-color: rgba(191,151,220,.2); background: rgba(191,151,220,.05); }
.plan-pro { color: #e6c27d; border-color: rgba(215,161,92,.2); background: rgba(215,161,92,.05); }
.plan-business, .plan-enterprise, .plan-edu { color: #aebee2; border-color: rgba(130,153,210,.2); background: rgba(130,153,210,.05); }

.quota-wrap { min-width: 150px; }
.quota-line { display: flex; align-items: baseline; gap: 7px; }
.quota-main { color: var(--text); font: 700 16px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.quota-label { color: #626865; font: 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.usage {
  color: #626865;
  font: 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.meter { height: 3px; margin-top: 7px; background: #202429; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); }
.secondary-quota,
.row-error {
  margin-top: 4px;
  color: #69706c;
  font: 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.row-error { color: var(--bad); overflow-wrap: anywhere; }
.muted-cell { color: #4f5552; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


@supports (height: 100dvh) {
  html, body { height: 100dvh; }
  .view { height: 100dvh; }
}

@media (max-width: 900px) {
  .dashboard {
    width: calc(100vw - 20px);
  }

  .dashboard-header {
    grid-template-columns: 1fr auto;
    gap: 10px;
  }

  .summary {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(1),
  .stat:nth-child(2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 600px) {
  .login-view {
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .login-panel {
    width: 100%;
    max-width: none;
    padding: 22px;
  }

  .login-content {
    margin-top: 34px;
  }

  .login-content h1 {
    font-size: 28px;
  }

  .dashboard {
    width: 100%;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .dashboard-header {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-bottom: 8px;
  }

  .brand-dashboard {
    min-height: 28px;
  }

  .brand-title {
    font-size: 12px;
  }

  .summary {
    grid-column: auto;
    grid-row: auto;
    font-size: 10px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 6px;
  }

  .header-actions .button {
    width: 100%;
    height: 36px;
    padding: 0 8px;
    font-size: 11px;
  }

  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-bottom: 1px solid var(--line);
  }

  .stat {
    min-width: 0;
    padding: 8px 5px 9px;
    border-right: 1px solid var(--line);
    border-bottom: 0 !important;
    display: grid;
    gap: 3px;
    justify-content: center;
    text-align: center;
  }

  .stat:last-child {
    border-right: 0;
  }

  .stat span {
    font-size: 7px;
    letter-spacing: .08em;
  }

  .stat strong {
    font-size: 13px;
  }

  .message {
    margin: 6px 0;
    padding: 7px 8px;
    font-size: 10px;
  }

  .table-panel {
    margin-top: 7px;
    border-left: 0;
    border-right: 0;
  }

  .table-scroll {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .account-table {
    min-width: 700px;
  }

  .account-table th,
  .account-table td {
    padding: 9px 9px;
  }

  .account-table th {
    font-size: 8px;
    letter-spacing: .08em;
  }

  .account-table th:first-child,
  .account-table td:first-child {
    position: sticky;
    left: 0;
  }

  .account-table th:first-child {
    z-index: 5;
    background: #121417;
    box-shadow: 7px 0 10px rgba(0,0,0,.16);
  }

  .account-table td:first-child {
    z-index: 3;
    background: #101215;
    box-shadow: 7px 0 10px rgba(0,0,0,.13);
  }

  .account-cell {
    min-width: 220px;
  }

  .email {
    font-size: 11px;
    line-height: 1.35;
  }

  .account-id {
    display: none;
  }

  .status {
    min-height: 22px;
    padding: 3px 6px;
    font-size: 9px;
  }

  .plan-badge {
    min-width: 50px;
    height: 22px;
    padding: 0 7px;
    font-size: 9px;
  }

  .quota-wrap {
    min-width: 130px;
  }

  .quota-main {
    font-size: 14px;
  }

  .quota-label,
  .usage,
  .secondary-quota {
    font-size: 9px;
  }

  .meter {
    margin-top: 5px;
  }

  .account-table td:nth-child(5) {
    min-width: 170px;
  }
}

@media (max-width: 390px) {
  .login-panel {
    padding: 18px;
  }

  .login-content {
    margin-top: 28px;
  }

  .login-content h1 {
    font-size: 26px;
  }

  .header-actions .button {
    font-size: 10px;
    padding: 0 6px;
  }

  .stat span {
    font-size: 6.5px;
  }

  .stat strong {
    font-size: 12px;
  }
}
