:root {
  color-scheme: dark;
  --navy-950: #050b16;
  --navy-925: #08111f;
  --navy-900: #0a1425;
  --navy-850: #0e1a2e;
  --navy-800: #13213a;
  --navy-760: #182944;
  --line: rgba(181, 198, 224, 0.13);
  --line-strong: rgba(221, 188, 101, 0.32);
  --text: #f4f7fb;
  --text-soft: #bec9d8;
  --muted: #8795aa;
  --gold: #e4bd5b;
  --gold-light: #ffe7a0;
  --gold-dark: #9b6b16;
  --red: #ed5b55;
  --red-soft: #ff8a82;
  --green: #38c992;
  --cyan: #64c6dc;
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.38);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.24);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 13px;
  --safe-left: max(18px, env(safe-area-inset-left));
  --safe-right: max(18px, env(safe-area-inset-right));
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scroll-padding-top: 92px;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 16% -8%, rgba(36, 65, 108, 0.55), transparent 36rem),
    radial-gradient(circle at 100% 18%, rgba(147, 98, 19, 0.14), transparent 30rem),
    linear-gradient(160deg, var(--navy-925), var(--navy-950) 72%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select,
label,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
select {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
strong {
  letter-spacing: -0.02em;
}

:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
}

::selection {
  color: var(--navy-950);
  background: var(--gold-light);
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
}

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

.nowrap {
  white-space: nowrap;
}

.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(90px);
  opacity: 0.13;
}

.ambient-one {
  top: 8rem;
  left: -15rem;
  background: #4d78b1;
}

.ambient-two {
  right: -13rem;
  bottom: 8%;
  background: #ba7d23;
}

.topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 13px var(--safe-right) 13px var(--safe-left);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 11, 22, 0.8);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(20px) saturate(135%);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img {
  flex: 0 0 auto;
  border-radius: 13px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(255, 231, 160, 0.08);
}

.brand-copy {
  display: grid;
  line-height: 1.18;
}

.brand-copy strong {
  color: #fff8e8;
  font-size: 17px;
  font-weight: 760;
  letter-spacing: 0.04em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.topbar-meta,
.viewer-status-cluster {
  display: flex;
  align-items: center;
  gap: 16px;
}

.connection-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 30px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

.connection-pill i,
.status-badge i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(135, 149, 170, 0.1);
}

.connection-pill.is-live,
.connection-pill.source-online,
.status-badge.status-active {
  color: #bdf4de;
  border-color: rgba(56, 201, 146, 0.25);
  background: rgba(56, 201, 146, 0.08);
}

.connection-pill.is-live i,
.connection-pill.source-online i,
.status-badge.status-active i {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(56, 201, 146, 0.13), 0 0 16px rgba(56, 201, 146, 0.5);
}

.connection-pill.is-polling,
.connection-pill.source-stale,
.status-badge.status-paused {
  color: #ffe7a0;
  border-color: rgba(228, 189, 91, 0.28);
  background: rgba(228, 189, 91, 0.08);
}

.connection-pill.is-polling i,
.connection-pill.source-stale i,
.status-badge.status-paused i {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(228, 189, 91, 0.13);
}

.connection-pill.is-offline,
.connection-pill.source-offline,
.status-badge.status-revoked {
  color: #ffc4c0;
  border-color: rgba(237, 91, 85, 0.28);
  background: rgba(237, 91, 85, 0.08);
}

.connection-pill.is-offline i,
.connection-pill.source-offline i,
.status-badge.status-revoked i {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(237, 91, 85, 0.13);
}

.connection-pill.is-connecting i {
  background: var(--cyan);
  animation: status-pulse 1.3s ease-in-out infinite;
}

.status-badge.status-expired {
  color: #b5c0d0;
  background: rgba(135, 149, 170, 0.08);
}

.page-shell {
  width: min(1480px, calc(100% - 36px));
  margin: 0 auto;
  padding: 44px 0 max(64px, env(safe-area-inset-bottom));
}

.admin-shell {
  width: min(1240px, calc(100% - 36px));
}

.admin-page.is-embedded > .topbar {
  display: none;
}

.admin-page.is-embedded .admin-shell {
  padding-top: 24px;
}

.admin-hero,
.viewer-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 48px;
  margin: 10px 0 32px;
}

.admin-hero > div:first-child,
.viewer-hero > div:first-child {
  max-width: 760px;
}

.eyebrow,
.section-kicker {
  margin-bottom: 9px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

.admin-hero h1,
.viewer-hero h1 {
  margin-bottom: 13px;
  color: #fff;
  font-size: clamp(32px, 5vw, 58px);
  font-weight: 750;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.admin-hero h1 {
  font-size: clamp(30px, 4.6vw, 52px);
}

.hero-copy {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1.75;
}

.security-note,
.market-session-card {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 13px;
  min-width: 250px;
  padding: 17px 19px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(228, 189, 91, 0.09), rgba(13, 25, 45, 0.76));
  box-shadow: var(--shadow-md);
}

.security-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(228, 189, 91, 0.3);
  border-radius: 12px;
  color: var(--gold-light);
  background: rgba(228, 189, 91, 0.08);
  font-size: 13px;
  font-weight: 760;
}

.security-note div,
.market-session-card {
  display: grid;
}

.security-note strong {
  color: #fff6df;
}

.security-note small,
.market-session-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 44%),
    rgba(10, 20, 37, 0.82);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(16px);
}

.panel::before {
  position: absolute;
  top: 0;
  right: 9%;
  left: 9%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 231, 160, 0.32), transparent);
  content: "";
  pointer-events: none;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 28px 21px;
}

.panel-heading h2 {
  margin: 0;
  color: #f8fafc;
  font-size: 21px;
  line-height: 1.25;
}

.section-kicker {
  margin-bottom: 5px;
  font-size: 10px;
}

.soft-badge,
.count-badge {
  display: inline-flex;
  min-height: 29px;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  border: 1px solid rgba(228, 189, 91, 0.2);
  border-radius: 999px;
  color: var(--gold-light);
  background: rgba(228, 189, 91, 0.07);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.count-badge {
  min-width: 31px;
  padding-inline: 9px;
  color: var(--text-soft);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
  font-variant-numeric: tabular-nums;
}

.heading-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.create-panel {
  margin-bottom: 22px;
}

.create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  padding: 0 28px 22px;
}

.ttl-fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
}

.ttl-fieldset legend,
.field > span {
  margin-bottom: 9px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(118px, 1fr));
  gap: 7px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(3, 9, 18, 0.46);
}

.segmented label {
  position: relative;
  min-width: 0;
}

.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  display: grid;
  min-height: 39px;
  place-items: center;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 670;
  white-space: nowrap;
  transition: 160ms ease;
}

.segmented input:hover + span {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.segmented input:checked + span {
  color: #fff1bf;
  border-color: rgba(228, 189, 91, 0.26);
  background: linear-gradient(145deg, rgba(228, 189, 91, 0.17), rgba(228, 189, 91, 0.06));
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.18);
}

.field {
  display: grid;
}

input[type="text"],
input[type="datetime-local"],
select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: rgba(3, 9, 18, 0.7);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

input[type="text"],
input[type="datetime-local"] {
  width: 100%;
  padding: 10px 13px;
}

select {
  padding: 9px 38px 9px 12px;
}

input:hover,
select:hover {
  border-color: rgba(181, 198, 224, 0.25);
}

input:focus,
select:focus {
  border-color: rgba(228, 189, 91, 0.48);
  outline: none;
  box-shadow: 0 0 0 3px rgba(228, 189, 91, 0.09);
}

::-webkit-calendar-picker-indicator {
  filter: invert(1) sepia(0.25);
  opacity: 0.72;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 720;
  line-height: 1.2;
  white-space: nowrap;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button-primary {
  color: #1e1708;
  border-color: #f3d174;
  background: linear-gradient(135deg, #fff0ae, #e5b94d 56%, #bc8522);
  box-shadow: 0 10px 25px rgba(202, 145, 36, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.button-primary:hover:not(:disabled) {
  box-shadow: 0 13px 30px rgba(202, 145, 36, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.button-large {
  min-height: 49px;
  padding-inline: 19px;
}

.button-secondary,
.button-quiet {
  color: var(--text-soft);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.button-secondary:hover:not(:disabled),
.button-quiet:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(228, 189, 91, 0.26);
  background: rgba(228, 189, 91, 0.07);
}

.button-danger {
  color: white;
  border-color: rgba(237, 91, 85, 0.7);
  background: linear-gradient(135deg, #f26e67, #c83f3b);
}

.button-ghost-danger {
  color: #ffaaa4;
  border-color: rgba(237, 91, 85, 0.22);
  background: rgba(237, 91, 85, 0.055);
}

.button-ghost-danger:hover:not(:disabled) {
  color: white;
  border-color: rgba(237, 91, 85, 0.5);
  background: rgba(237, 91, 85, 0.16);
}

.button.is-busy {
  animation: busy-fade 900ms ease-in-out infinite alternate;
}

.form-hint {
  margin: 0;
  padding: 0 28px 23px;
  color: var(--muted);
  font-size: 12px;
}

.stats-grid,
.account-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card,
.metric-card {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 20px 21px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(12, 24, 43, 0.72);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.stat-card::after,
.metric-card::after {
  position: absolute;
  right: -22px;
  bottom: -36px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(228, 189, 91, 0.045);
  content: "";
}

.stat-card > span,
.metric-card > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat-card strong {
  margin: 4px 0 0;
  color: #fff;
  font-size: 31px;
  font-variant-numeric: tabular-nums;
}

.stat-card small,
.metric-card small {
  color: var(--muted);
  font-size: 11px;
}

.links-panel {
  min-height: 300px;
}

.link-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.compact-select select {
  min-height: 40px;
}

.links-list {
  display: grid;
  gap: 13px;
  padding: 20px;
}

.link-card {
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.027), rgba(3, 9, 18, 0.28));
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}

.link-card:hover {
  border-color: rgba(181, 198, 224, 0.22);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(3, 9, 18, 0.32));
}

.link-card.status-active {
  border-left-color: rgba(56, 201, 146, 0.62);
}

.link-card.status-paused {
  border-left-color: rgba(228, 189, 91, 0.62);
}

.link-card.status-revoked {
  border-left-color: rgba(237, 91, 85, 0.58);
  opacity: 0.82;
}

.link-card-head,
.link-title-group,
.link-actions,
.share-link-row,
.extend-control {
  display: flex;
  align-items: center;
}

.link-card-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.link-title-group {
  min-width: 0;
  gap: 11px;
}

.link-id {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.share-link-row {
  gap: 8px;
}

.share-link-input {
  color: #d9e3ef !important;
  font-size: 12px !important;
}

.link-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 13px;
}

.link-meta-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(2, 8, 16, 0.3);
}

.link-meta-item span {
  color: var(--muted);
  font-size: 10px;
}

.link-meta-item strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-actions {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(181, 198, 224, 0.08);
}

.extend-control {
  flex: 1 1 390px;
  gap: 7px;
}

.extend-select {
  min-width: 160px;
  flex: 0 1 190px;
}

.revoked-note {
  color: var(--red-soft);
  font-size: 12px;
}

.empty-state,
.table-empty,
.record-empty,
.stage-empty {
  color: var(--muted);
  text-align: center;
}

.empty-state {
  padding: 58px 20px 64px;
}

.empty-state h3 {
  margin: 12px 0 4px;
  color: var(--text-soft);
  font-size: 17px;
}

.empty-state p {
  margin: 0;
  font-size: 13px;
}

.empty-symbol {
  display: grid;
  width: 52px;
  height: 52px;
  margin: auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(228, 189, 91, 0.055);
  font-size: 22px;
}

.loading-list {
  display: grid;
  gap: 13px;
  padding: 20px;
}

.skeleton-card {
  height: 184px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.025) 20%, rgba(255, 255, 255, 0.07) 40%, rgba(255, 255, 255, 0.025) 60%);
  background-size: 220% 100%;
  animation: skeleton 1.6s ease infinite;
}

.confirm-dialog {
  width: min(450px, calc(100% - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(237, 91, 85, 0.32);
  border-radius: 22px;
  color: var(--text);
  background: #0b1526;
  box-shadow: var(--shadow-lg);
}

.confirm-dialog::backdrop {
  background: rgba(1, 5, 12, 0.77);
  backdrop-filter: blur(7px);
}

.confirm-dialog form {
  padding: 28px;
  text-align: center;
}

.danger-mark {
  display: grid;
  width: 50px;
  height: 50px;
  margin: 0 auto 16px;
  place-items: center;
  border: 1px solid rgba(237, 91, 85, 0.34);
  border-radius: 50%;
  color: #fff;
  background: rgba(237, 91, 85, 0.15);
  font-size: 23px;
  font-weight: 800;
}

.confirm-dialog h2 {
  margin-bottom: 9px;
  font-size: 22px;
}

.confirm-dialog p {
  color: var(--text-soft);
  font-size: 13px;
}

.dialog-link {
  margin: 17px 0;
  padding: 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(2, 8, 16, 0.42);
  font-family: Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  width: min(370px, calc(100% - 36px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(12, 24, 43, 0.96);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-mark {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--navy-950);
  background: var(--gold);
  font-size: 12px;
  font-weight: 850;
}

.toast-success .toast-mark {
  background: var(--green);
}

.toast-error {
  border-color: rgba(237, 91, 85, 0.34);
}

.toast-error .toast-mark {
  color: white;
  background: var(--red);
}

.toast-copy {
  color: var(--text-soft);
  font-size: 13px;
}

/* Viewer */

.viewer-topbar {
  gap: 40px;
}

.viewer-status-cluster {
  justify-content: flex-end;
}

.viewer-updated,
.viewer-countdown {
  display: grid;
  line-height: 1.15;
}

.viewer-updated span,
.viewer-countdown span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.viewer-updated strong,
.viewer-countdown strong {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.viewer-countdown strong {
  color: var(--gold-light);
}

.stale-banner {
  position: sticky;
  z-index: 45;
  top: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px var(--safe-right) 8px var(--safe-left);
  border-bottom: 1px solid rgba(228, 189, 91, 0.22);
  color: #f6e4b4;
  background: rgba(100, 70, 18, 0.88);
  backdrop-filter: blur(14px);
  font-size: 12px;
  text-align: center;
}

.stale-banner span {
  color: rgba(255, 244, 214, 0.78);
}

.mobile-jump-nav {
  display: none;
}

.viewer-shell {
  padding-top: 38px;
}

.viewer-hero {
  margin-top: 0;
  margin-bottom: 28px;
}

.market-session-card {
  min-width: 210px;
  align-content: center;
  text-align: right;
}

.market-session-card > span {
  color: var(--muted);
  font-size: 11px;
}

.market-session-card strong {
  margin: 2px 0;
  color: #fff0b2;
  font-size: 24px;
}

.metric-card {
  min-height: 134px;
  justify-content: stretch;
  padding: 22px;
}

.metric-card strong {
  align-self: end;
  margin: 13px 0 5px;
  overflow: hidden;
  color: #f9fbff;
  font-size: clamp(22px, 2.4vw, 31px);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-primary {
  border-color: rgba(228, 189, 91, 0.24);
  background: linear-gradient(145deg, rgba(228, 189, 91, 0.115), rgba(12, 24, 43, 0.76));
}

.value-up {
  color: var(--red-soft) !important;
}

.value-down {
  color: #69d5a9 !important;
}

.value-flat {
  color: var(--text-soft) !important;
}

.stage-panel,
.manual-desk-panel,
.data-panel,
.records-grid {
  margin-bottom: 20px;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 0 20px 22px;
}

.stage-card {
  position: relative;
  min-width: 0;
  min-height: 190px;
  padding: 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(3, 9, 18, 0.34);
}

.stage-card::after {
  position: absolute;
  right: -24px;
  bottom: -24px;
  width: 70px;
  height: 70px;
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 50%;
  content: "";
}

.stage-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.stage-order {
  color: rgba(228, 189, 91, 0.58);
  font-size: 10px;
}

.stage-status {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-time {
  display: block;
  margin: 19px 0 2px;
  color: #fff0ae;
  font-size: 22px;
}

.stage-card h3 {
  margin: 0 0 10px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.stage-complete {
  border-color: rgba(56, 201, 146, 0.2);
}

.stage-complete .stage-status {
  color: #79dbb4;
}

.stage-current {
  border-color: rgba(228, 189, 91, 0.4);
  background: linear-gradient(145deg, rgba(228, 189, 91, 0.11), rgba(3, 9, 18, 0.37));
  box-shadow: inset 0 1px 0 rgba(255, 231, 160, 0.08), 0 10px 30px rgba(0, 0, 0, 0.17);
}

.stage-current .stage-status {
  color: var(--gold-light);
}

.stage-warning {
  border-color: rgba(237, 91, 85, 0.28);
}

.stage-warning .stage-status {
  color: var(--red-soft);
}

.stage-empty {
  grid-column: 1 / -1;
  padding: 40px 16px;
  border: 1px dashed var(--line);
  border-radius: 15px;
}

.manual-desk-panel {
  border-color: rgba(228, 189, 91, 0.24);
  background:
    radial-gradient(circle at 92% 0, rgba(228, 189, 91, 0.095), transparent 32rem),
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 44%),
    rgba(10, 20, 37, 0.9);
}

.manual-desk-heading {
  align-items: center;
}

.manual-summary {
  min-width: 132px;
}

.manual-stage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 13px;
  padding: 0 22px 24px;
}

.manual-stage-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(3, 9, 18, 0.42);
}

.manual-state-ready {
  border-color: rgba(237, 91, 85, 0.3);
  box-shadow: inset 3px 0 0 rgba(237, 91, 85, 0.72);
}

.manual-state-empty {
  border-color: rgba(56, 201, 146, 0.2);
  box-shadow: inset 3px 0 0 rgba(56, 201, 146, 0.44);
}

.manual-state-warning,
.manual-state-missed {
  border-color: rgba(228, 189, 91, 0.26);
  box-shadow: inset 3px 0 0 rgba(228, 189, 91, 0.58);
}

.manual-stage-header {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(181, 198, 224, 0.085);
  background: rgba(255, 255, 255, 0.018);
}

.manual-stage-title {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 11px;
}

.manual-stage-title strong {
  flex: 0 0 auto;
  color: var(--gold-light);
  font-size: 21px;
}

.manual-stage-title span {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manual-stage-count,
.manual-buy-badge {
  display: inline-flex;
  min-height: 27px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.manual-state-ready .manual-stage-count,
.manual-buy-badge {
  color: #ffaaa4;
  border-color: rgba(237, 91, 85, 0.26);
  background: rgba(237, 91, 85, 0.09);
}

.manual-state-empty .manual-stage-count {
  color: #79dbb4;
  border-color: rgba(56, 201, 146, 0.2);
  background: rgba(56, 201, 146, 0.07);
}

.manual-stock-list {
  display: grid;
  max-height: 360px;
  overflow-y: auto;
  scrollbar-color: rgba(228, 189, 91, 0.24) transparent;
}

.manual-stock-row {
  display: grid;
  grid-template-columns: minmax(116px, 0.8fr) minmax(124px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid rgba(181, 198, 224, 0.07);
}

.manual-stock-row:last-child {
  border-bottom: 0;
}

.manual-stock-identity {
  min-width: 0;
}

.manual-stock-identity strong,
.manual-stock-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manual-stock-identity strong {
  color: var(--text);
  font-size: 13px;
}

.manual-stock-identity small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.manual-stock-note {
  min-width: 0;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 11px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manual-stage-empty {
  display: grid;
  min-height: 82px;
  align-content: center;
  gap: 4px;
  padding: 15px 16px;
}

.manual-stage-empty strong {
  color: var(--text-soft);
  font-size: 12px;
}

.manual-stage-empty span {
  color: var(--muted);
  font-size: 10px;
}

.data-panel {
  overflow: hidden;
}

.table-wrap {
  position: relative;
  width: 100%;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  scrollbar-color: rgba(228, 189, 91, 0.24) transparent;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(181, 198, 224, 0.075);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: rgba(2, 8, 16, 0.28);
  font-size: 10px;
  font-weight: 680;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

td {
  color: var(--text-soft);
  font-size: 12px;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.stock-cell {
  min-width: 112px;
}

.stock-cell strong,
.stock-cell small,
td > small {
  display: block;
}

.stock-cell strong {
  color: var(--text);
  font-size: 13px;
}

.stock-cell small,
td > small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.note-cell {
  min-width: 210px;
  max-width: 400px;
  line-height: 1.55;
}

.rank-cell,
.score-cell {
  color: var(--gold-light);
  font-weight: 730;
}

.table-badge {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
  font-size: 10px;
  font-weight: 690;
  white-space: nowrap;
}

.action-buy {
  color: #ffaaa4;
  border-color: rgba(237, 91, 85, 0.23);
  background: rgba(237, 91, 85, 0.075);
}

.action-sell {
  color: #83e1bb;
  border-color: rgba(56, 201, 146, 0.22);
  background: rgba(56, 201, 146, 0.07);
}

.action-hold {
  color: var(--gold-light);
  border-color: rgba(228, 189, 91, 0.22);
  background: rgba(228, 189, 91, 0.07);
}

.neutral-badge,
.risk-badge {
  color: #c7d2e2;
}

.table-empty {
  padding: 42px 18px;
  font-size: 12px;
}

.records-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.record-panel {
  min-width: 0;
}

.record-list {
  display: grid;
  gap: 0;
  max-height: 460px;
  padding: 0 24px 22px;
  overflow-y: auto;
}

.record-item {
  position: relative;
  display: grid;
  grid-template-columns: 11px minmax(0, 1fr);
  gap: 13px;
  padding: 15px 0;
  border-bottom: 1px solid rgba(181, 198, 224, 0.075);
}

.record-item:last-child {
  border-bottom: 0;
}

.record-marker {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(228, 189, 91, 0.085);
}

.record-risk .record-marker {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(237, 91, 85, 0.085);
}

.record-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.record-head strong {
  color: var(--text);
  font-size: 13px;
}

.record-head time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.record-body p {
  margin: 5px 0 0;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.6;
}

.record-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.record-empty {
  padding: 8px 24px 40px;
  font-size: 12px;
}

.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 26px 12px 0;
  color: var(--muted);
  font-size: 11px;
}

.viewer-footer img {
  opacity: 0.72;
}

.access-state {
  position: fixed;
  z-index: 90;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(3, 8, 17, 0.83);
  backdrop-filter: blur(17px) saturate(110%);
}

.access-card {
  width: min(480px, 100%);
  padding: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 0, rgba(228, 189, 91, 0.1), transparent 55%),
    #0b1526;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.access-card img {
  margin: 0 auto 19px;
  border-radius: 18px;
  box-shadow: 0 13px 36px rgba(0, 0, 0, 0.32);
}

.access-card h1 {
  margin-bottom: 10px;
  font-size: 26px;
}

.access-card p:not(.eyebrow) {
  margin: 0 auto;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
}

.access-card .button {
  min-width: 130px;
  margin-top: 22px;
}

.access-state[data-state="revoked"] .access-card,
.access-state[data-state="invalid"] .access-card {
  border-color: rgba(237, 91, 85, 0.28);
}

@keyframes status-pulse {
  0%, 100% { opacity: 0.48; transform: scale(0.82); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes skeleton {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@keyframes busy-fade {
  from { opacity: 0.62; }
  to { opacity: 0.9; }
}

@media (max-width: 1180px) {
  .create-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .create-form > .button {
    grid-column: 2;
    align-self: stretch;
  }

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

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

@media (max-width: 900px) {
  .page-shell,
  .admin-shell {
    width: min(100% - 28px, 760px);
    padding-top: 30px;
  }

  .admin-hero,
  .viewer-hero {
    align-items: stretch;
    flex-direction: column;
    gap: 20px;
  }

  .security-note,
  .market-session-card {
    min-width: 0;
    width: 100%;
  }

  .market-session-card {
    text-align: left;
  }

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

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

  .create-form > .button {
    grid-column: auto;
    grid-row: auto;
  }

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

  .records-grid {
    grid-template-columns: 1fr;
  }

  .manual-stage-grid {
    grid-template-columns: 1fr;
  }

  .viewer-status-cluster {
    gap: 10px;
  }

  .viewer-updated {
    display: none;
  }
}

@media (max-width: 680px) {
  :root {
    --radius-xl: 19px;
  }

  html {
    scroll-padding-top: 132px;
  }

  body {
    font-size: 14px;
  }

  .topbar {
    min-height: 68px;
    gap: 12px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .brand img {
    width: 39px;
    height: 39px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .brand-copy small {
    display: none;
  }

  .topbar-meta {
    gap: 9px;
  }

  .topbar-meta .mono {
    display: none;
  }

  .viewer-status-cluster {
    margin-left: auto;
  }

  .viewer-countdown span {
    display: none;
  }

  .viewer-countdown strong {
    font-size: 11px;
  }

  .connection-pill {
    min-height: 27px;
    padding: 4px 8px;
    font-size: 10px;
  }

  .stale-banner {
    top: 68px;
    display: grid;
    gap: 1px;
    padding-block: 7px;
    font-size: 10px;
  }

  .mobile-jump-nav {
    position: sticky;
    z-index: 40;
    top: 68px;
    display: flex;
    gap: 5px;
    padding: 7px var(--safe-right) 7px var(--safe-left);
    overflow-x: auto;
    border-bottom: 1px solid var(--line);
    background: rgba(5, 11, 22, 0.88);
    scrollbar-width: none;
    backdrop-filter: blur(14px);
  }

  .stale-banner:not(.is-hidden) + .mobile-jump-nav {
    top: 110px;
  }

  .mobile-jump-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-jump-nav a {
    flex: 0 0 auto;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.025);
    font-size: 10px;
  }

  .page-shell,
  .admin-shell {
    width: calc(100% - 22px);
    padding-top: 24px;
  }

  .admin-hero,
  .viewer-hero {
    margin-bottom: 23px;
  }

  .admin-hero h1,
  .viewer-hero h1 {
    margin-bottom: 10px;
    font-size: 34px;
  }

  .hero-copy {
    font-size: 13px;
    line-height: 1.65;
  }

  .security-note,
  .market-session-card {
    padding: 14px;
  }

  .panel-heading {
    gap: 13px;
    padding: 20px 17px 17px;
  }

  .panel-heading h2 {
    font-size: 18px;
  }

  .soft-badge {
    max-width: 145px;
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
  }

  .create-form {
    gap: 14px;
    padding: 0 17px 18px;
  }

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

  .form-hint {
    padding: 0 17px 20px;
  }

  .stats-grid,
  .account-grid {
    gap: 9px;
  }

  .stat-card,
  .metric-card {
    padding: 16px;
  }

  .metric-card {
    min-height: 118px;
  }

  .metric-card strong {
    font-size: 20px;
  }

  .link-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .heading-actions {
    width: 100%;
  }

  .compact-select,
  .compact-select select {
    width: 100%;
  }

  .links-list,
  .loading-list {
    padding: 11px;
  }

  .link-card {
    padding: 14px;
  }

  .link-card-head {
    align-items: flex-start;
  }

  .link-title-group {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .viewer-count {
    font-size: 10px;
  }

  .share-link-row {
    align-items: stretch;
    flex-direction: column;
  }

  .share-link-row .button {
    width: 100%;
  }

  .link-meta-grid {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .link-actions,
  .extend-control {
    align-items: stretch;
    flex-direction: column;
  }

  .extend-control {
    flex-basis: auto;
  }

  .extend-select,
  .link-actions .button {
    width: 100%;
    flex: none;
  }

  .stage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 11px 13px;
  }

  .manual-desk-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .manual-summary {
    min-width: 0;
  }

  .manual-stage-grid {
    gap: 9px;
    padding: 0 11px 13px;
  }

  .manual-stage-header,
  .manual-stock-row {
    padding-inline: 13px;
  }

  .manual-stock-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 12px;
  }

  .manual-stock-note {
    grid-column: 1;
    grid-row: 2;
    overflow: visible;
    text-align: left;
    text-overflow: clip;
    white-space: normal;
  }

  .manual-buy-badge {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .stage-card {
    min-height: 174px;
    padding: 13px;
  }

  .stage-time {
    font-size: 19px;
  }

  th,
  td {
    padding: 12px 13px;
  }

  .record-list {
    padding-inline: 17px;
  }

  .access-state {
    padding: 15px;
  }

  .access-card {
    padding: 30px 21px;
  }

  .access-card h1 {
    font-size: 22px;
  }

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

@media (max-width: 410px) {
  .viewer-status-cluster .connection-pill {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .viewer-countdown {
    display: none;
  }

  .stage-grid {
    grid-template-columns: 1fr;
  }

  .stage-card {
    min-height: 150px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
