:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --text: #17324d;
  --muted: #65788b;
  --accent: #2269d8;
  --accent-dark: #1853ad;
  --secondary: #36b6c5;
  --line: #dce4ed;
  --danger: #b83a4b;
  --danger-bg: #fff1f3;
  --success: #147a64;
  --success-bg: #eaf8f5;
  --radius: 12px;
  --shadow: 0 14px 40px rgba(23, 50, 77, .1);
  font-family: "Avenir Next", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid rgba(34, 105, 216, .32); outline-offset: 2px; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
h1, h2, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(24px, 4vw, 32px); line-height: 1.12; letter-spacing: -.025em; }
h2 { margin: 0; font-size: 22px; line-height: 1.2; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-size: 18px; font-weight: 700; text-decoration: none; letter-spacing: -.015em; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--text); border-radius: 9px 3px 9px 3px; color: var(--accent); font-family: SFMono-Regular, Consolas, monospace; font-size: 11px; letter-spacing: -.04em; }

.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; gap: 7px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-weight: 650; line-height: 1.15; text-decoration: none; transition: background-color .15s ease, border-color .15s ease, transform .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button[aria-disabled="true"] { cursor: not-allowed; opacity: .5; transform: none; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { border-color: #addce2; background: #edfafd; color: #176674; }
.button-quiet { border-color: var(--line); background: var(--surface); color: var(--text); }
.button-danger { border-color: #efc2c8; background: var(--danger-bg); color: var(--danger); }
.button-wide { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-button { width: 34px; height: 34px; flex: 0 0 auto; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-size: 24px; line-height: 1; }
.icon-button:hover { background: var(--bg); color: var(--text); }

.login-page { min-height: 100vh; }
.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card { width: min(100%, 390px); padding: 28px; border: 1px solid var(--line); border-top: 4px solid var(--secondary); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.brand-login { margin-bottom: 38px; }
.login-heading { margin-bottom: 22px; }
.login-heading .muted { margin: 9px 0 0; font-size: 14px; line-height: 1.5; }

.stack-form, .dialog-card { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: var(--text); font-size: 13px; font-weight: 650; }
label small { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.4; }
input, select { width: 100%; min-height: 42px; border: 1px solid #c8d3df; border-radius: 8px; background: #fff; color: var(--text); padding: 9px 11px; }
input:hover, select:hover { border-color: #9dafc1; }

.topbar { position: sticky; z-index: 10; top: 0; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .96); }
.topbar-inner { display: flex; width: min(1120px, calc(100% - 32px)); min-height: 64px; align-items: center; justify-content: space-between; gap: 20px; margin: 0 auto; }
.account { display: flex; min-width: 0; align-items: center; gap: 12px; }
.account-copy { display: grid; min-width: 0; max-width: 220px; text-align: right; }
.account-copy strong { font-size: 13px; }
.account-copy span { color: var(--muted); font-size: 11px; }
.app-shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 26px 0 56px; }

.tabs { display: flex; gap: 3px; margin-bottom: 28px; padding: 4px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #eaf0f6; scrollbar-width: none; }
.tab { flex: 0 0 auto; min-height: 36px; padding: 7px 13px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 650; }
.tab.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(23, 50, 77, .1); }
.badge { min-width: 19px; padding: 2px 6px; border-radius: 10px; background: var(--accent); color: white; font-family: SFMono-Regular, Consolas, monospace; font-size: 10px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }

.notice, .alert { margin-bottom: 16px; padding: 10px 12px; border: 1px solid #b9dfe4; border-radius: 8px; background: #eefbfd; color: #176674; font-size: 13px; }
.alert-error, .notice.is-error { border-color: #efc2c8; background: var(--danger-bg); color: var(--danger); }
.notice.is-success { border-color: #b9dfd5; background: var(--success-bg); color: var(--success); }

.counters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.counter { display: flex; min-width: 0; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px; border-right: 1px solid var(--line); }
.counter:last-child { border-right: 0; }
.counter span { color: var(--muted); font-size: 12px; }
.counter strong { font-family: SFMono-Regular, Consolas, monospace; font-size: 22px; font-variant-numeric: tabular-nums; }
.status-line { display: flex; justify-content: space-between; gap: 16px; padding: 9px 2px 18px; color: var(--muted); font-size: 11px; }

.state-block { padding: 22px; border: 1px dashed #bac8d6; border-radius: var(--radius); color: var(--muted); text-align: center; }
.state-error { border-color: #e7aab4; background: var(--danger-bg); color: var(--danger); }
.data-list { display: grid; gap: 8px; }
.data-row { display: grid; grid-template-columns: minmax(150px, 1.3fr) minmax(120px, .8fr) minmax(180px, 1fr) 90px auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.data-row.no-owner { grid-template-columns: minmax(160px, 1.4fr) minmax(180px, 1fr) 90px auto; }
.data-row.user-row { grid-template-columns: minmax(150px, 1fr) minmax(120px, .8fr) auto; }
.data-row.request-row { grid-template-columns: minmax(170px, 1fr) minmax(120px, .7fr) minmax(135px, .65fr) auto; }
.row-primary { min-width: 0; }
.row-primary strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.row-primary span, .cell-label { color: var(--muted); font-size: 11px; }
.row-meta { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.link-status { display: inline-flex; align-items: center; gap: 4px; font-weight: 650; }
.link-status::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.link-status.is-enabled { color: var(--success); }
.link-status.is-disabled { color: var(--danger); }
.cell { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.cell-number { font-family: SFMono-Regular, Consolas, monospace; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.row-actions .button { min-height: 34px; padding: 6px 9px; font-size: 12px; }

.usage { display: grid; gap: 6px; }
.usage-copy { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: SFMono-Regular, Consolas, monospace; font-size: 11px; }
.segments { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.segment { height: 7px; border-radius: 2px; background: #dfe7ef; }
.segment.is-on { background: var(--secondary); }
.segment.is-over { background: var(--danger); }
.unlimited { display: inline-flex; align-items: center; gap: 7px; color: var(--accent); font-weight: 700; }
.unlimited-mark { display: grid; width: 30px; height: 24px; place-items: center; border: 1px solid #a9c5ec; border-radius: 6px; background: #eef5ff; font-family: Georgia, serif; font-size: 20px; line-height: 1; }

.credentials { margin-bottom: 16px; padding: 16px; border: 1px solid #9fd8cb; border-left: 4px solid var(--success); border-radius: 10px; background: var(--success-bg); }
.credentials-head { display: flex; align-items: center; justify-content: space-between; }
.credentials p { margin: 3px 0 12px; color: #37695f; font-size: 12px; }
.credentials dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.credentials dl div { min-width: 0; padding: 9px; border-radius: 7px; background: rgba(255,255,255,.7); }
.credentials dt { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.credentials dd { margin: 4px 0 0; overflow-wrap: anywhere; font-family: SFMono-Regular, Consolas, monospace; font-size: 13px; }

.dialog { width: min(94vw, 470px); max-height: 90vh; padding: 0; overflow: auto; border: 0; border-radius: 14px; background: transparent; box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(14, 32, 50, .45); }
.dialog-card { padding: 22px; background: var(--surface); }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.result-box { padding: 14px; border: 1px solid #b9dfd5; border-radius: 9px; background: var(--success-bg); }
.result-box p { margin: 6px 0 12px; font-family: SFMono-Regular, Consolas, monospace; font-size: 12px; }
.result-box .result-meta { margin-top: -8px; color: var(--success); font-family: inherit; }

@media (max-width: 760px) {
  .topbar-inner, .app-shell { width: min(100% - 24px, 1120px); }
  .account-copy { max-width: 120px; }
  .account-copy span { display: none; }
  .app-shell { padding-top: 16px; }
  .tabs { margin-bottom: 20px; }
  .section-heading { align-items: start; }
  .counters { grid-template-columns: 1fr; }
  .counter { border-right: 0; border-bottom: 1px solid var(--line); }
  .counter:last-child { border-bottom: 0; }
  .status-line { flex-direction: column; gap: 4px; }
  .data-row, .data-row.no-owner, .data-row.user-row, .data-row.request-row { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px; }
  .cell[data-label]::before { display: block; margin-bottom: 3px; color: var(--muted); content: attr(data-label); font-size: 10px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
  .row-actions { justify-content: flex-start; }
  .usage { max-width: 280px; }
}

@media (max-width: 430px) {
  .login-shell { padding: 14px; }
  .login-card { padding: 22px; }
  .topbar-inner { min-height: 58px; }
  .brand { gap: 7px; font-size: 16px; }
  .brand-mark { width: 29px; height: 29px; }
  .account { gap: 7px; }
  .account-copy { max-width: 92px; }
  .button { padding-inline: 10px; }
  .section-heading { display: grid; }
  .section-heading > .button { width: 100%; }
  .credentials dl { grid-template-columns: 1fr; }
  .dialog-card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
