:root {
  color-scheme: light;
  --ink: #15171a;
  --muted: #667085;
  --paper: #f5f7fa;
  --panel: #ffffff;
  --line: #d9e0ea;
  --signal: #2f7dff;
  --signal-ink: #ffffff;
  --success: #1c8c5a;
  --warn: #c77700;
  --danger: #c63d3d;
  --shadow: 0 24px 70px rgb(33 43 54 / 0.12);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgb(47 125 255 / 0.08), transparent 34%),
    linear-gradient(225deg, rgb(28 140 90 / 0.08), transparent 28%),
    var(--paper);
  color: var(--ink);
}

.client-body {
  background: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .client-body {
    background: var(--paper);
  }
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  background: var(--signal);
  color: var(--signal-ink);
  font-weight: 760;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
  white-space: nowrap;
}

button:hover {
  box-shadow: 0 12px 26px rgb(47 125 255 / 0.25);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

button.secondary {
  background: #eef3fb;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.danger-button {
  color: #9f2b2b;
  background: rgb(198 61 61 / 0.1);
  border-color: rgb(198 61 61 / 0.22);
}

button.danger-button:hover {
  box-shadow: 0 12px 26px rgb(198 61 61 / 0.16);
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 680;
}

label span,
legend {
  color: #344054;
  font-size: 0.9rem;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  background: #fbfcfe;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 4px rgb(47 125 255 / 0.14);
}

fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

fieldset label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
}

fieldset input {
  width: auto;
  min-height: auto;
}

.page {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.panel {
  border: 1px solid rgb(217 224 234 / 0.9);
  border-radius: 22px;
  background: rgb(255 255 255 / 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--signal);
  font-size: 0.78rem;
  font-weight: 820;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero {
  min-height: min(760px, calc(100dvh - 56px));
  padding: clamp(24px, 5vw, 70px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  align-items: center;
  gap: clamp(24px, 5vw, 76px);
  overflow: hidden;
}

.hero h1 {
  max-width: 740px;
  margin: 0;
  font-size: clamp(3rem, 8vw, 7.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.lead {
  max-width: 54ch;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.22rem);
  line-height: 1.7;
}

.login-box,
.job-form {
  display: grid;
  gap: 16px;
}

.login-box {
  padding: 22px;
  border-radius: 18px;
  background: #f9fbff;
  border: 1px solid var(--line);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.account-panel {
  padding: 22px;
  display: grid;
  gap: 22px;
}

.account-panel h2,
.task-panel h2,
.jobs-panel h2,
.log-panel h2,
.admin-card h2,
.table-panel h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
}

.quota-ring {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 50%, #ffffff 56%, transparent 57%),
    conic-gradient(var(--signal), #b9d3ff);
}

.quota-ring strong {
  font-size: 4.2rem;
  line-height: 1;
}

.quota-ring span {
  color: var(--muted);
}

.compact-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.compact-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.compact-list dt,
.compact-list dd {
  margin: 0;
}

.compact-list dt {
  color: var(--muted);
}

.task-panel,
.jobs-panel {
  grid-column: 2;
  padding: 24px;
}

.field-error {
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

input.input-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgb(198 61 61 / 0.12);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.job-form {
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.32fr) minmax(220px, 0.42fr);
  align-items: end;
}

.job-form .wide,
.notice,
.actions {
  grid-column: 1 / -1;
}

.notice {
  border-radius: 14px;
  padding: 13px 14px;
  background: #fff8eb;
  color: #7a4b00;
  border: 1px solid #f1d29b;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.result-box,
.status-block,
.copy-box {
  margin-top: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f7f9fd;
  padding: 16px;
  overflow: auto;
}

.jobs-list,
.artifact-list,
.table-list {
  display: grid;
  gap: 12px;
}

.job-card,
.artifact-card,
.table-row {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fbfcff;
  display: grid;
  gap: 8px;
}

.job-card {
  min-width: 0;
  overflow: hidden;
  white-space: normal;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.job-card:hover {
  border-color: rgb(47 125 255 / 0.48);
}

.job-card:focus-visible {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgb(47 125 255 / 0.22);
}

.job-source-link {
  display: inline-block;
  justify-self: start;
  width: fit-content;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--signal);
  font-size: 0.8rem;
  font-weight: 650;
  line-height: 1.45;
  text-decoration-color: rgb(47 125 255 / 0.34);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-source-link:hover,
.job-source-link:focus-visible {
  text-decoration-color: currentColor;
}

.job-source-link:focus-visible {
  border-radius: 4px;
  outline: 3px solid rgb(47 125 255 / 0.22);
  outline-offset: 2px;
}

.job-issue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.job-issue-button {
  min-height: 34px;
  padding: 6px 10px;
  border-color: rgb(47 125 255 / 0.28);
  background: rgb(47 125 255 / 0.08);
  color: var(--signal);
  font-size: 0.78rem;
  font-weight: 760;
}

.job-issue-button.warning {
  border-color: rgb(190 122 24 / 0.32);
  background: rgb(219 146 35 / 0.1);
  color: #8a5300;
}

.job-issue-button.danger {
  border-color: rgb(198 61 61 / 0.28);
  background: rgb(198 61 61 / 0.08);
  color: var(--danger);
}

.artifact-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.artifact-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.artifact-copy strong,
.delivery-note,
.delivery-error {
  overflow-wrap: anywhere;
}

.delivery-note {
  color: var(--success);
  font-size: 0.88rem;
}

.delivery-error {
  color: var(--danger);
  font-size: 0.88rem;
}

.artifact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  padding: 0 18px;
  background: var(--signal);
  color: var(--signal-ink);
  font-weight: 760;
  text-decoration: none;
  white-space: nowrap;
}

.button-link:focus-visible {
  outline: 3px solid rgb(47 125 255 / 0.34);
  outline-offset: 2px;
}

.job-top,
.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.job-top strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.job-status-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.job-delivery-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 760;
  white-space: nowrap;
}

.job-delivery-badge.pending {
  color: #8a5300;
  border-color: rgb(190 122 24 / 0.28);
  background: rgb(219 146 35 / 0.1);
}

.job-delivery-badge.delivered {
  color: var(--success);
  border-color: rgb(28 140 90 / 0.26);
  background: rgb(28 140 90 / 0.1);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  width: fit-content;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef3fb;
  color: #344054;
  font-size: 0.82rem;
  font-weight: 750;
}

.badge.completed {
  background: rgb(28 140 90 / 0.13);
  color: var(--success);
}

.badge.failed {
  background: rgb(198 61 61 / 0.12);
  color: var(--danger);
}

.badge.quota-completed {
  background: rgb(47 125 255 / 0.13);
  color: var(--signal);
}

.badge.running,
.badge.recovering {
  background: rgb(47 125 255 / 0.12);
  color: var(--signal);
}

.muted {
  color: var(--muted);
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
}

#jobLog {
  min-height: 132px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  border-radius: 16px;
  padding: 16px;
  background: #101418;
  color: #d5f7e8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
}

.admin-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.admin-nav {
  position: sticky;
  top: 24px;
  padding: 22px;
  display: grid;
  gap: 14px;
}

.admin-nav h1 {
  margin: 0 0 8px;
  font-size: 2.4rem;
  line-height: 1;
}

.admin-main {
  display: grid;
  gap: 22px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.admin-grid-single {
  grid-template-columns: minmax(0, 720px);
}

.admin-card,
.table-panel {
  padding: 22px;
}

.admin-card {
  display: grid;
  gap: 14px;
}

.copy-box {
  min-height: 88px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
}

.table-row strong {
  word-break: break-word;
}

.table-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #eef2f7;
    --muted: #a9b4c4;
    --paper: #11161d;
    --panel: #171d26;
    --line: #2b3442;
    --shadow: 0 24px 70px rgb(0 0 0 / 0.34);
  }

  body {
    background:
      linear-gradient(135deg, rgb(47 125 255 / 0.16), transparent 34%),
      linear-gradient(225deg, rgb(28 140 90 / 0.12), transparent 28%),
      var(--paper);
  }

  .panel,
  .login-box,
  .job-card,
  .artifact-card,
  .table-row {
    background: rgb(23 29 38 / 0.88);
  }

  input,
  select,
  .result-box,
  .status-block,
  .copy-box {
    background: #121820;
    color: var(--ink);
  }

  label span,
  legend {
    color: #d7dee8;
  }

  button.secondary {
    background: #1d2530;
    color: var(--ink);
  }

  .notification-button.is-enabled {
    color: #86e6b8;
    border-color: rgb(83 211 151 / 0.3);
    background: rgb(28 140 90 / 0.16);
  }

  .notification-sound-select {
    background-color: #1d2530;
    color: var(--ink);
  }

  .notice {
    background: rgb(199 119 0 / 0.12);
    color: #ffd28a;
    border-color: rgb(199 119 0 / 0.35);
  }

  .quota-ring {
    background:
      radial-gradient(circle at 50% 50%, #171d26 56%, transparent 57%),
      conic-gradient(var(--signal), #294466);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 980px) {
  .page {
    padding: 16px;
  }

  .hero,
  .workspace,
  .admin-shell,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero h1 {
    font-size: clamp(2.8rem, 18vw, 5rem);
  }

  .account-panel {
    position: static;
  }

  .task-panel,
  .jobs-panel,
  .log-panel {
    grid-column: 1;
  }

  .job-form {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }

  .actions,
  .section-head {
    align-items: stretch;
  }

  .actions button,
  .section-head button {
    width: 100%;
  }

  .admin-nav {
    position: static;
  }
}

/* Paid console v2 */
.page {
  width: min(1320px, 100%);
  padding: 18px;
}

.client-page {
  display: grid;
  gap: 16px;
}

.workspace {
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 16px;
}

.sidebar-stack {
  position: sticky;
  top: 18px;
  grid-column: 1;
  grid-row: 2 / span 4;
  align-self: start;
  min-width: 0;
  max-height: calc(100dvh - 36px);
  display: grid;
  grid-template-rows: auto;
  gap: 12px;
  overflow: visible;
}

.sidebar-stack .account-panel {
  position: static;
  grid-row: auto;
  min-width: 0;
  padding: 14px;
  gap: 9px;
}

.sidebar-stack .account-panel .eyebrow {
  margin-bottom: 7px;
}

.sidebar-stack .quota-water {
  width: min(100%, 200px);
  margin: 0 auto;
}

.sidebar-stack .quota-copy strong {
  font-size: 3.4rem;
}

.sidebar-stack .compact-list {
  gap: 2px;
}

.sidebar-stack .compact-list div {
  padding-top: 6px;
}

.sidebar-stack .log-panel {
  grid-column: auto;
  min-width: 0;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.sidebar-stack.has-log {
  grid-template-rows: auto minmax(160px, 1fr);
}

.sidebar-stack.has-log .log-panel:not(.hidden) {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.sidebar-stack .log-panel .section-head {
  align-items: center;
  margin-bottom: 9px;
}

.sidebar-stack .log-panel .section-head button {
  min-height: 36px;
  padding: 0 12px;
}

.sidebar-stack #jobLog {
  min-height: 120px;
  max-height: none;
  height: 100%;
  padding: 12px;
  font-size: 0.78rem;
}

.workspace-top {
  grid-column: 1 / -1;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.workspace-actions,
.notification-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notification-button.is-enabled {
  color: #15734a;
  border-color: rgb(28 140 90 / 0.28);
  background: rgb(28 140 90 / 0.1);
}

.notification-button.is-enabled:hover {
  box-shadow: 0 10px 24px rgb(28 140 90 / 0.14);
}

.notification-sound-settings {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.notification-sound-field {
  display: block;
  min-width: 0;
}

.notification-sound-select {
  width: auto;
  min-width: 112px;
  min-height: 44px;
  padding-inline: 12px 34px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background-color: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.sound-preview-button {
  min-width: 68px;
  padding-inline: 14px;
}

.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;
}

.workspace-top h1,
.admin-top h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.7rem);
  line-height: 1.05;
}

.account-panel,
.task-panel,
.jobs-panel,
.log-panel,
.table-panel,
.admin-card {
  border-radius: 18px;
}

.account-panel {
  padding: 18px;
  gap: 16px;
}

.task-panel,
.jobs-panel,
.log-panel {
  padding: 20px;
}

.task-panel {
  display: grid;
  gap: 14px;
}

.task-panel .section-head {
  margin-bottom: 0;
}

.job-form {
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}

.job-form .wide,
.notice,
.actions,
.option-row {
  grid-column: 1 / -1;
}

.option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.option-row fieldset {
  padding: 12px 14px 14px;
  align-content: center;
  min-height: 74px;
  background: rgb(127 150 180 / 0.06);
}

.option-row fieldset.is-unavailable {
  border-color: rgb(127 140 160 / 0.34);
  background: rgb(127 140 160 / 0.1);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px rgb(127 140 160 / 0.04);
}

.option-row fieldset.is-unavailable legend {
  color: var(--muted);
}

.locked-option {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  color: var(--muted);
  font-weight: 760;
}

.option-row legend {
  padding: 0 8px;
}

.free-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgb(28 140 90 / 0.13);
  color: var(--success);
  font-size: 0.76rem;
  font-weight: 820;
}

.result-box.hidden {
  display: none;
}

.quota-water {
  --water-top: rgb(124 176 248 / 0.82);
  --water-bottom: rgb(47 125 255 / 0.96);
  --water-sheen: rgb(255 255 255 / 0.28);
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  contain: layout paint;
  isolation: isolate;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgb(93 151 255 / 0.55);
  background:
    radial-gradient(circle at 42% 28%, rgb(255 255 255 / 0.18), transparent 22%),
    radial-gradient(circle at 52% 58%, rgb(17 24 39 / 0.24), transparent 58%),
    linear-gradient(180deg, rgb(12 23 38 / 0.92), rgb(7 16 24 / 0.98));
  box-shadow:
    inset 0 0 0 10px rgb(255 255 255 / 0.035),
    inset 0 24px 54px rgb(255 255 255 / 0.07),
    inset 0 -30px 66px rgb(0 0 0 / 0.36),
    0 18px 40px rgb(47 125 255 / 0.16);
}

.quota-water::before,
.quota-water::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.quota-water::before {
  z-index: 2;
  background:
    radial-gradient(circle at 34% 22%, rgb(255 255 255 / 0.28), transparent 18%),
    linear-gradient(150deg, rgb(255 255 255 / 0.18), transparent 28% 72%, rgb(0 0 0 / 0.18));
  mix-blend-mode: screen;
}

.quota-water::after {
  z-index: 3;
  box-shadow:
    inset 0 0 0 2px rgb(255 255 255 / 0.08),
    inset 0 0 28px rgb(0 0 0 / 0.38);
}

.quota-fluid {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}

.quota-copy {
  position: relative;
  z-index: 4;
  display: grid;
  justify-items: center;
  text-align: center;
  color: #f6f9ff;
  text-shadow: 0 2px 18px rgb(0 0 0 / 0.34);
}

.quota-copy strong {
  position: relative;
  display: grid;
  width: max-content;
  min-width: 3.6ch;
  height: 1em;
  place-items: center;
  overflow: hidden;
  font-size: clamp(3rem, 7vw, 4.45rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.quota-copy strong span {
  grid-area: 1 / 1;
  color: inherit;
  font-weight: inherit;
  will-change: transform, opacity;
}

.quota-number-old {
  animation: quota-number-out 520ms cubic-bezier(.4, 0, .2, 1) forwards;
}

.quota-number-new {
  animation: quota-number-in 520ms cubic-bezier(.16, 1, .3, 1) forwards;
}

.quota-copy span {
  color: rgb(226 234 246 / 0.82);
  font-weight: 720;
}

.tilt-control {
  width: min(100%, 220px);
  min-height: 40px;
  justify-self: center;
  border: 1px solid rgb(93 151 255 / 0.48);
  border-radius: 999px;
  padding: 0 16px;
  background: rgb(47 125 255 / 0.16);
  color: #f6f9ff;
  font-size: 0.82rem;
  font-weight: 760;
}

.tilt-control:hover {
  border-color: rgb(93 151 255 / 0.72);
  background: rgb(47 125 255 / 0.24);
  box-shadow: none;
}

@keyframes quota-number-out {
  to {
    opacity: 0;
    transform: translateY(-72%);
  }
}

@keyframes quota-number-in {
  from {
    opacity: 0;
    transform: translateY(72%);
  }
}

.quota-water.is-full {
  --water-top: rgb(142 190 250 / 0.88);
  --water-bottom: rgb(79 140 235 / 0.98);
  --water-sheen: rgb(255 255 255 / 0.34);
  border-color: rgb(142 190 250 / 0.72);
}

.quota-water.is-mid {
  --water-top: rgb(60 196 191 / 0.82);
  --water-bottom: rgb(35 116 223 / 0.96);
  --water-sheen: rgb(255 255 255 / 0.3);
  border-color: rgb(62 180 210 / 0.62);
}

.quota-water.is-low {
  --water-top: rgb(255 174 84 / 0.88);
  --water-bottom: rgb(209 71 76 / 0.96);
  --water-sheen: rgb(255 238 210 / 0.36);
  border-color: rgb(255 174 84 / 0.68);
  box-shadow:
    inset 0 0 0 10px rgb(255 174 84 / 0.05),
    inset 0 24px 54px rgb(255 255 255 / 0.06),
    inset 0 -30px 66px rgb(0 0 0 / 0.4),
    0 18px 40px rgb(209 71 76 / 0.15);
}

.expiry-warning {
  display: grid;
  gap: 4px;
  border: 1px solid rgb(198 61 61 / 0.34);
  border-radius: 12px;
  padding: 11px 12px;
  background: rgb(198 61 61 / 0.1);
  color: var(--danger);
}

.expiry-warning strong {
  font-size: 0.9rem;
}

.expiry-warning span {
  color: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.5;
}

.pending-delivery {
  width: min(100%, 460px);
  min-height: 78px;
  border: 1px solid rgb(47 125 255 / 0.28);
  border-radius: 12px;
  padding: 10px;
  display: none;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: rgb(47 125 255 / 0.07);
}

.pending-delivery.is-visible {
  display: grid;
}

.task-center-head {
  align-items: center;
}

.pending-delivery-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.pending-delivery-copy span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 720;
}

.pending-delivery-copy strong {
  overflow-wrap: anywhere;
  font-size: 0.84rem;
  line-height: 1.35;
}

.pending-delivery button {
  min-height: 38px;
  padding: 0 10px;
  white-space: nowrap;
}

.storage-limit-warning {
  border: 1px solid rgb(209 71 76 / 0.58);
  border-left-width: 5px;
  border-radius: 14px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  background: rgb(209 71 76 / 0.12);
  color: #ffb4b4;
}

.storage-limit-warning > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.storage-limit-warning strong {
  font-size: 0.96rem;
}

.storage-limit-warning span {
  color: inherit;
  font-size: 0.84rem;
  line-height: 1.55;
}

.storage-limit-warning button {
  background: #d1474c;
  color: #fff;
  white-space: nowrap;
}

.storage-limit-warning button:hover {
  box-shadow: 0 12px 26px rgb(209 71 76 / 0.28);
}

.zip-spotlight {
  position: fixed;
  z-index: 9999;
  border: 2px solid rgb(135 183 255 / 0.98);
  border-radius: 17px;
  background: transparent;
  box-shadow:
    0 0 0 9999px rgb(2 7 15 / 0.72),
    0 0 0 7px rgb(47 125 255 / 0.2),
    0 0 34px rgb(47 125 255 / 0.86);
  pointer-events: none;
  opacity: 1;
  transition: opacity 500ms ease;
}

.zip-spotlight.is-fading {
  opacity: 0;
}

.admin-login {
  width: min(520px, 100%);
  margin: min(12vh, 110px) auto 0;
  padding: clamp(24px, 5vw, 42px);
  display: grid;
  gap: 18px;
}

.admin-login h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 1.05;
}

#adminLoginForm {
  display: grid;
  gap: 14px;
}

.admin-dashboard {
  display: grid;
  gap: 16px;
}

.admin-top {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-actions {
  display: flex;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  padding: 14px;
  display: grid;
  gap: 8px;
}

.stat-card span,
.mini-report span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.stat-card strong,
.mini-report strong {
  font-size: clamp(1.25rem, 2.4vw, 1.9rem);
  line-height: 1;
}

.nas-storage-overview {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(180px, 0.7fr) minmax(360px, 2fr);
  gap: 0;
  padding: 0 14px;
  overflow: hidden;
}

.nas-storage-metric {
  min-width: 0;
  padding: 11px 16px;
  display: grid;
  align-content: center;
  gap: 2px;
  border-right: 1px solid var(--line);
}

.nas-storage-metric:last-child {
  border-right: 0;
}

.nas-storage-metric > span,
.nas-storage-metric small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 720;
}

.nas-storage-metric > strong {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.nas-storage-top {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 14px;
}

.nas-storage-key-list {
  min-width: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.storage-key-link {
  min-width: 0;
  min-height: 34px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 9px;
  background: rgb(127 150 180 / 0.08);
  color: var(--text);
  border-color: var(--line);
  font-size: 0.76rem;
}

.storage-key-link span {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.storage-key-link strong {
  color: #86b8ff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.storage-key-link:hover,
.storage-key-link:focus-visible {
  border-color: rgb(47 128 237 / 0.55);
  background: rgb(47 128 237 / 0.12);
}

.key-row.storage-key-target {
  border-color: rgb(47 128 237 / 0.72);
  box-shadow: 0 0 0 3px rgb(47 128 237 / 0.14);
}

.admin-job-row {
  grid-template-columns: minmax(0, 1fr);
}

.admin-job-content {
  min-width: 0;
}

.admin-job-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-job-title > strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-job-origin {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.admin-job-origin > span {
  font-weight: 760;
}

.admin-job-origin.is-missing {
  color: var(--danger);
}

.admin-job-key-link,
.admin-job-order-link {
  width: fit-content;
  max-width: 100%;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid rgb(47 128 237 / 0.28);
  border-radius: 8px;
  background: rgb(47 128 237 / 0.07);
  color: var(--accent);
  font: inherit;
  font-weight: 760;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: left;
}

.admin-job-key-link {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.admin-job-key-link:hover,
.admin-job-key-link:focus-visible,
.admin-job-order-link:hover,
.admin-job-order-link:focus-visible {
  border-color: rgb(47 128 237 / 0.64);
  background: rgb(47 128 237 / 0.14);
}

.admin-job-key-link:active,
.admin-job-order-link:active {
  transform: translateY(1px);
}

.admin-job-row.has-failure {
  border-color: rgb(198 61 61 / 0.3);
}

.admin-failure-block {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgb(198 61 61 / 0.26);
  border-radius: 10px;
  background: rgb(198 61 61 / 0.07);
}

.admin-failure-block > strong,
.admin-failure-block summary {
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 800;
}

.admin-failure-block p {
  margin: 5px 0 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.admin-failure-block details {
  margin-top: 10px;
}

.admin-failure-block summary {
  width: fit-content;
  cursor: pointer;
}

.admin-failure-log {
  max-height: 260px;
  margin: 9px 0 0;
  padding: 11px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid rgb(198 61 61 / 0.2);
  border-radius: 8px;
  background: rgb(10 14 20 / 0.9);
  color: #ffc1c1;
  font-size: 0.75rem;
  line-height: 1.55;
}

.tabbar {
  padding: 8px;
  display: flex;
  gap: 8px;
  overflow: auto;
}

.tab-button {
  flex: 0 0 auto;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.tab-button.active {
  background: var(--signal);
  color: var(--signal-ink);
  border-color: rgb(255 255 255 / 0.14);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.strm-link-head {
  align-items: end;
}

.strm-import-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.strm-import-actions input[type="file"] {
  width: min(100%, 340px);
  min-height: 44px;
  padding: 6px;
}

.strm-import-actions input[type="file"]::file-selector-button {
  min-height: 32px;
  margin-right: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-weight: 760;
  cursor: pointer;
}

.strm-selection-summary {
  margin: -2px 0 14px;
}

.strm-link-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.strm-link-main {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 6px;
}

.strm-link-main strong,
.strm-link-main a,
.strm-source {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.strm-link-main a {
  display: inline;
  width: fit-content;
}

.strm-source,
.strm-link-main small {
  color: var(--muted);
  font-size: 0.82rem;
}

.strm-link-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 760px) {
  .strm-link-head,
  .strm-link-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .strm-import-actions,
  .strm-link-actions {
    width: 100%;
    justify-content: stretch;
  }

  .strm-import-actions input[type="file"],
  .strm-import-actions button,
  .strm-link-actions button {
    width: 100%;
  }
}

.filter-bar {
  display: grid;
  grid-template-columns: 180px 180px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.key-row {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fbfcff;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(420px, 0.9fr);
  gap: 14px;
  align-items: center;
}

.key-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(0.95rem, 1.5vw, 1.15rem);
  font-weight: 820;
  word-break: break-all;
}

.key-code.is-exhausted {
  text-decoration: line-through;
}

.key-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.key-title-row .key-code {
  min-width: 0;
}

.delivery-tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.delivery-tag.is-delivered {
  color: #86b8ff;
  border-color: rgb(47 128 237 / 0.46);
  background: rgb(47 128 237 / 0.14);
}

.delivery-tag.is-pending {
  color: var(--muted);
  background: rgb(127 150 180 / 0.08);
}

.refund-tag {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 3px 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgb(198 61 61 / 0.3);
  border-radius: 8px;
  color: #9f2b2b;
  background: rgb(198 61 61 / 0.1);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.refund-tag.has-error {
  border-style: dashed;
}

.xianyu-key-row {
  border-left: 4px solid rgb(47 128 237 / 0.72);
}

.xianyu-key-row.is-refunded {
  border-left-color: rgb(198 61 61 / 0.72);
}

#tab-xianyu.active {
  display: block;
}

.xianyu-compact-row {
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  overflow: hidden;
}

.xianyu-compact-head {
  min-width: 0;
  padding: 12px 14px 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.xianyu-identity {
  min-width: 0;
}

.xianyu-identity p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 680;
}

.key-state-tag {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgb(127 150 180 / 0.08);
  font-size: 0.74rem;
  font-weight: 760;
}

.xianyu-order-amount {
  flex: 0 0 auto;
  min-width: 142px;
  padding-left: 16px;
  display: grid;
  justify-items: end;
  gap: 1px;
  border-left: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.xianyu-order-amount span,
.xianyu-order-amount small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.xianyu-order-amount strong {
  font-size: 1.12rem;
}

.xianyu-compact-grid {
  margin: 0;
  padding: 0 14px;
  display: grid;
  grid-template-columns: minmax(210px, 1.35fr) minmax(138px, 0.86fr) minmax(185px, 1.05fr) minmax(92px, 0.55fr) minmax(160px, 0.9fr);
  border-block: 1px solid var(--line);
  background: rgb(127 150 180 / 0.035);
}

.xianyu-compact-grid > div {
  min-width: 0;
  padding: 9px 12px;
  border-left: 1px solid var(--line);
}

.xianyu-compact-grid > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.xianyu-compact-grid > div:last-child {
  padding-right: 0;
}

.xianyu-compact-grid .is-refund {
  grid-column: span 2;
}

.xianyu-compact-grid dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 720;
}

.xianyu-compact-grid dd {
  margin: 3px 0 0;
  font-size: 0.8rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.xianyu-storage-stats {
  margin: 0;
  padding: 10px 14px 0;
}

.xianyu-compact-footer {
  padding: 10px 14px 12px;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) auto;
  align-items: end;
  gap: 10px 14px;
}

.xianyu-inline-fields {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
}

.xianyu-inline-fields label {
  display: grid;
  gap: 5px;
}

.xianyu-inline-fields label > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 720;
}

.xianyu-inline-fields input {
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 9px;
}

.xianyu-compact-actions {
  grid-column: auto;
  align-self: end;
}

.xianyu-compact-actions button {
  min-height: 36px;
  padding: 0 11px;
}

.xianyu-income-panel {
  padding: 20px;
}

.xianyu-income-head {
  margin-bottom: 14px;
}

.report-period {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
  white-space: nowrap;
}

.xianyu-income-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-block: 1px solid var(--line);
}

.xianyu-income-metric {
  min-width: 0;
  padding: 15px 18px;
  display: grid;
  gap: 7px;
}

.xianyu-income-metric + .xianyu-income-metric {
  border-left: 1px solid var(--line);
}

.xianyu-income-metric span,
.xianyu-chart-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.xianyu-income-metric strong {
  min-width: 0;
  font-size: clamp(1.18rem, 2.2vw, 1.75rem);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.xianyu-chart-wrap {
  margin-top: 16px;
  padding: 14px 14px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(127 150 180 / 0.045);
  overflow: hidden;
}

.xianyu-chart-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 8px;
}

.xianyu-chart-legend {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.xianyu-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.xianyu-chart-legend i {
  width: 16px;
  height: 3px;
  border-radius: 999px;
  background: var(--signal);
}

.xianyu-chart-legend i.is-net {
  background: #16835d;
}

.xianyu-chart-legend i.is-refund {
  background: #c63d3d;
}

.xianyu-income-chart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 210px;
}

.xianyu-chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.xianyu-chart-axis {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.xianyu-chart-area {
  fill: rgb(47 125 255 / 0.09);
}

.xianyu-chart-line {
  fill: none;
  stroke: #2f80ed;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.xianyu-chart-point {
  fill: var(--panel);
  stroke: #2f80ed;
  stroke-width: 2.5;
}

.xianyu-chart-line.is-net,
.xianyu-chart-point.is-net {
  stroke: #16835d;
}

.xianyu-chart-line.is-refund,
.xianyu-chart-point.is-refund {
  stroke: #c63d3d;
}

.xianyu-chart-zero {
  stroke: rgb(127 150 180 / 0.72);
  stroke-width: 1.2;
  stroke-dasharray: 5 5;
}

.xianyu-chart-empty,
.xianyu-order-legacy {
  margin: 8px 4px 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.xianyu-order-grid {
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.xianyu-order-grid > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(127 150 180 / 0.055);
}

.xianyu-order-grid dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 720;
}

.xianyu-order-grid dd {
  margin: 3px 0 0;
  font-size: 0.85rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.refund-cleanup-error {
  margin: 8px 0 0;
  padding: 9px 10px;
  border: 1px solid rgb(198 61 61 / 0.22);
  border-radius: 10px;
  color: #9f2b2b;
  background: rgb(198 61 61 / 0.08);
  font-size: 0.8rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.spec-tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid rgb(190 122 24 / 0.36);
  border-radius: 8px;
  background: rgb(219 146 35 / 0.12);
  color: #8a5300;
  font-size: 0.76rem;
  font-weight: 820;
  white-space: nowrap;
}

.key-created-at {
  width: fit-content;
  margin-top: 11px;
  padding: 9px 11px;
  display: grid;
  gap: 2px;
  border-left: 3px solid var(--signal);
  background: rgb(47 128 237 / 0.07);
}

.key-created-at span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 720;
}

.key-created-at strong {
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.key-storage-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.key-storage-stats > span {
  display: inline-grid;
  gap: 1px;
  min-width: 180px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgb(127 150 180 / 0.06);
}

.key-storage-stats small {
  color: var(--muted);
  font-size: 0.72rem;
}

.key-storage-stats strong {
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.key-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px 12px;
  align-items: end;
}

.key-field {
  min-width: 0;
}

.key-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.key-editor input {
  min-height: 40px;
  border-radius: 10px;
}

.key-editor button {
  min-height: 40px;
  padding: 0 12px;
}

.key-actions button {
  flex: 0 0 auto;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.report-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.mini-report {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 10px;
  background: rgb(127 150 180 / 0.06);
}

@media (prefers-color-scheme: dark) {
  .key-row {
    background: rgb(23 29 38 / 0.88);
  }

  .quota-water {
    background:
      radial-gradient(circle at 42% 28%, rgb(255 255 255 / 0.18), transparent 22%),
      radial-gradient(circle at 52% 58%, rgb(17 24 39 / 0.24), transparent 58%),
      linear-gradient(180deg, rgb(12 23 38 / 0.92), rgb(7 16 24 / 0.98));
  }

  .option-row fieldset,
  .mini-report {
    background: rgb(127 150 180 / 0.08);
  }

  .expiry-warning {
    background: rgb(209 71 76 / 0.14);
    color: #ffb4b4;
  }

  .spec-tag {
    color: #ffd08a;
    border-color: rgb(255 184 77 / 0.34);
    background: rgb(219 146 35 / 0.14);
  }

  .refund-tag,
  .refund-cleanup-error {
    color: #ffb4b4;
    border-color: rgb(255 180 180 / 0.28);
    background: rgb(198 61 61 / 0.14);
  }
}

@media (max-width: 1500px) {
  .key-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .xianyu-income-metric:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .xianyu-income-metric:nth-child(4) {
    border-top: 1px solid var(--line);
  }

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

  .xianyu-compact-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .xianyu-compact-grid > div:nth-child(3n + 1) {
    padding-left: 0;
    border-left: 0;
  }

  .xianyu-compact-grid > div:nth-child(n + 4) {
    border-top: 1px solid var(--line);
  }

  .xianyu-compact-footer {
    grid-template-columns: minmax(0, 1fr);
  }

  .xianyu-compact-actions {
    justify-content: flex-start;
  }

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

  .nas-storage-top {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-right: 0;
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .sidebar-stack,
  .sidebar-stack.has-log {
    position: static;
    grid-column: 1;
    grid-row: auto;
    width: 100%;
    min-width: 0;
    max-height: none;
    grid-template-rows: auto auto;
    overflow: visible;
  }

  .task-panel,
  .jobs-panel {
    grid-column: 1;
    min-width: 0;
  }

  .quota-water {
    width: min(100%, 320px);
    margin: 0 auto;
  }

  .sidebar-stack .log-panel:not(.hidden) {
    min-height: 220px;
  }
}

@media (max-width: 760px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .page {
    width: 100%;
    max-width: 100vw;
    padding: 12px;
  }

  .client-page,
  .admin-dashboard {
    gap: 12px;
  }

  .panel,
  .account-panel,
  .task-panel,
  .jobs-panel,
  .log-panel,
  .admin-card,
  .table-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .account-panel,
  .task-panel,
  .jobs-panel,
  .log-panel {
    padding: 16px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .account-panel {
    grid-row: auto;
  }

  .workspace-top,
  .admin-top {
    display: grid;
  }

  .workspace-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .notification-controls {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .notification-controls button {
    min-width: 0;
  }

  .notification-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .notification-sound-settings {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .notification-sound-select,
  #logoutButton {
    width: 100%;
  }

  .option-row,
  .filter-bar,
  .report-cards {
    grid-template-columns: 1fr;
  }

  .xianyu-income-panel {
    padding: 16px;
  }

  .xianyu-income-head,
  .xianyu-chart-head {
    display: grid;
  }

  .xianyu-income-chart {
    min-height: 170px;
  }

  .xianyu-order-grid {
    grid-template-columns: 1fr;
  }

  .xianyu-compact-head {
    display: grid;
  }

  .xianyu-order-amount {
    width: 100%;
    min-width: 0;
    padding: 9px 0 0;
    grid-template-columns: auto auto 1fr;
    align-items: baseline;
    justify-items: start;
    gap: 8px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .xianyu-order-amount small {
    justify-self: end;
  }

  .xianyu-compact-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .xianyu-compact-grid > div,
  .xianyu-compact-grid > div:nth-child(3n + 1) {
    padding: 9px 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .xianyu-compact-grid > div:first-child {
    border-top: 0;
  }

  .xianyu-compact-grid .is-refund {
    grid-column: auto;
  }

  .xianyu-inline-fields {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .nas-storage-overview {
    grid-template-columns: 1fr;
    padding: 0 12px;
  }

  .nas-storage-metric,
  .nas-storage-top {
    grid-column: auto;
    grid-template-columns: 1fr;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 11px 4px;
  }

  .nas-storage-metric:first-child {
    border-top: 0;
  }

  .nas-storage-key-list {
    padding-top: 5px;
  }

  .quota-water {
    width: min(100%, 320px);
    margin: 0 auto;
  }

  .sidebar-stack .quota-water {
    width: min(100%, 320px);
  }

  .sidebar-stack .quota-copy strong {
    font-size: clamp(3rem, 18vw, 4.45rem);
  }

  .pending-delivery,
  .storage-limit-warning {
    grid-template-columns: 1fr;
  }

  .pending-delivery button,
  .storage-limit-warning button {
    width: 100%;
  }

  .compact-list div {
    align-items: flex-start;
  }

  .compact-list dd {
    min-width: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  input,
  select,
  fieldset,
  .job-card,
  .artifact-card,
  .result-box,
  .key-row {
    min-width: 0;
    max-width: 100%;
  }

  .key-editor {
    grid-template-columns: 1fr;
  }

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

  .key-actions button {
    width: 100%;
  }

  .job-top {
    grid-template-columns: 1fr;
  }

  .artifact-card {
    grid-template-columns: 1fr;
  }

  .artifact-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .artifact-actions > * {
    width: 100%;
  }

  .job-top .badge {
    justify-self: start;
  }

  .table-meta {
    max-width: 100%;
    min-width: 0;
  }

  .admin-job-origin {
    align-items: flex-start;
  }

  .admin-job-key-link,
  .admin-job-order-link {
    max-width: 100%;
  }

  .admin-actions {
    display: grid;
  }
}

/* Task center interactions */
.workspace-tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.workspace-tab {
  min-height: 46px;
  padding: 0 2px;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.workspace-tab:hover {
  color: var(--ink);
  box-shadow: none;
}

.workspace-tab.active {
  border-bottom-color: var(--signal);
  color: var(--ink);
}

.workspace-tab span {
  display: inline-grid;
  min-width: 24px;
  min-height: 24px;
  margin-left: 5px;
  padding: 0 7px;
  place-items: center;
  border-radius: 999px;
  background: rgb(127 150 180 / 0.14);
  color: inherit;
  font-size: 0.78rem;
}

.workspace-tab-panel {
  margin-top: 16px;
}

.package-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 2px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.package-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.job-card.selected,
.artifact-card.selected {
  border-color: var(--signal);
  background: rgb(47 125 255 / 0.07);
  box-shadow:
    inset 4px 0 0 var(--signal),
    0 0 0 3px rgb(47 125 255 / 0.16);
}

.artifact-select {
  cursor: pointer;
  outline: none;
}

.artifact-select:focus-visible {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgb(47 125 255 / 0.22);
}

.artifact-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.artifact-title-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.compact-button {
  min-height: 40px;
  padding-inline: 13px;
}

button.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.button-spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: button-spin 700ms linear infinite;
}

@keyframes button-spin {
  to {
    transform: rotate(360deg);
  }
}

.dialog-open {
  overflow: hidden;
}

.ui-dialog-root {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.ui-dialog-root.is-open {
  opacity: 1;
}

.ui-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 0.54);
  backdrop-filter: blur(8px);
}

.ui-dialog {
  position: relative;
  width: 100%;
  max-width: 620px;
  min-width: 0;
  max-height: min(680px, calc(100dvh - 40px));
  overflow-y: auto;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 28px 90px rgb(15 23 42 / 0.3);
  transform: translateY(10px) scale(0.985);
  transition: transform 160ms ease;
}

.ui-dialog-root.is-open .ui-dialog {
  transform: translateY(0) scale(1);
}

.ui-dialog-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgb(47 125 255 / 0.12);
  color: var(--signal);
  font-size: 1.25rem;
  font-weight: 820;
}

.ui-dialog[data-tone="danger"] .ui-dialog-icon,
.ui-dialog[data-tone="warning"] .ui-dialog-icon {
  background: rgb(198 61 61 / 0.11);
  color: var(--danger);
}

.ui-dialog-copy {
  min-width: 0;
}

.ui-dialog-copy h2 {
  margin: 2px 0 8px;
  font-size: 1.2rem;
  letter-spacing: 0;
}

.ui-dialog-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.ui-dialog-detail {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(47 125 255 / 0.06);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-line;
  max-height: min(46vh, 420px);
  overflow: auto;
}

.quota-adjust-form {
  display: grid;
  gap: 13px;
  white-space: normal;
}

.quota-adjust-code {
  min-width: 0;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.quota-adjust-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--line);
}

.quota-adjust-summary > span {
  min-width: 0;
  padding: 9px 8px;
  display: grid;
  gap: 2px;
  text-align: center;
}

.quota-adjust-summary > span + span {
  border-left: 1px solid var(--line);
}

.quota-adjust-summary small,
.quota-adjust-field > span,
.quota-adjust-last {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.quota-adjust-summary strong {
  color: var(--ink);
  font-size: 0.94rem;
  font-variant-numeric: tabular-nums;
}

.quota-adjust-field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.quota-adjust-field > span small {
  font: inherit;
  opacity: 0.72;
}

.quota-adjust-field input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border-radius: 10px;
}

.quota-adjust-last {
  margin: -2px 0 0;
}

.track-issue-list {
  display: grid;
  gap: 6px;
  white-space: normal;
}

.track-issue-item,
.track-issue-empty {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.track-issue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.track-issue-link {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

a.track-issue-link {
  color: var(--signal);
  text-decoration: none;
}

a.track-issue-link:hover,
a.track-issue-link:focus-visible {
  text-decoration: underline;
}

.track-retry-button {
  min-height: 36px;
  padding: 0 12px;
  background: var(--panel);
  font-size: 0.78rem;
}

.track-retry-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  white-space: nowrap;
}

.track-retry-status.success {
  color: var(--success);
}

.ui-dialog-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.ui-dialog-actions button {
  min-width: 104px;
}

.ui-dialog-actions button.secondary {
  background: var(--panel);
}

.ui-dialog[data-tone="danger"] [data-dialog-confirm],
.ui-dialog[data-tone="warning"] [data-dialog-confirm] {
  background: var(--danger);
}

.ui-dialog[data-tone="danger"] [data-dialog-confirm]:hover,
.ui-dialog[data-tone="warning"] [data-dialog-confirm]:hover {
  box-shadow: 0 12px 26px rgb(198 61 61 / 0.22);
}

.toast-region {
  position: fixed;
  z-index: 1000;
  top: 18px;
  right: 18px;
  width: min(380px, calc(100vw - 36px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--success);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 16px 42px rgb(33 43 54 / 0.2);
  pointer-events: auto;
}

.toast.info {
  border-left-color: var(--signal);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast strong {
  white-space: nowrap;
}

.toast span {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.history-load-status {
  min-height: 42px;
  padding: 12px 0 4px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.history-load-status::before {
  content: "";
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -3px;
  animation: button-spin 0.8s linear infinite;
}

@media (prefers-color-scheme: dark) {
  .toast {
    background: #171d26;
    box-shadow: 0 16px 42px rgb(0 0 0 / 0.4);
  }

  .job-card.selected,
  .artifact-card.selected {
    background: rgb(47 125 255 / 0.11);
  }
}

@media (prefers-reduced-motion: reduce) {
  .button-spinner {
    animation-duration: 1.4s !important;
  }
}

@media (max-width: 760px) {
  .ui-dialog-root {
    align-items: end;
    padding: 12px;
  }

  .ui-dialog {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 12px;
    padding: 20px;
    border-radius: 16px;
  }

  .ui-dialog-icon {
    width: 38px;
    height: 38px;
  }

  .ui-dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .ui-dialog-actions button {
    width: 100%;
    min-width: 0;
  }

  .workspace-tabs {
    gap: 18px;
  }

  .job-issue-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .job-issue-button {
    width: 100%;
  }

  .track-issue-item {
    grid-template-columns: minmax(0, 1fr);
  }

  .track-retry-button {
    width: 100%;
  }

  .package-toolbar,
  .artifact-title-row {
    grid-template-columns: 1fr;
  }

  .package-toolbar button {
    width: 100%;
  }

  .artifact-title-row .badge {
    justify-self: start;
  }

  .toast-region {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
  }

  .toast {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
