:root {
  --ink: #18231d;
  --ink-soft: #536158;
  --paper: #f4f0e6;
  --paper-deep: #e8e1d2;
  --card: rgba(255, 253, 247, 0.88);
  --forest: #244d3a;
  --forest-deep: #153629;
  --moss: #7f9673;
  --clay: #c95d3a;
  --clay-soft: #f1c7b7;
  --gold: #d2a54b;
  --line: rgba(24, 35, 29, 0.14);
  --danger: #9f372d;
  --shadow: 0 24px 70px rgba(43, 51, 43, 0.13);
  --display: "Iowan Old Style", "Songti SC", "STSong", serif;
  --sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 78% 18%, rgba(201, 93, 58, 0.14), transparent 28rem),
    radial-gradient(circle at 12% 86%, rgba(127, 150, 115, 0.2), transparent 30rem),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.page-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.35;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(24, 35, 29, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 35, 29, 0.025) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 30px 22px 24px;
  color: #f8f3e9;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.05), transparent 36%),
    var(--forest-deep);
  overflow: auto;
}

.sidebar::after {
  position: absolute;
  right: -70px;
  bottom: 40px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  content: "";
}

.brand {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 13px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 50% 50% 50% 10%;
  color: var(--forest-deep);
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  background: var(--gold);
  transform: rotate(-5deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--display);
  font-size: 19px;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.56);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.primary-nav {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 5px;
  margin-top: 70px;
}

.nav-item {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 6px;
  align-items: center;
  width: 100%;
  padding: 13px 12px;
  border: 0;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.62);
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: 160ms ease;
}

.nav-item span {
  color: rgba(255, 255, 255, 0.3);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.nav-item:hover,
.nav-item:focus-visible {
  color: white;
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.nav-item.is-active {
  color: var(--forest-deep);
  font-weight: 700;
  background: var(--paper);
}

.nav-item.is-active span {
  color: var(--clay);
}

.session-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.session-card small,
.session-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-card small {
  color: rgba(255, 255, 255, 0.47);
  font-size: 10px;
}

.session-card strong {
  margin-top: 2px;
  font-size: 11px;
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9cc38b;
  box-shadow: 0 0 0 5px rgba(156, 195, 139, 0.12);
}

.text-button {
  padding: 4px;
  border: 0;
  color: rgba(255, 255, 255, 0.54);
  font-size: 11px;
  background: transparent;
  cursor: pointer;
}

.main-stage {
  min-width: 0;
  padding: clamp(28px, 5vw, 72px);
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.75fr);
  gap: clamp(50px, 8vw, 130px);
  align-items: center;
  width: min(1120px, 100%);
  min-height: calc(100vh - 144px);
  margin: 0 auto;
}

.login-intro {
  animation: rise 500ms ease-out both;
}

.eyebrow,
.card-kicker {
  margin: 0 0 18px;
  color: var(--clay);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.login-intro h1,
.dashboard-header h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.035em;
}

.login-intro h1 {
  max-width: 720px;
  font-size: clamp(43px, 6vw, 78px);
  line-height: 1.08;
}

.login-intro > p:not(.eyebrow) {
  max-width: 590px;
  margin: 28px 0 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.9;
}

.signal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 34px;
}

.signal-row span,
.environment-badge {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--forest);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.34);
}

.login-card {
  display: grid;
  gap: 21px;
  padding: clamp(28px, 4vw, 48px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 4px 38px 4px 4px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  animation: rise 500ms 90ms ease-out both;
}

.login-card::before {
  width: 58px;
  height: 4px;
  background: var(--clay);
  content: "";
}

.login-card h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 30px;
}

.login-card .card-kicker {
  margin-bottom: 9px;
}

.muted {
  margin: 7px 0 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.login-card label {
  display: grid;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
  transition: 160ms ease;
}

.login-card input:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(36, 77, 58, 0.1);
}

.primary-button,
.secondary-button,
.action-button {
  border: 0;
  cursor: pointer;
  transition: 160ms ease;
}

.primary-button {
  display: flex;
  justify-content: space-between;
  padding: 15px 18px;
  border-radius: 8px;
  color: white;
  font-weight: 700;
  background: var(--forest);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--forest-deep);
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.action-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.security-note {
  margin: -6px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  text-align: center;
}

.form-error {
  margin: -4px 0;
  color: var(--danger);
  font-size: 12px;
}

.dashboard {
  width: min(1440px, 100%);
  margin: 0 auto;
  animation: rise 320ms ease-out both;
}

.dashboard-header {
  display: flex;
  gap: 30px;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.dashboard-header h1 {
  font-size: clamp(36px, 5vw, 58px);
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-bottom: 5px;
}

.environment-badge {
  color: var(--clay);
}

.secondary-button,
.action-button {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--forest);
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.5);
}

.secondary-button:hover,
.action-button:hover {
  border-color: var(--forest);
  background: white;
}

.notice {
  margin-top: 18px;
  padding: 11px 14px;
  border-left: 4px solid var(--moss);
  color: var(--forest);
  font-size: 12px;
  background: rgba(127, 150, 115, 0.14);
}

.notice.is-error {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(159, 55, 45, 0.09);
}

.content {
  padding-top: 28px;
}

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

.stat-card,
.panel,
.table-panel {
  border: 1px solid rgba(255, 255, 255, 0.74);
  background: var(--card);
  box-shadow: 0 12px 35px rgba(43, 51, 43, 0.07);
}

.stat-card {
  position: relative;
  min-height: 150px;
  padding: 22px;
  border-radius: 14px;
  overflow: hidden;
}

.stat-card::after {
  position: absolute;
  right: -18px;
  bottom: -35px;
  width: 88px;
  height: 88px;
  border: 17px solid rgba(36, 77, 58, 0.06);
  border-radius: 50%;
  content: "";
}

.stat-card small {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 19px;
  font-family: var(--display);
  font-size: 46px;
  font-weight: 600;
}

.stat-card em {
  color: var(--clay);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.08em;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
  margin-top: 16px;
}

.panel,
.table-panel {
  border-radius: 14px;
}

.panel {
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.panel-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
}

.panel-heading span {
  color: var(--ink-soft);
  font-size: 10px;
}

.queue-list {
  display: grid;
  gap: 1px;
  background: var(--line);
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  background: var(--card);
}

.queue-item strong,
.queue-item small {
  display: block;
}

.queue-item strong {
  font-size: 13px;
}

.queue-item small {
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 11px;
}

.table-panel {
  overflow: hidden;
}

.table-note {
  margin: 0;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(201, 93, 58, 0.16);
  color: #7e442f;
  font-size: 11px;
  line-height: 1.6;
  background: rgba(241, 199, 183, 0.28);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--ink-soft);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(232, 225, 210, 0.42);
}

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

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

.cell-primary,
.cell-secondary {
  display: block;
}

.cell-primary {
  max-width: 310px;
  font-weight: 700;
}

.cell-secondary {
  max-width: 360px;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.45;
}

.status-pill,
.risk-pill {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  color: var(--forest);
  background: rgba(127, 150, 115, 0.17);
}

.status-pill[data-tone="warning"],
.risk-pill[data-tone="warning"] {
  color: #87531d;
  background: rgba(210, 165, 75, 0.2);
}

.status-pill[data-tone="danger"],
.risk-pill[data-tone="danger"] {
  color: var(--danger);
  background: rgba(159, 55, 45, 0.11);
}

.status-control {
  display: flex;
  gap: 7px;
  min-width: 205px;
}

.status-control select {
  min-width: 105px;
  padding: 8px 25px 8px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.75);
}

.action-button {
  padding: 8px 10px;
  font-size: 10px;
}

.empty-state,
.loading-state {
  padding: 60px 24px;
  color: var(--ink-soft);
  text-align: center;
}

.loading-state::before {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 15px;
  border: 3px solid var(--paper-deep);
  border-top-color: var(--clay);
  border-radius: 50%;
  content: "";
  animation: spin 800ms linear infinite;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

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

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 205px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 16px;
  }

  .login-layout {
    grid-template-columns: 1fr;
    gap: 42px;
    padding-block: 30px;
  }

  .login-intro h1 {
    font-size: clamp(42px, 8vw, 70px);
  }

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

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    display: block;
    height: auto;
    padding: 18px;
  }

  .sidebar::after {
    display: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .primary-nav {
    display: flex;
    gap: 6px;
    margin-top: 18px;
    padding-bottom: 2px;
    overflow-x: auto;
  }

  .nav-item {
    display: block;
    width: auto;
    min-width: max-content;
    padding: 9px 11px;
    font-size: 11px;
  }

  .nav-item span {
    display: none;
  }

  .session-card {
    margin-top: 14px;
    padding-top: 12px;
  }

  .main-stage {
    padding: 28px 18px 50px;
  }

  .login-layout {
    min-height: auto;
  }

  .login-intro h1 {
    font-size: 42px;
  }

  .dashboard-header,
  .header-actions {
    align-items: flex-start;
  }

  .dashboard-header {
    flex-direction: column;
  }

  .header-actions {
    flex-wrap: wrap;
  }

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

@media (max-width: 480px) {
  .login-intro h1 {
    font-size: 35px;
  }

  .login-card {
    padding: 25px 20px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stat-card {
    min-height: 124px;
    padding: 16px;
  }

  .stat-card strong {
    margin-top: 13px;
    font-size: 35px;
  }
}

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