:root {
  --ink: #102b33;
  --ink-soft: #526970;
  --paper: #f4f8f7;
  --surface: #ffffff;
  --line: #ccd9d6;
  --signal: #17a993;
  --signal-dark: #0c7769;
  --coral: #d85f4b;
  --amber: #c48824;
  --shadow: 0 18px 50px rgba(16, 43, 51, .09);
  --radius: 10px;
  --body-font: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --data-font: "SFMono-Regular", "Roboto Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body-font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--data-font); font-size: .88em; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.035em; line-height: 1.12; }
h1 { font-size: clamp(2.2rem, 5vw, 4.8rem); }
h2 { font-size: clamp(1.45rem, 2.5vw, 2.1rem); }
h3 { font-size: 1.25rem; }
small { color: var(--ink-soft); display: block; }

:focus-visible { outline: 3px solid rgba(23, 169, 147, .36); outline-offset: 3px; }

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: .72rem 1rem;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.button-primary { background: var(--signal); color: white; }
.button-primary:hover { background: var(--signal-dark); }
.button-secondary { background: var(--ink); color: white; }
.button-secondary:hover { background: #183b45; }
.button-ghost { border-color: var(--line); background: transparent; color: var(--ink); }
.button-light { background: white; color: var(--ink); }
.quiet-link { color: var(--ink-soft); display: inline-block; font-size: .9rem; margin-top: 1.25rem; text-decoration: underline; text-underline-offset: 4px; }
.text-button { background: none; border: 0; color: var(--signal-dark); cursor: pointer; font-weight: 700; padding: .3rem; }
.text-button.danger { color: var(--coral); }

.brand-lockup { align-items: center; display: inline-flex; font-size: 1.05rem; font-weight: 800; gap: .7rem; letter-spacing: -.02em; }
.brand-lockup em { border-left: 1px solid var(--line); color: var(--ink-soft); font-size: .78rem; font-style: normal; font-weight: 600; margin-left: .25rem; padding-left: .9rem; }
.brand-mark { align-items: center; background: var(--ink); border-radius: 50%; color: white; display: inline-flex; font-family: var(--data-font); font-size: .72rem; height: 36px; justify-content: center; letter-spacing: -.08em; width: 36px; }
.eyebrow, .section-label { color: var(--signal-dark); font-family: var(--data-font); font-size: .72rem; font-weight: 800; letter-spacing: .14em; margin-bottom: .6rem; text-transform: uppercase; }
.lede { color: var(--ink-soft); font-size: 1.05rem; max-width: 36rem; }

.login-shell { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr); min-height: 100vh; }
.login-intro {
  background:
    linear-gradient(rgba(255,255,255,.54) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.54) 1px, transparent 1px),
    #cfe6e2;
  background-size: 42px 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(2rem, 6vw, 6rem);
  position: relative;
}
.login-intro::after { border: 38px solid rgba(23,169,147,.14); border-radius: 50%; bottom: -13vw; content: ""; height: 32vw; position: absolute; right: -10vw; width: 32vw; }
.login-intro h1 { margin-bottom: 1.25rem; max-width: 8ch; }
.ticket-rule { display: flex; gap: 1.2rem; position: relative; width: min(460px, 75%); z-index: 1; }
.ticket-rule::before { border-top: 2px dashed var(--signal-dark); content: ""; left: 0; position: absolute; right: 0; top: 50%; }
.ticket-rule span { background: var(--paper); border: 2px solid var(--signal-dark); border-radius: 50%; height: 17px; position: relative; width: 17px; }
.login-panel { align-self: center; margin: auto; padding: 3rem; width: min(470px, 100%); }
.panel-heading { margin-bottom: 2rem; }
.panel-heading h2 { font-size: 2.2rem; }
.stack-form, .drawer-form, .form-card { display: grid; gap: 1rem; }
label > span { color: var(--ink-soft); display: block; font-size: .78rem; font-weight: 700; margin-bottom: .35rem; }
input, select {
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 46px;
  padding: .72rem .8rem;
  width: 100%;
}
input:hover, select:hover { border-color: #96aaa6; }

.alert { border-left: 4px solid var(--signal); margin: 1rem 0; padding: .8rem 1rem; background: #e5f4f1; }
.alert-error { background: #fae9e6; border-color: var(--coral); color: #7f2d22; }
.alert-warning { background: #fff5dd; border-color: var(--amber); color: #684814; }
.alert-success { background: #e5f4f1; border-color: var(--signal); }

.app-shell { min-height: 100vh; }
.topbar { align-items: center; background: rgba(244,248,247,.94); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; min-height: 76px; padding: .9rem clamp(1rem, 4vw, 4rem); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(16px); }
.topbar-user { align-items: center; display: flex; gap: 1.2rem; text-align: right; }
.topbar-user small { font-size: .72rem; }

.customer-main { display: grid; gap: 2rem; margin: 0 auto; max-width: 1180px; padding: clamp(1.5rem, 4vw, 4rem); }
.quota-ticket {
  background: var(--ink);
  color: white;
  display: grid;
  gap: 2rem;
  grid-template-columns: 1fr auto;
  overflow: hidden;
  padding: clamp(1.6rem, 4vw, 3.4rem);
  position: relative;
  box-shadow: var(--shadow);
}
.quota-ticket::before, .quota-ticket::after { background: var(--paper); border-radius: 50%; content: ""; height: 34px; position: absolute; top: calc(50% - 17px); width: 34px; }
.quota-ticket::before { left: -17px; }
.quota-ticket::after { right: -17px; }
.ticket-copy h1 { font-size: clamp(2rem, 4vw, 4.4rem); margin-bottom: .7rem; }
.ticket-copy h1 strong { color: #67dfca; font-family: var(--data-font); }
.ticket-copy p { color: #b8cbc8; }
.quota-stamp { align-self: start; border: 1px solid currentColor; color: #67dfca; font-family: var(--data-font); font-size: .72rem; font-weight: 800; letter-spacing: .12em; padding: .55rem .75rem; text-transform: uppercase; transform: rotate(2deg); }
.stamp-paused { color: #ff9a89; }
.punch-track { border-top: 1px dashed #547078; display: flex; gap: clamp(.25rem, 1vw, .75rem); grid-column: 1 / -1; padding: 1.5rem 0 .2rem; }
.punch { background: transparent; border: 1px solid #6c858b; border-radius: 50%; height: clamp(10px, 1.5vw, 16px); width: clamp(10px, 1.5vw, 16px); }
.punch.used { background: var(--signal); border-color: var(--signal); box-shadow: 0 0 0 4px rgba(23,169,147,.12); }
.quota-meta { display: grid; gap: 1px; grid-column: 1 / -1; grid-template-columns: repeat(3, 1fr); margin: 0; background: #38525a; }
.quota-meta div { background: var(--ink); padding: 1rem 0; }
.quota-meta dt { color: #90a9ad; font-size: .72rem; }
.quota-meta dd { font-family: var(--data-font); margin: .25rem 0 0; }

.download-workbench, .history-panel, .admin-section { background: var(--surface); border: 1px solid var(--line); padding: clamp(1.25rem, 3vw, 2rem); }
.section-heading { align-items: end; display: flex; gap: 2rem; justify-content: space-between; margin-bottom: 1.5rem; }
.section-heading h2 { margin-bottom: 0; }
.section-heading > p { color: var(--ink-soft); margin-bottom: .2rem; max-width: 36rem; }
.request-form { align-items: stretch; display: grid; gap: .75rem; grid-template-columns: 1fr auto; }
.input-command { border: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr; }
.input-command > span { align-items: center; background: #e8efed; border-right: 1px solid var(--line); display: flex; font-family: var(--data-font); margin: 0; padding: 0 1rem; }
.input-command input { border: 0; border-radius: 0; }
.download-result { align-items: center; background: #e5f4f1; border-left: 5px solid var(--signal); display: flex; justify-content: space-between; margin-bottom: 1rem; padding: 1rem; }
.download-result > div { align-items: center; display: grid; gap: .15rem; grid-template-columns: auto 1fr; }
.download-result small { grid-column: 2; }
.status-dot { background: var(--signal); border-radius: 50%; display: inline-block; height: 10px; margin-right: .55rem; width: 10px; box-shadow: 0 0 0 4px rgba(23,169,147,.15); }
.status-dot.muted { background: #9cafab; box-shadow: none; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; min-width: 650px; width: 100%; }
th { color: var(--ink-soft); font-size: .7rem; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
th, td { border-bottom: 1px solid #e3eae8; padding: .85rem .7rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.empty-cell { color: var(--ink-soft); padding: 2rem; text-align: center; }
.status { border: 1px solid currentColor; display: inline-block; font-size: .72rem; font-weight: 700; padding: .18rem .48rem; white-space: nowrap; }
.status-succeeded, .status-active { color: var(--signal-dark); }
.status-failed, .status-suspended { color: var(--coral); }
.status-reserved { color: var(--amber); }

.admin-nav { background: var(--surface); border-bottom: 1px solid var(--line); display: flex; gap: 1.4rem; overflow-x: auto; padding: .65rem clamp(1rem, 4vw, 4rem); position: sticky; top: 76px; z-index: 15; }
.admin-nav a { color: var(--ink-soft); font-size: .8rem; font-weight: 700; padding: .4rem 0; }
.admin-nav a:hover { color: var(--signal-dark); }
.admin-main { display: grid; gap: 1.5rem; margin: 0 auto; max-width: 1500px; padding: clamp(1.2rem, 3vw, 3rem); }
.overview-grid { display: grid; gap: 1rem; grid-template-columns: repeat(4, 1fr); }
.metric-card { background: white; border: 1px solid var(--line); min-height: 160px; padding: 1.3rem; position: relative; }
.metric-card span { color: var(--ink-soft); font-size: .78rem; font-weight: 700; }
.metric-card strong { display: block; font-family: var(--data-font); font-size: 2.8rem; line-height: 1; margin: 1.25rem 0 .55rem; }
.metric-card small { font-size: .72rem; }
.metric-primary { background: var(--signal); border-color: var(--signal); color: white; }
.metric-primary span, .metric-primary small { color: #d9fffa; }
.action-drawer { position: relative; }
.action-drawer summary { list-style: none; }
.action-drawer summary::-webkit-details-marker { display: none; }
.drawer-form { background: white; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 1.25rem; position: absolute; right: 0; top: calc(100% + .6rem); width: min(420px, 90vw); z-index: 10; }
.admin-table td:first-child strong, .admin-table td:first-child small { display: block; white-space: nowrap; }
.row-actions { align-items: center; display: flex; gap: .35rem; min-width: 230px; }
.row-actions form { align-items: center; display: flex; }
.tiny-input { min-height: 32px; padding: .25rem; width: 55px; }
.mini-meter { background: #e3eae8; height: 5px; margin-bottom: .35rem; min-width: 80px; overflow: hidden; }
.mini-meter span { background: var(--signal); display: block; height: 100%; }
.two-column-section { display: grid; gap: clamp(1.5rem, 4vw, 4rem); grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); }
.plan-list, .upstream-list { display: grid; gap: .75rem; }
.plan-card { align-items: center; border: 1px solid var(--line); display: flex; justify-content: space-between; padding: 1rem; }
.plan-card > div strong, .plan-card > div small { display: block; }
.plan-card dl { display: flex; gap: 2rem; margin: 0; }
.plan-card dt { color: var(--ink-soft); font-size: .68rem; }
.plan-card dd { font-family: var(--data-font); margin: .1rem 0 0; }
.form-card { align-self: start; background: #edf3f1; border-top: 5px solid var(--ink); padding: 1.3rem; }
.form-card h3 { margin-bottom: .4rem; }
.form-grid { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.upstream-row { align-items: center; border-bottom: 1px solid var(--line); display: grid; gap: .8rem; grid-template-columns: auto 1fr auto auto; padding: 1rem .25rem; }
.upstream-row div:nth-child(3) { text-align: right; }
.empty-state { border: 1px dashed var(--line); color: var(--ink-soft); padding: 2rem; text-align: center; }
.secret-reveal { align-items: center; background: var(--ink); color: white; display: grid; gap: 2rem; grid-template-columns: 1fr minmax(320px, .8fr); padding: 1.5rem; }
.secret-reveal p { color: #b8cbc8; margin-bottom: 0; }
.secret-value { align-items: center; background: #1e3c45; display: flex; gap: 1rem; justify-content: space-between; padding: 1rem; }
.secret-value code { overflow-wrap: anywhere; }
.security-section > div > p:last-child { color: var(--ink-soft); max-width: 44rem; }
.compact-form { max-width: 520px; width: 100%; }

.error-shell { margin: 15vh auto; max-width: 640px; padding: 2rem; }
.error-code { color: var(--signal); font-family: var(--data-font); font-size: 5rem; font-weight: 800; line-height: 1; margin-bottom: 1rem; }

@media (max-width: 980px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-intro { min-height: 48vh; padding: 2rem; }
  .login-panel { padding: 2rem; }
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .two-column-section { grid-template-columns: 1fr; }
  .secret-reveal { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .topbar { min-height: 66px; }
  .topbar-user > span { display: none; }
  .brand-lockup em { display: none; }
  .admin-nav { top: 66px; }
  .quota-ticket { grid-template-columns: 1fr; }
  .quota-stamp { justify-self: start; }
  .quota-meta { grid-template-columns: 1fr; }
  .request-form { grid-template-columns: 1fr; }
  .input-command { grid-template-columns: 58px 1fr; }
  .download-result { align-items: stretch; flex-direction: column; gap: 1rem; }
  .overview-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 135px; }
  .metric-card strong { font-size: 2.2rem; }
  .section-heading { align-items: start; flex-direction: column; gap: .8rem; }
  .action-drawer { width: 100%; }
  .action-drawer summary { width: 100%; }
  .drawer-form { left: 0; right: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .secret-value { align-items: stretch; flex-direction: column; }
}

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

