* {
  box-sizing: border-box;
}

:root {
  --bg: #080808;
  --s1: #0e0e0e;
  --s2: #141414;
  --s3: #1c1c1c;
  --line: #252525;
  --line-strong: #333;
  --text: #e6e6e6;
  --muted: #8a8a8a;
  --accent: #f6821f;
  --accent-2: #f9a55a;
  --green: #00e676;
  --blue: #2979ff;
  --font-mono: "IBM Plex Mono", monospace;
  --font-sans: "IBM Plex Sans", sans-serif;
  --font-display: "Bebas Neue", sans-serif;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(circle at 20% 20%, #191919 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, #251809 0%, transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.012) 3px,
    rgba(255, 255, 255, 0.012) 4px
  );
}

.app-shell {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  background: var(--s1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  line-height: 1;
}

.brand em {
  color: var(--accent);
  font-style: normal;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  border: 1px solid var(--line-strong);
  background: var(--s3);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge strong {
  color: var(--accent);
}

.agent-status {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.65rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot.paused {
  background: #ffd600;
}

.dot.live {
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}

.metrics-bar {
  background: var(--s1);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  padding: 0.65rem 0.85rem;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: none;
}

.metric-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: 0.04em;
}

.metric-value.orange {
  color: var(--accent);
}

.metric-value.green {
  color: var(--green);
}

.metric-value.blue {
  color: var(--blue);
}

.metric-label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.56rem;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 420px 340px 280px;
  height: 100%;
  min-height: 0;
}

.panel {
  border-right: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(20, 20, 20, 0.95), rgba(10, 10, 10, 0.95));
}

.panel:last-child {
  border-right: none;
}

.panel-head {
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  background: var(--s1);
  padding: 0.55rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.actions-bar {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--s2);
}

.btn {
  border: 1px solid transparent;
  border-radius: 4px;
  min-height: 36px;
  padding: 0.45rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: 160ms ease;
}

.btn.primary {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.btn.secondary {
  background: #2a2a2a;
  border-color: #3a3a3a;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line-strong);
}

.btn:hover {
  filter: brightness(1.12);
}

.btn.compact {
  min-height: 30px;
  padding: 0.25rem 0.5rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--s1);
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.55rem;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.panel-body {
  padding: 0.8rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.profile-panel .panel-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-panel {
  display: none;
}

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

.profile-card {
  border: 1px solid var(--line);
  background: var(--s2);
  border-radius: 6px;
  height: 48px;
  padding: 0.35rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  overflow: hidden;
}

.profile-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.profile-link:hover .profile-card {
  border-color: var(--accent);
}

.profile-picture {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--accent);
}

.label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.56rem;
}

.profile-name {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-card .label {
  display: none;
}

.cv-section {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

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

.cv-head .label {
  margin: 0;
}

.cv-content {
  margin-top: 0.4rem;
  min-height: 0;
  max-height: none;
  flex: 1;
  font-size: 0.7rem;
  line-height: 1.45;
  border: 1px solid var(--line-strong);
  background: #0d0d0d;
  border-radius: 4px;
  padding: 0.65rem;
  overflow: auto;
}

.cv-content h1,
.cv-content h2,
.cv-content h3,
.cv-content h4 {
  font-family: var(--font-sans);
  margin: 0.9rem 0 0.45rem;
  line-height: 1.25;
}

.cv-content h1 {
  font-size: 1rem;
}

.cv-content h2 {
  font-size: 0.9rem;
  color: var(--accent);
}

.cv-content h3 {
  font-size: 0.8rem;
}

.cv-content p,
.cv-content li {
  font-size: 0.72rem;
  color: var(--text);
}

.cv-content ul {
  margin: 0.4rem 0 0.6rem;
  padding-left: 1.1rem;
}

.cv-content a {
  color: var(--accent-2);
  text-decoration: none;
}

.cv-content a:hover {
  text-decoration: underline;
}

.composer {
  display: grid;
  gap: 0.55rem;
}

.post-text,
pre,
.jobs-list {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #0d0d0d;
  color: var(--text);
  border-radius: 4px;
  font-family: var(--font-mono);
}

.post-text {
  min-height: 120px;
  padding: 0.65rem;
  resize: vertical;
}

pre {
  margin: 0;
  min-height: 160px;
  max-height: 44vh;
  overflow: auto;
  padding: 0.65rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
}

.post-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

#post-status,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.65rem;
}

.jobs-list {
  min-height: 320px;
  padding: 0.6rem;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
}

.cloudflare-panel .panel-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cloudflare-panel .jobs-list {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.job-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.65rem;
  background: var(--s2);
}

.job-card + .job-card {
  margin-top: 0.5rem;
}

.job-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
}

.job-title a {
  color: #f0f0f0;
}

.job-meta {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.58rem;
}

.log-list {
  display: grid;
  gap: 0.35rem;
}

.log-item {
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  background: var(--s2);
  border-radius: 4px;
  padding: 0.5rem;
}

.log-time {
  margin: 0;
  color: var(--muted);
  font-size: 0.55rem;
}

.log-text {
  margin: 0.2rem 0 0;
  font-size: 0.65rem;
  line-height: 1.45;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  height: 100%;
  flex: 1;
  min-height: 0;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--s2);
  padding: 0.55rem;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.chart-title {
  margin: 0 0 0.35rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.55rem;
}

.chart-canvas-wrap {
  position: relative;
  min-height: 0;
  height: 100%;
}

.chart-card canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.plots-panel .panel-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

#panel-profile.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1180px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
    min-height: 320px;
  }

  .panel:last-child {
    border-bottom: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 0.6rem;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }

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

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

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

  .chart-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-rows: minmax(190px, 220px);
    height: auto;
  }

  .plots-panel .panel-body {
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

}
