:root {
  --bg: #0f0d0b;
  --bg-alt: #171310;
  --panel: rgba(22, 18, 16, 0.92);
  --panel-strong: rgba(31, 25, 22, 0.96);
  --panel-soft: rgba(255, 255, 255, 0.03);
  --text: #f3ecdf;
  --muted: #baa98e;
  --line: rgba(255, 242, 224, 0.1);
  --line-strong: rgba(255, 242, 224, 0.18);
  --lime: #d8ff63;
  --gold: #f6c772;
  --orange: #ff8c42;
  --sand: #f2dfbf;
  --danger: #ff6c57;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(216, 255, 99, 0.12), transparent 24rem),
    radial-gradient(circle at 100% 10%, rgba(255, 140, 66, 0.12), transparent 22rem),
    linear-gradient(180deg, #181411 0%, #0f0d0b 100%);
  font-family: "IBM Plex Sans", sans-serif;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 4px 4px, 4px 4px;
  mix-blend-mode: soft-light;
}

.shell {
  width: min(1500px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.status-banner:empty {
  display: none;
}

.status-banner {
  margin-bottom: 1rem;
}

.banner-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255, 108, 87, 0.26);
  background: rgba(255, 108, 87, 0.08);
  color: var(--sand);
  box-shadow: var(--shadow);
}

.hero,
.summary-card,
.panel,
.mini-panel {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.8fr);
  gap: 1rem;
  padding: 1.35rem;
  background:
    linear-gradient(135deg, rgba(34, 28, 25, 0.94), rgba(17, 14, 12, 0.92)),
    linear-gradient(180deg, rgba(216, 255, 99, 0.04), transparent);
}

.hero-copy h1 {
  margin: 0.35rem 0 0.8rem;
  max-width: 12ch;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.6rem, 5.8vw, 4.9rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
}

.hero-text,
.summary-note,
.panel-meta,
.warning-copy,
.identity-row small,
.empty-state p {
  color: var(--muted);
}

.hero-utility {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.language-switch {
  display: grid;
  gap: 0.4rem;
  justify-items: end;
}

.language-button-row {
  display: inline-flex;
  gap: 0.45rem;
  padding: 0.25rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.lang-button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  min-height: 2.3rem;
  padding: 0.5rem 0.8rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition:
    color 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.lang-button.is-active {
  color: var(--text);
  border-color: rgba(216, 255, 99, 0.3);
  background: rgba(216, 255, 99, 0.08);
}

.hero-aside {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.phase-cluster,
.uptime-card,
.control-panel,
.summary-card,
.panel,
.mini-panel {
  background: linear-gradient(180deg, var(--panel-strong), rgba(19, 16, 14, 0.94));
  backdrop-filter: blur(14px);
}

.phase-cluster,
.uptime-card,
.control-panel {
  padding: 1rem;
}

.phase-cluster {
  display: grid;
  gap: 0.9rem;
}

.control-panel {
  display: grid;
  gap: 0.9rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.control-status-row {
  display: grid;
  gap: 0.45rem;
}

.control-button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.control-button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  color: var(--text);
  min-height: 3rem;
  padding: 0.85rem 0.95rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease,
    opacity 140ms ease;
}

.control-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22);
}

.control-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.control-button.is-start {
  border-color: rgba(216, 255, 99, 0.3);
  color: var(--lime);
}

.control-button.is-stop {
  border-color: rgba(255, 108, 87, 0.28);
  color: var(--danger);
}

.control-button.is-restart {
  border-color: rgba(246, 199, 114, 0.28);
  color: var(--gold);
}

.control-note {
  min-height: 3.4rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  line-height: 1.5;
}

.phase-copy strong,
.uptime-card strong {
  display: block;
  margin: 0.35rem 0 0.2rem;
  font-size: 1.5rem;
}

.phase-pill,
.status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: fit-content;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.02);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.status-tag {
  padding: 0.5rem 0.75rem;
  letter-spacing: 0.12em;
}

.is-active {
  color: var(--lime);
}

.is-warning {
  color: var(--gold);
}

.is-danger {
  color: var(--danger);
}

.is-ok {
  color: var(--sand);
}

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

.eyebrow,
.identity-label,
.summary-label,
.data-chip span,
.tx-item span,
.scope-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--gold);
}

.identity-row {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.identity-row strong {
  font-size: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.summary-card {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  min-height: 8.7rem;
}

.summary-card::after {
  content: "";
  position: absolute;
  inset: auto -18% -48% auto;
  width: 9rem;
  height: 9rem;
  border-radius: 50%;
  opacity: 0.12;
}

.accent-lime::after {
  background: var(--lime);
}

.accent-gold::after {
  background: var(--gold);
}

.accent-orange::after {
  background: var(--orange);
}

.accent-sand::after {
  background: var(--sand);
}

.summary-value {
  display: block;
  margin: 0.7rem 0 0.4rem;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  line-height: 1;
}

.deck-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(320px, 0.88fr);
  gap: 1rem;
  margin-top: 1rem;
}

.intel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 1rem;
  margin-top: 1rem;
}

.panel {
  padding: 1rem;
}

.wide-panel {
  grid-column: 1 / -1;
}

.emphasis-panel {
  position: relative;
  overflow: hidden;
}

.emphasis-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(216, 255, 99, 0.1), transparent 30%),
    linear-gradient(180deg, rgba(246, 199, 114, 0.04), transparent 45%);
  pointer-events: none;
}

.stack-panel {
  display: grid;
  gap: 1rem;
}

.mini-panel {
  padding: 1rem;
}

.mini-head h3,
.panel-head h2 {
  margin: 0.25rem 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
  line-height: 1;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.panel-meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}

.route-block {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(216, 255, 99, 0.16);
  background: rgba(216, 255, 99, 0.04);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  word-break: break-word;
  direction: ltr;
  text-align: left;
}

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

.data-chip {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.data-chip strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--text);
  word-break: break-word;
}

.decision-box {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.signal-box {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.signal-head {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}

.signal-head strong {
  font-size: 1.1rem;
}

.subsection-block {
  margin-top: 1rem;
  display: grid;
  gap: 0.65rem;
}

.subsection-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.warning-copy {
  margin: 1rem 0 0;
  line-height: 1.6;
}

.scroll-panel {
  max-height: 40rem;
  overflow: auto;
  padding-right: 0.15rem;
}

.compact-scroll {
  max-height: 32rem;
}

.scroll-panel::-webkit-scrollbar {
  width: 10px;
}

.scroll-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.list-stack {
  display: grid;
  gap: 0.8rem;
}

.list-card {
  display: grid;
  gap: 0.85rem;
  padding: 0.95rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.compact-card .key-grid {
  margin-top: 0.2rem;
}

.danger-card {
  border-color: rgba(255, 108, 87, 0.24);
  background: rgba(255, 108, 87, 0.05);
}

.warning-card {
  border-color: rgba(246, 199, 114, 0.24);
  background: rgba(246, 199, 114, 0.05);
}

.list-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
}

.meter-stack {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.meter-row {
  display: grid;
  gap: 0.45rem;
}

.meter-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.meter-head strong {
  color: var(--sand);
  font-size: 0.84rem;
}

.meter-bar {
  height: 0.7rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.meter-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--lime), var(--gold) 60%, var(--orange));
}

.tx-list {
  display: grid;
  gap: 0.6rem;
}

.tx-item {
  display: grid;
  gap: 0.3rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.tx-item strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.84rem;
  word-break: break-word;
  color: var(--sand);
  direction: ltr;
  text-align: left;
}

.scope-label {
  color: var(--danger);
}

.empty-state {
  display: grid;
  gap: 0.5rem;
  padding: 1.3rem;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.empty-state strong {
  font-size: 1rem;
}

.loading-panel {
  min-height: 50vh;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

@media (max-width: 1080px) {
  .hero,
  .intel-grid,
  .deck-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 1rem, 100%);
    padding-top: 0.5rem;
  }

  .hero,
  .panel,
  .mini-panel,
  .summary-card {
    padding: 0.9rem;
  }

  .hero-copy h1 {
    max-width: none;
  }

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

  .list-head,
  .banner-card,
  .identity-row,
  .hero-utility,
  .signal-head,
  .subsection-head,
  .meter-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-button-row {
    grid-template-columns: 1fr;
  }
}

body[data-ui-language="ar"] .language-switch {
  justify-items: start;
}
