:root {
  --bg: #f4efe6;
  --card: rgba(255, 252, 247, 0.92);
  --line: rgba(54, 41, 30, 0.12);
  --text: #1f1710;
  --muted: #725f4d;
  --accent: #b74d1c;
  --accent-soft: rgba(183, 77, 28, 0.14);
  --success: #146b3a;
  --error: #ab2b2b;
  --shadow: 0 18px 40px rgba(52, 35, 22, 0.12);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(221, 143, 70, 0.18), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(34, 112, 84, 0.14), transparent 24rem),
    linear-gradient(180deg, #f6f2eb 0%, #ece4d8 100%);
}

a {
  color: inherit;
}

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

button {
  border: 0;
  border-radius: 999px;
  padding: 0.66rem 1rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

button.danger {
  color: var(--error);
  border-color: rgba(171, 43, 43, 0.24);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.72rem 0.9rem;
  background: rgba(255, 255, 255, 0.82);
}

textarea {
  resize: vertical;
}

.topbar,
.auth-card,
.share-card,
.panel {
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  padding: 1.2rem 1.4rem;
  margin: 1rem;
  border-radius: 24px;
}

.topbar h1,
.auth-card h1,
.share-card h1 {
  margin: 0;
  font-size: 1.7rem;
}

.topbar p,
.auth-card p,
.share-card p,
.panel-head p,
.inline-note {
  color: var(--muted);
}

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

.panel {
  border-radius: 24px;
  padding: 1rem;
  min-height: 12rem;
}

.detail-panel {
  grid-column: span 2;
}

.panel-head,
.detail-top,
.share-status,
.actions,
.share-link-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.panel-head {
  align-items: start;
  margin-bottom: 0.75rem;
}

.panel-head > div {
  display: grid;
  gap: 0.45rem;
}

.panel-head h2,
.timeline h3 {
  margin: 0;
}

.panel-head-subtle {
  margin: 0.9rem 0 0.55rem;
}

.panel-head-subtle h3 {
  margin: 0;
}

.stack-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.stack-form label {
  display: grid;
  gap: 0.45rem;
  font-size: 0.94rem;
  color: var(--muted);
}

.stack-form button {
  align-self: end;
}

.compact-form {
  margin-top: 0.5rem;
}

.full-span {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.service-browser {
  margin-top: 0.9rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

.service-browser-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
}

.service-browser-tools input {
  flex: 1 1 auto;
  min-width: 12rem;
}

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

.marketplace-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 1rem;
}

.marketplace-column {
  min-width: 0;
}

.table-shell {
  overflow: auto;
  max-height: 18rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.compact-table {
  max-height: 14rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 0.55rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr.is-selected {
  background: rgba(183, 77, 28, 0.08);
}

th {
  color: var(--muted);
  font-weight: 600;
}

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

.mono {
  font-family: "SFMono-Regular", "JetBrains Mono", monospace;
}

.otp-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.otp-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(183, 77, 28, 0.12), rgba(183, 77, 28, 0.03));
  margin: 0.8rem 0;
}

.otp-card strong {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1;
}

.otp-card small {
  color: var(--muted);
  word-break: break-word;
}

.otp-empty {
  opacity: 0.78;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 0.8rem 0;
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.value {
  margin-top: 0.15rem;
  font-size: 0.95rem;
}

.status-stack {
  display: grid;
  gap: 0.18rem;
}

.order-meta-stack {
  display: grid;
  gap: 0.18rem;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  background: rgba(183, 77, 28, 0.08);
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-note {
  color: #8a4d11;
  font-size: 0.75rem;
}

.order-pick {
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.order-pick:hover,
.order-pick:focus-visible {
  border-color: currentColor;
}

.order-pick.is-selected {
  color: var(--accent);
}

.row-action-cell {
  white-space: nowrap;
}

.row-action-button {
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  font-size: 0.82rem;
}

.local-detail-shell {
  margin-top: 0.9rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

.actions {
  justify-content: start;
  flex-wrap: wrap;
  margin: 0.8rem 0;
}

.assign-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  margin: 0.8rem 0;
}

.share-box {
  padding: 0.6rem 0 0.2rem;
}

.share-link-row input {
  flex: 1;
}

.share-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 4rem;
  border-radius: 999px;
  padding: 0.66rem 0.95rem;
  text-decoration: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.timeline {
  margin-top: 0.8rem;
  max-height: 18rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
  padding: 0.2rem 0;
}

.timeline table {
  font-size: 0.84rem;
}

.alert {
  display: inline-flex;
  padding: 0.65rem 0.9rem;
  border-radius: 14px;
  background: rgba(32, 32, 32, 0.06);
}

.alert.info {
  background: rgba(35, 102, 180, 0.12);
}

.alert.success {
  background: rgba(20, 107, 58, 0.12);
  color: var(--success);
}

.alert.warning {
  background: rgba(183, 126, 28, 0.14);
  color: #8a4d11;
}

.alert.error {
  background: rgba(171, 43, 43, 0.12);
  color: var(--error);
}

.archive-note {
  display: flex;
  margin: 0.55rem;
}

.reply-card {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.token-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  margin-top: 0.5rem;
}

.auth-shell,
.share-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card,
.share-card {
  width: min(34rem, 100%);
  padding: 2rem;
  border-radius: 30px;
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.share-card {
  width: min(46rem, 100%);
}

@media (max-width: 980px) {
  .admin-grid,
  .remote-columns,
  .marketplace-grid,
  .detail-grid,
  .stack-form {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    grid-column: auto;
  }

  .topbar,
  .panel-head,
  .detail-top,
  .share-status {
    flex-direction: column;
    align-items: start;
  }

  .service-browser-tools {
    flex-direction: column;
    align-items: stretch;
  }

  .assign-row,
  .token-form {
    grid-template-columns: 1fr;
  }

  .full-span {
    grid-column: auto;
  }
}
