:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --surface-muted: #eef3f0;
  --line: #dfe7e3;
  --line-strong: #cbd8d2;
  --text: #17231e;
  --muted: #68766f;
  --green: #176f52;
  --green-hover: #105d44;
  --green-soft: #eaf6ef;
  --orange: #a45b0b;
  --orange-soft: #fff5e6;
  --red: #b43737;
  --red-soft: #fff1f1;
  --blue: #286da8;
  --blue-soft: #edf6fc;
  --shadow-sm: 0 1px 2px rgba(24, 45, 36, .05), 0 8px 24px rgba(24, 45, 36, .045);
  --shadow-lg: 0 24px 70px rgba(24, 45, 36, .13);
  --radius: 16px;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(180deg, #edf5f1 0, var(--bg) 300px);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, summary { cursor: pointer; }
[hidden] { display: none !important; }
.ambient { position: fixed; z-index: 0; border-radius: 999px; filter: blur(100px); opacity: .2; pointer-events: none; }
.ambient-one { width: 26rem; height: 26rem; top: -17rem; right: -9rem; background: #b9e5ce; }
.ambient-two { width: 22rem; height: 22rem; bottom: -16rem; left: -10rem; background: #dbe9f5; }
.shell { position: relative; z-index: 1; width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 36px 0 72px; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.05; letter-spacing: -.045em; }
h2 { margin-bottom: 8px; font-size: clamp(1.3rem, 2.5vw, 1.75rem); line-height: 1.15; letter-spacing: -.025em; }
.eyebrow { margin-bottom: 7px; color: var(--green); font-size: .7rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.lede { color: var(--muted); font-size: 1.04rem; line-height: 1.55; }
.muted { color: var(--muted); }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }

.login-layout { min-height: calc(100vh - 108px); display: grid; place-items: center; }
.login-card { width: min(520px, 100%); padding: clamp(30px, 6vw, 52px); border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-lg); }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 30px; border-radius: 13px; color: #fff; background: var(--green); box-shadow: 0 8px 20px rgba(23, 111, 82, .2); font-size: 1.3rem; font-weight: 900; }
.login-card form { margin-top: 32px; }
label { display: grid; gap: 8px; color: #34433c; font-size: .83rem; font-weight: 700; }
input[type="text"], input[type="password"] { width: 100%; min-height: 44px; padding: 0 13px; color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px; outline: none; background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease; }
input::placeholder { color: #9ba7a1; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 111, 82, .11); }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.form-error { min-height: 20px; margin: 11px 0 0; color: var(--red); font-size: .83rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.topbar h1 { font-size: clamp(1.85rem, 4vw, 2.4rem); }
.topbar-actions, .button-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.button { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 10px; color: var(--text); background: transparent; font-weight: 700; line-height: 1; transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, color .15s ease; }
.button:hover:not(:disabled) { box-shadow: 0 3px 10px rgba(25, 50, 40, .08); }
.button:focus-visible, summary:focus-visible, .dialog-close:focus-visible { outline: 3px solid rgba(40, 109, 168, .2); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .46; }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover:not(:disabled) { background: var(--green-hover); }
.button.ghost { border-color: var(--line-strong); background: var(--surface); }
.button.ghost:hover:not(:disabled) { border-color: #aebeb6; background: var(--surface-soft); }
.button.danger { color: var(--red); border-color: #edcccc; background: var(--surface); }
.button.danger:hover:not(:disabled) { border-color: #dfaaaa; background: var(--red-soft); }
.button.full { display: flex; align-items: center; justify-content: center; width: 100%; text-decoration: none; }
.status-pill { display: inline-flex; align-items: center; min-height: 28px; padding: 0 9px; border: 1px solid #bfe0d1; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: .72rem; font-weight: 800; white-space: nowrap; }
.status-pill.neutral { color: #56645e; border-color: var(--line); background: var(--surface-muted); }
.status-pill.warn { color: var(--orange); border-color: #f0d3a7; background: var(--orange-soft); }
.status-pill.error { color: var(--red); border-color: #edc5c5; background: var(--red-soft); }
.notice { margin-bottom: 18px; padding: 13px 15px; border: 1px solid #c7dfef; border-radius: 11px; color: #205b87; background: var(--blue-soft); box-shadow: var(--shadow-sm); }
.notice.error { color: var(--red); border-color: #edc5c5; background: var(--red-soft); }

.hero { min-height: 168px; padding: clamp(25px, 4vw, 38px); display: flex; align-items: center; justify-content: space-between; gap: 30px; overflow: hidden; border-left: 4px solid var(--green); }
.hero h2 { font-size: clamp(1.35rem, 3vw, 2rem); }
.hero p:last-child { max-width: 720px; margin-bottom: 0; color: var(--muted); line-height: 1.6; }
.hero-orbit { position: relative; flex: 0 0 92px; width: 92px; height: 92px; display: grid; place-items: center; border: 1px solid #cde4d8; border-radius: 50%; background: var(--green-soft); }
.hero-orbit::before { content: ""; width: 52px; height: 52px; border: 1px solid #a9d2bf; border-radius: 50%; background: rgba(255,255,255,.5); }
.hero-orbit span { position: absolute; width: 12px; height: 12px; border: 3px solid var(--surface); border-radius: 50%; background: var(--green); box-shadow: 0 3px 8px rgba(23, 111, 82, .25); }
.section-heading { margin: 40px 2px 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading.compact { margin: 0 0 22px; align-items: center; }
.section-tools { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
.section-tools p { margin: 0; font-size: .8rem; }

.profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.profile-card { min-width: 0; padding: 21px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow-sm); }
.profile-card.active { border-color: #91c7ad; box-shadow: 0 0 0 2px rgba(23, 111, 82, .08), var(--shadow-sm); }
.profile-card.active::before { content: "Active connection"; align-self: flex-start; margin: -22px 0 16px -22px; padding: 7px 11px; border-radius: 14px 0 9px 0; color: #fff; background: var(--green); font-size: .65rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.profile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.profile-name { margin: 0; font-size: 1.02rem; line-height: 1.3; }
.account-email { min-height: 22px; margin: 4px 0 17px; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.credit-stat { margin: 0 0 18px; padding: 14px 15px; display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.credit-stat span { color: var(--muted); font-size: .66rem; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
.credit-stat strong { color: var(--text); font-size: 1.15rem; }
.credit-stat small { color: var(--muted); font-size: .7rem; line-height: 1.4; }
.credit-stat.available { border-color: #c3e0d2; background: var(--green-soft); }
.credit-stat.available strong { color: var(--green); }
.credit-stat.empty { border-color: #efd7b2; background: var(--orange-soft); }
.credit-stat.empty strong { color: var(--orange); }
.usage-block { margin: 12px 0; }
.usage-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: #4a5952; font-size: .75rem; }
.usage-head strong { color: var(--text); font-size: .8rem; }
.meter { height: 7px; overflow: hidden; border-radius: 20px; background: var(--surface-muted); }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.meter span.medium { background: #d28127; }
.meter span.high { background: var(--red); }
.reset-text { margin: 6px 0 0; color: var(--muted); font-size: .68rem; line-height: 1.45; }
.usage-empty { min-height: 84px; padding: 16px; display: grid; place-items: center; text-align: center; border: 1px dashed var(--line-strong); border-radius: 11px; color: var(--muted); background: var(--surface-soft); font-size: .78rem; line-height: 1.45; }
.token-stat { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; line-height: 1.5; }
.token-stat strong { color: var(--text); font-size: .84rem; }
.profile-actions { margin-top: auto; padding-top: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.profile-actions .button { min-height: 38px; padding: 0 10px; font-size: .75rem; }
.profile-empty { grid-column: 1 / -1; min-height: 170px; display: grid; place-items: center; align-content: center; gap: 7px; padding: 28px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 15px; background: var(--surface); text-align: center; }
.profile-empty strong { color: var(--text); font-size: 1rem; }

.lower-grid { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.lower-grid > .panel, .audit-panel { padding: 26px; }
.toggle-row { grid-template-columns: 1fr auto; align-items: center; margin-bottom: 20px; }
.toggle-row span { display: grid; gap: 4px; }
.toggle-row small { color: var(--muted); font-weight: 500; }
input[type="checkbox"] { position: relative; width: 42px; height: 23px; margin: 0; appearance: none; border: 1px solid #b9c5bf; border-radius: 999px; outline: none; background: #dbe2de; transition: border-color .2s, background .2s; }
input[type="checkbox"]::after { content: ""; position: absolute; width: 17px; height: 17px; left: 2px; top: 2px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: transform .2s; }
input[type="checkbox"]:checked { border-color: var(--green); background: var(--green); }
input[type="checkbox"]:checked::after { transform: translateX(19px); }
input[type="checkbox"]:focus-visible { box-shadow: 0 0 0 3px rgba(23, 111, 82, .13); }
#alerts-form > label[for="thresholds"] { margin-top: 4px; }
#alert-route { margin: 11px 0 18px; font-size: .75rem; line-height: 1.55; }
.client-list { display: grid; gap: 2px; }
.client-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.client-row strong, .client-row small { display: block; }
.client-row strong { font-size: .88rem; }
.client-row small { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.client-row button { min-height: 34px; padding: 0 10px; }
.add-app { margin-top: 17px; }
.add-app summary { color: var(--green); font-size: .85rem; font-weight: 750; }
.add-app form { margin-top: 18px; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.audit-panel { margin-top: 18px; }
.audit-list { max-height: 320px; overflow: auto; scrollbar-color: #bdcac4 transparent; }
.audit-row { display: grid; grid-template-columns: 170px 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); color: #3f4d46; font-size: .77rem; }
.audit-row:last-child, .client-row:last-child { border-bottom: 0; }
.audit-row time { color: var(--muted); }

dialog { width: min(520px, calc(100% - 30px)); padding: 30px; color: var(--text); border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(25, 38, 32, .34); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); border: 0; border-radius: 9px; background: transparent; font-size: 1.5rem; }
.dialog-close:hover { color: var(--text); background: var(--surface-muted); }
.device-code-wrap { margin: 22px 0; padding: 21px; display: grid; place-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.device-code-wrap span { color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.device-code-wrap code { color: var(--green); font-size: clamp(1.5rem, 7vw, 2.25rem); font-weight: 900; letter-spacing: .08em; }
.token-block { display: block; margin: 20px 0; padding: 15px; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 10px; color: var(--green); background: var(--surface-soft); }
#profile-form { display: grid; gap: 16px; margin-top: 22px; }

@media (max-width: 980px) {
  .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .profile-grid, .lower-grid { grid-template-columns: 1fr; }
  .profile-card { padding: 20px; }
  .profile-card.active::before { margin-left: -21px; }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1200px); padding: 22px 0 52px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; }
  .topbar-actions .button { flex: 1; }
  .topbar-actions .status-pill { width: 100%; justify-content: center; }
  .hero { min-height: 0; }
  .hero-orbit { display: none; }
  .section-heading { align-items: flex-start; flex-direction: column; margin-top: 34px; }
  .section-tools { width: 100%; justify-content: space-between; }
  .password-row, .two-fields { grid-template-columns: 1fr; }
  .password-row .button { width: 100%; }
  .lower-grid > .panel, .audit-panel { padding: 22px 20px; }
  .audit-row { grid-template-columns: 1fr; gap: 3px; }
}

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