:root {
  --ink: #17201f;
  --ink-2: #283432;
  --paper: #f1eee7;
  --card: #fffdf8;
  --line: #d8d3c8;
  --muted: #6f7a76;
  --acid: #c9ff4a;
  --green: #26805a;
  --orange: #d47738;
  --red: #bd4638;
  --shadow: 0 18px 45px rgb(34 44 42 / 10%);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 4vw, 3.4rem); letter-spacing: -.06em; line-height: .98; }
h2 { margin-bottom: .35rem; letter-spacing: -.035em; }
h3 { margin-bottom: .25rem; }
.eyebrow { margin-bottom: .45rem; color: var(--muted); font-size: .67rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.6; }
.small { font-size: .75rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .7rem 1rem;
  border: 0;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 800;
}
.button-primary { background: var(--acid); color: var(--ink); }
.button-dark { background: var(--ink); color: white; }
.button-small { min-height: 34px; padding: .45rem .7rem; background: var(--ink); color: white; font-size: .75rem; }
.text-link { color: var(--green); font-size: .78rem; font-weight: 800; text-decoration: none; }

.alert, .preview-banner { margin-bottom: 1rem; padding: .85rem 1rem; border-radius: 9px; font-size: .82rem; font-weight: 700; }
.preview-banner { background: #e7ddc8; color: #624e26; border: 1px solid #d4c39f; }
.alert-success { background: #e4f5e9; color: #225e3e; border: 1px solid #add8bd; }
.alert-error { background: #fae8e4; color: #8b3027; border: 1px solid #edb9b0; }

/* Login */
.login-page { background: var(--ink); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.2fr .8fr; }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(2.5rem, 6vw, 7rem); overflow: hidden; color: white; }
.login-brand::before {
  content: "";
  position: absolute;
  width: 54vw;
  height: 54vw;
  right: -34vw;
  bottom: -26vw;
  border: 7vw solid var(--acid);
  border-radius: 50%;
  opacity: .92;
}
.login-brand > * { position: relative; z-index: 1; }
.brand-mark { font-size: 1.25rem; font-weight: 950; letter-spacing: -.055em; }
.login-copy { max-width: 860px; margin: auto 0; padding: 5vh 0; }
.login-brand .eyebrow { color: #9bb0aa; }
.login-brand h1 { display: grid; gap: .08em; max-width: 860px; font-size: clamp(4rem, 7vw, 8rem); line-height: .86; }
.login-brand h1 span:last-child { color: var(--acid); }
.login-description { max-width: 520px; margin: 2rem 0 0; color: #b9c6c2; font-size: clamp(.85rem, 1.1vw, 1.05rem); letter-spacing: .02em; }
.login-node-list { display: flex; gap: .7rem; font-size: .8rem; color: #c7d2ce; }
.login-node-list span { padding: .65rem .8rem; border: 1px solid #45514f; border-radius: 8px; background: rgb(255 255 255 / 3%); }
.dot { display: inline-block; width: .5rem; height: .5rem; margin-right: .35rem; border-radius: 50%; }
.dot-green { background: var(--acid); box-shadow: 0 0 0 4px rgb(201 255 74 / 13%); }
.login-card { display: flex; flex-direction: column; justify-content: center; padding: clamp(2rem, 7vw, 7rem); background: var(--paper); }
.login-card h2 { font-size: 2.2rem; }
.stack-form { display: grid; gap: 1rem; margin-top: 2rem; }
.stack-form label, .download-card label { display: grid; gap: .45rem; color: var(--muted); font-size: .75rem; font-weight: 750; }
.stack-form input, .download-card input, .inline-settings input, .compact-form input {
  width: 100%;
  padding: .82rem .9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  outline: none;
}
input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgb(23 32 31 / 8%); }
.login-foot { margin-top: 1.25rem; color: var(--muted); font-size: .72rem; }

/* Admin shell */
.console-shell { width: min(1320px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.4rem); }
.console-topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.console-brand { font-size: 1.08rem; font-weight: 950; letter-spacing: -.045em; text-decoration: none; }
.console-actions { display: flex; align-items: center; gap: .75rem; }
.console-actions .button { min-height: 36px; padding: .55rem .8rem; font-size: .72rem; }
.console-actions form { margin: 0; }
.console-logout { padding: .45rem; border: 0; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 750; }
.console-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin: clamp(1.8rem, 5vw, 4rem) 0 1.5rem; }
.console-heading .muted { max-width: 520px; margin: .85rem 0 0; font-size: .85rem; }
.console-period { min-width: 145px; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--muted); font-size: .66rem; line-height: 1.55; }
.console-period span, .console-period strong { display: block; }
.console-period strong { margin-top: .22rem; color: var(--ink); font-size: .72rem; }
.overview-account-list { display: grid; gap: .45rem; }
.overview-account-labels, .overview-account-row { display: grid; grid-template-columns: 1.15fr 1fr 1fr .68fr; gap: .85rem; align-items: center; }
.overview-account-labels { padding: 0 .8rem .2rem; color: var(--muted); font-size: .59rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.overview-account-row { padding: .8rem; border-radius: 9px; background: #f2f0ea; }
.overview-account-row.is-disabled { opacity: .58; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 190px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.6rem 1rem; background: var(--ink); color: white; }
.sidebar-brand { margin: 0 .45rem 2.7rem; font-size: 1.08rem; font-weight: 950; letter-spacing: -.045em; text-decoration: none; white-space: nowrap; }
.sidebar-label { margin: 0 .45rem .6rem; color: #71827e; font-size: .58rem; font-weight: 800; letter-spacing: .16em; }
.sidebar-nav { display: grid; gap: .28rem; }
.sidebar-nav a { padding: .7rem .75rem; border-radius: 8px; color: #b7c3bf; font-size: .8rem; font-weight: 720; text-decoration: none; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: var(--acid); color: var(--ink); }
.sidebar-user { margin-top: auto; padding: .85rem; border-top: 1px solid #34413e; }
.sidebar-user > span { display: block; color: #71827e; font-size: .55rem; letter-spacing: .16em; }
.sidebar-user strong { display: block; margin: .25rem 0 .5rem; font-size: .82rem; }
.sidebar-user form { margin: 0; }
.sidebar-user button, .member-topbar button { padding: 0; border: 0; background: transparent; color: #8fa09b; font-size: .68rem; }
.content { width: min(1320px, 100%); padding: clamp(1.35rem, 3vw, 2.6rem); }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin: 1rem 0 1.5rem; }
.header-meta { text-align: right; color: var(--muted); font-size: .7rem; line-height: 1.55; }

.metric-grid { display: grid; grid-template-columns: 1.35fr .75fr .9fr; gap: .75rem; margin-bottom: .75rem; }
.metric { min-height: 132px; display: flex; flex-direction: column; justify-content: space-between; padding: 1.15rem; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.metric span, .metric small { color: var(--muted); font-size: .68rem; }
.metric strong { font-size: clamp(1.65rem, 3vw, 2.7rem); letter-spacing: -.06em; }
.metric-accent { border-color: var(--acid); background: var(--acid); }
.metric-accent span, .metric-accent small { color: #455321; }
.metric-dark { border-color: var(--ink); background: var(--ink); color: white; }
.metric-dark strong { font-size: 1.25rem; letter-spacing: -.025em; }
.metric-dark small { color: var(--acid); }

.panel { padding: 1.15rem; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.panel-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1rem; }
.panel-heading h2 { margin-bottom: 0; }
.panel-note { color: var(--muted); font-size: .68rem; }
.account-list { display: grid; gap: .45rem; }
.account-row { position: relative; display: grid; grid-template-columns: 1.15fr 1fr 1fr .68fr 48px; gap: .85rem; align-items: center; padding: .8rem; border-radius: 9px; background: #f2f0ea; }
.account-row.is-disabled { opacity: .58; }
.account-identity { min-width: 0; display: flex; gap: .65rem; align-items: center; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: var(--ink); color: var(--acid); font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.account-identity strong, .account-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-identity strong { font-size: .78rem; }
.account-identity small { margin-top: .18rem; color: var(--muted); font-size: .62rem; }
.usage-cell > div { display: flex; justify-content: space-between; gap: .4rem; font-size: .62rem; }
.usage-cell span { color: var(--muted); font-weight: 800; }
.usage-cell b { font-size: .62rem; white-space: nowrap; }
progress { width: 100%; height: 7px; overflow: hidden; border: 0; border-radius: 10px; background: #dedbd3; }
progress::-webkit-progress-bar { background: #dedbd3; border-radius: 10px; }
progress::-webkit-progress-value { background: var(--ink); border-radius: 10px; }
progress::-moz-progress-bar { background: var(--ink); border-radius: 10px; }
.usage-cell progress { margin-top: .42rem; }
.account-status { display: grid; justify-items: start; gap: .28rem; }
.account-status small { color: var(--muted); font-size: .6rem; }
.status { display: inline-flex; align-items: center; padding: .28rem .48rem; border-radius: 999px; font-size: .61rem; font-weight: 850; }
.status-ok { background: #dcefe3; color: #246446; }
.status-warn { background: #f8e8d6; color: #975321; }
.status-danger { background: #f6deda; color: #94362c; }
.status-muted { background: #e5e4df; color: #6d7471; }
.account-actions { position: relative; }
.account-actions summary { list-style: none; padding: .4rem; color: var(--muted); font-size: .68rem; font-weight: 800; cursor: pointer; }
.account-actions summary::-webkit-details-marker { display: none; }
.action-popover { position: absolute; z-index: 10; top: 36px; right: 0; width: 230px; padding: .85rem; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow); }
.compact-form { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; margin-top: .7rem; }
.compact-form label { display: grid; gap: .3rem; color: var(--muted); font-size: .62rem; font-weight: 750; }
.compact-form input { padding: .55rem; }
.compact-form .check-line { grid-column: 1 / -1; display: flex; align-items: center; gap: .4rem; }
.compact-form .check-line input { width: auto; }
.compact-form button { grid-column: 1 / -1; }

.node-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-top: .75rem; }
.node-card { padding: 1.15rem; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.node-title { display: flex; justify-content: space-between; align-items: start; }
.node-number { display: flex; align-items: end; gap: .35rem; margin: 1rem 0 .55rem; }
.node-number strong { font-size: 1.8rem; letter-spacing: -.05em; }
.node-number span { margin-bottom: .25rem; color: var(--muted); font-size: .7rem; }
.node-facts { display: flex; justify-content: space-between; gap: .5rem; margin: .75rem 0; color: var(--muted); font-size: .64rem; }
.node-card > small { color: var(--muted); font-size: .6rem; }
.node-traffic .node-number { margin: .55rem 0 .2rem; }
.provider-traffic { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.provider-traffic .node-number { margin-top: .55rem; }
.provider-traffic > small { color: var(--muted); font-size: .6rem; }
.settings-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: .75rem; margin-top: .75rem; }
.settings-card { min-height: 190px; }
.inline-settings { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: .55rem; margin-top: 1rem; }
.inline-settings input { min-width: 0; }

/* Member */
.member-page { background: #d8d3c9; }
.member-topbar { height: 68px; display: flex; justify-content: space-between; align-items: center; padding: 0 clamp(1rem, 5vw, 4rem); background: var(--ink); color: white; }
.member-brand { font-weight: 950; letter-spacing: -.06em; text-decoration: none; }
.member-topbar > div { display: flex; align-items: center; gap: .7rem; font-size: .72rem; }
.member-topbar form { display: inline; }
.member-shell { width: min(1020px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3.5rem) 0; }
.member-hero { position: relative; overflow: hidden; padding: clamp(1.4rem, 4vw, 2.6rem); border-radius: 18px; background: var(--paper); }
.member-hero::after { content: ""; position: absolute; width: 260px; height: 260px; right: -90px; bottom: -150px; border: 48px solid var(--acid); border-radius: 50%; }
.member-hero > * { position: relative; z-index: 1; }
.member-hero h1 { font-size: clamp(2.3rem, 6vw, 5rem); }
.member-total { display: flex; align-items: end; gap: .35rem; margin: 2rem 0 .75rem; }
.member-total strong { font-size: clamp(2rem, 5vw, 3.7rem); letter-spacing: -.06em; }
.member-total span { margin-bottom: .4rem; color: var(--muted); }
.member-usage-grid, .member-actions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-top: .75rem; }
.member-usage-card { padding: 1.3rem; border-radius: 14px; background: var(--card); }
.member-usage-card h2 { font-size: 2rem; }
.member-usage-card span, .member-usage-card small { color: var(--muted); font-size: .68rem; }
.member-usage-card progress { margin: 1.2rem 0 .65rem; }
.accent-card { background: var(--acid); }
.accent-card progress::-webkit-progress-bar { background: #afdc42; }
.download-card .button { margin: .5rem 0 1rem; }
.download-card label { margin-top: .4rem; }
.download-card input { font-size: .68rem; }
.simple-node { display: flex; justify-content: space-between; padding: .8rem 0; border-bottom: 1px solid var(--line); font-size: .78rem; }
.simple-node:last-child { border-bottom: 0; }
.online { color: var(--green); }
.offline { color: var(--red); }
.password-card { margin-top: .75rem; }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 44vh; padding: 2rem; }
  .login-copy { margin: 2.5rem 0; padding: 0; }
  .login-brand h1 { font-size: clamp(3.2rem, 14vw, 5.5rem); }
  .login-description { margin-top: 1.3rem; }
  .login-brand::before { width: 78vw; height: 78vw; right: -48vw; bottom: -42vw; border-width: 11vw; }
  .login-card { padding: 2rem; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; gap: .75rem; padding: .8rem 1rem; }
  .sidebar-brand { margin: 0 auto 0 0; }
  .sidebar-label, .sidebar-nav, .sidebar-user > span, .sidebar-user > strong { display: none; }
  .sidebar-user { margin: 0; padding: 0; border: 0; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-dark { grid-column: 1 / -1; }
  .overview-account-labels { display: none; }
  .overview-account-row { grid-template-columns: 1fr 1fr; }
  .overview-account-row .account-identity { grid-column: 1 / 2; }
  .overview-account-row .usage-cell { grid-column: 1 / -1; }
  .overview-account-row .account-status { grid-column: 2 / 3; grid-row: 1; justify-self: end; }
  .account-row { grid-template-columns: 1fr 1fr 48px; }
  .account-identity { grid-column: 1 / 2; }
  .usage-cell { grid-column: 1 / -1; }
  .account-status { grid-column: 2 / 3; grid-row: 1; justify-self: end; }
  .account-actions { grid-column: 3 / 4; grid-row: 1; }
  .inline-settings { grid-template-columns: 1fr 1fr; }
  .inline-settings .button { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .console-shell { padding: 1rem; }
  .console-topbar { align-items: flex-start; }
  .console-actions { gap: .35rem; }
  .console-actions .button { padding: .5rem .6rem; }
  .console-heading { align-items: start; flex-direction: column; margin-top: 2rem; }
  .console-period { width: 100%; }
  .content { padding: 1rem; }
  .page-header { align-items: start; }
  .metric-grid, .node-grid, .settings-grid, .member-usage-grid, .member-actions-grid { grid-template-columns: 1fr; }
  .metric-dark { grid-column: auto; }
  .panel-heading { align-items: start; flex-direction: column; }
  .account-row { grid-template-columns: 1fr 42px; }
  .account-identity { grid-column: 1; }
  .account-status { grid-column: 1; grid-row: auto; justify-self: start; display: flex; align-items: center; }
  .account-actions { grid-column: 2; grid-row: 1; }
  .usage-cell { grid-column: 1 / -1; }
  .action-popover { right: 0; width: min(260px, calc(100vw - 2rem)); }
  .overview-account-row { grid-template-columns: 1fr; }
  .overview-account-row .account-identity, .overview-account-row .usage-cell, .overview-account-row .account-status { grid-column: auto; grid-row: auto; }
  .overview-account-row .account-status { justify-self: start; display: flex; align-items: center; }
  .node-facts { flex-direction: column; }
  .inline-settings { grid-template-columns: 1fr; }
  .inline-settings .button { grid-column: auto; }
  .member-shell { width: min(100% - 1rem, 1020px); }
}
