:root {
  color-scheme: dark;
  --ink: #161615;
  --paper: #fbf7ef;
  --paper-2: #f3eadc;
  --panel: rgba(255, 252, 244, 0.94);
  --panel-strong: #fffaf0;
  --line: rgba(22, 22, 21, 0.12);
  --line-dark: rgba(255, 255, 255, 0.14);
  --muted: #6f706d;
  --soft: #9b9386;
  --black: #0c0f0e;
  --sidebar: #101311;
  --orange: #ff5a1f;
  --cyan: #06b6d4;
  --gold: #f8c46b;
  --green: #38a169;
  --red: #e05243;
  --blue: #3875d7;
  --shadow: 0 26px 70px rgba(20, 20, 18, 0.16);
  --shadow-soft: 0 14px 40px rgba(20, 20, 18, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 90, 31, 0.08), transparent 34%),
    linear-gradient(160deg, #fffaf0 0%, #f5efe5 42%, #e9f7f8 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

input,
select,
textarea {
  width: 100%;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  min-height: 40px;
  padding: 0 11px;
  outline: 0;
}

textarea {
  min-height: 86px;
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(6, 182, 212, 0.65);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.12);
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  color: #f7f3ea;
  background:
    radial-gradient(circle at 20% 12%, rgba(255, 90, 31, 0.22), transparent 14rem),
    radial-gradient(circle at 80% 38%, rgba(6, 182, 212, 0.18), transparent 16rem),
    var(--sidebar);
  border-right: 1px solid var(--line-dark);
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong {
  display: block;
  font-size: 18px;
  letter-spacing: 0;
}

.brand span,
.admin-card p {
  display: block;
  margin: 2px 0 0;
  color: rgba(247, 243, 234, 0.66);
  font-size: 13px;
}

.brand-mark,
.kpi-icon,
.icon-button {
  display: grid;
  place-items: center;
  border-radius: var(--radius);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(145deg, rgba(255, 90, 31, 0.9), rgba(6, 182, 212, 0.78));
  box-shadow: 0 14px 32px rgba(255, 90, 31, 0.18);
}

svg {
  width: 1em;
  height: 1em;
}

.brand-mark svg,
.nav-item svg,
.ghost-button svg,
.primary-button svg,
.outline-button svg,
.mini-button svg,
.icon-button svg,
.search-box svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.main-nav {
  display: grid;
  gap: 6px;
}

.nav-item,
.project-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  color: rgba(247, 243, 234, 0.74);
  border-radius: var(--radius);
  background: transparent;
  padding: 0 12px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover,
.project-button.active,
.project-button:hover {
  color: #fffaf0;
  background: rgba(255, 255, 255, 0.1);
}

.side-block {
  display: grid;
  gap: 10px;
}

.side-label,
.eyebrow {
  color: var(--soft);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.project-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 99px;
  background: var(--dot);
  box-shadow: 0 0 22px var(--dot);
}

.admin-card {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.07);
}

.admin-card input {
  color: #fffaf0;
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(255, 255, 255, 0.14);
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
}

.main {
  min-width: 0;
  padding: 30px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 540px);
  gap: 28px;
  align-items: start;
}

.hero h1 {
  max-width: 760px;
  margin-bottom: 14px;
  font-size: clamp(36px, 5vw, 70px);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy,
.lead {
  max-width: 660px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.hero-actions {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
}

.search-box input {
  min-height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.primary-button,
.ghost-button,
.outline-button,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-weight: 780;
  white-space: nowrap;
}

.primary-button {
  color: #211006;
  border: 1px solid rgba(255, 90, 31, 0.5);
  background: linear-gradient(135deg, var(--orange), #ffb15f);
  box-shadow: 0 14px 28px rgba(255, 90, 31, 0.22);
}

.ghost-button,
.outline-button,
.mini-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
}

.outline-button:hover,
.ghost-button:hover,
.mini-button:hover {
  border-color: rgba(6, 182, 212, 0.45);
  background: rgba(255, 255, 255, 0.9);
}

.icon-button {
  width: 38px;
  height: 38px;
  color: inherit;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
}

.icon-button.danger {
  color: var(--red);
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 26px 0 18px;
}

.kpi-card,
.panel,
.drawer-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  min-height: 112px;
  padding: 15px;
}

.kpi-icon {
  width: 42px;
  height: 42px;
  color: #0c272d;
  background: linear-gradient(145deg, rgba(6, 182, 212, 0.28), rgba(255, 90, 31, 0.18));
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
}

.kpi-card strong {
  display: block;
  margin-top: 2px;
  font-size: 30px;
  line-height: 1;
}

.kpi-card p {
  margin: 7px 0 0;
  color: var(--soft);
  font-size: 12px;
}

.command-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 18px;
  align-items: start;
}

.operations-grid,
.connect-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 3px 0 0;
  font-size: 24px;
}

.detail-panel {
  position: sticky;
  top: 24px;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.agent-grid.wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.agent-card {
  min-height: 252px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4)),
    radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--agent) 24%, transparent), transparent 18rem);
  box-shadow: var(--shadow-soft);
}

.agent-card.selected {
  border-color: color-mix(in srgb, var(--agent) 72%, #ffffff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--agent) 18%, transparent), var(--shadow);
}

.agent-card-top,
.agent-foot,
.with-mini-avatar,
.action-row,
.row-actions,
.approval-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-card-top,
.agent-foot {
  justify-content: space-between;
}

.agent-card h3 {
  margin: 0 0 5px;
  font-size: 20px;
}

.agent-card p,
.agent-work,
.agent-foot,
.profile-section p,
.event-item p,
.compact-item span,
.approval-card p,
.approval-card span,
.cron-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.agent-work {
  min-height: 40px;
  margin-top: 12px;
}

.agent-meter,
.progress-line {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(22, 22, 21, 0.1);
}

.agent-meter span,
.progress-line span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--agent, var(--cyan)), color-mix(in srgb, var(--agent, var(--cyan)) 35%, #fff));
}

.agent-portrait {
  width: 76px;
  height: 76px;
  display: inline-grid;
  place-items: center;
  color: var(--agent);
  flex: 0 0 auto;
}

.agent-portrait.large {
  width: 108px;
  height: 108px;
}

.agent-portrait.tiny {
  width: 34px;
  height: 34px;
}

.agent-portrait svg {
  width: 100%;
  height: 100%;
}

.portrait-bg {
  fill: color-mix(in srgb, var(--agent) 18%, #ffffff);
  stroke: color-mix(in srgb, var(--agent) 72%, #141414);
  stroke-width: 2;
}

.portrait-ring {
  fill: rgba(255, 255, 255, 0.66);
  stroke: color-mix(in srgb, var(--agent) 55%, #111);
  stroke-width: 1.5;
}

.portrait-core {
  fill: color-mix(in srgb, var(--agent) 18%, #fff);
  stroke: rgba(22, 22, 21, 0.22);
  stroke-width: 1.5;
}

.portrait-line,
.portrait-circuit {
  fill: none;
  stroke: #16201f;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portrait-fill {
  fill: #16201f;
}

.portrait-hole {
  fill: var(--panel-strong);
}

.status-chip,
.priority-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.status-online,
.status-done,
.status-active,
.status-approved {
  color: #0f4d2d;
  background: rgba(56, 161, 105, 0.16);
}

.status-busy,
.status-in_progress {
  color: #075266;
  background: rgba(6, 182, 212, 0.16);
}

.status-waiting,
.status-watch,
.status-paused {
  color: #7b5100;
  background: rgba(248, 196, 107, 0.24);
}

.status-error,
.status-blocked,
.status-rejected {
  color: #892318;
  background: rgba(224, 82, 67, 0.15);
}

.status-setup,
.status-backlog {
  color: #58534b;
  background: rgba(22, 22, 21, 0.08);
}

.priority-critical {
  color: #892318;
  background: rgba(224, 82, 67, 0.16);
}

.priority-high {
  color: #8d310c;
  background: rgba(255, 90, 31, 0.16);
}

.priority-normal {
  color: #075266;
  background: rgba(6, 182, 212, 0.16);
}

.agent-profile {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 14px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.agent-profile h2 {
  margin: 3px 0 5px;
  font-size: 28px;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 15px 0;
}

.profile-stats div,
.compact-item,
.event-item,
.approval-card,
.cron-card,
.code-card,
.token-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.54);
}

.profile-stats div {
  padding: 11px;
}

.profile-stats span {
  display: block;
  color: var(--soft);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.profile-stats strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
}

.skill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.skill-row span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  padding: 0 9px;
  color: #0b3d45;
  background: rgba(6, 182, 212, 0.14);
  font-size: 12px;
  font-weight: 760;
}

.profile-section {
  margin-top: 16px;
}

.compact-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 10px;
}

.task-table {
  display: grid;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.45fr) minmax(120px, 0.75fr) minmax(92px, 0.55fr) minmax(120px, 0.62fr) minmax(110px, 0.55fr) 84px;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  border-top: 1px solid var(--line);
  padding: 11px 0;
}

.table-row:first-child {
  border-top: 0;
}

.table-head {
  min-height: 34px;
  color: var(--soft);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.table-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-row select {
  min-height: 34px;
}

.row-actions {
  justify-content: flex-end;
}

.calendar-grid,
.approval-list,
.timeline {
  display: grid;
  gap: 10px;
}

.cron-card {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
}

.cron-date {
  display: grid;
  place-items: center;
  min-height: 70px;
  border-radius: var(--radius);
  color: #09292f;
  background: linear-gradient(145deg, rgba(6, 182, 212, 0.22), rgba(248, 196, 107, 0.18));
}

.cron-date strong {
  font-size: 18px;
}

.cron-date span {
  color: var(--muted);
  font-size: 12px;
}

.approval-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
}

.approval-actions {
  justify-content: flex-end;
}

.event-item {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 9px;
  padding: 10px;
}

.event-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 99px;
  background: var(--cyan);
  box-shadow: 0 0 18px var(--cyan);
}

.severity-danger .event-dot {
  background: var(--red);
  box-shadow: 0 0 18px var(--red);
}

.severity-warning .event-dot {
  background: var(--gold);
  box-shadow: 0 0 18px var(--gold);
}

.severity-success .event-dot {
  background: var(--green);
  box-shadow: 0 0 18px var(--green);
}

.connect-main {
  min-height: 420px;
}

.code-card,
.token-box {
  position: relative;
  margin-top: 18px;
  padding: 14px;
}

.copy-code {
  position: absolute;
  right: 12px;
  top: 12px;
}

pre {
  margin: 0;
  overflow: auto;
  color: #0f312f;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  justify-items: end;
  background: rgba(14, 17, 16, 0.42);
  backdrop-filter: blur(6px);
}

.drawer[hidden] {
  display: none;
}

.drawer-panel {
  width: min(520px, calc(100vw - 24px));
  min-height: 100vh;
  padding: 20px;
  overflow: auto;
  border-radius: 0;
}

.empty-state {
  min-height: 88px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.36);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: 380px;
  padding: 13px 14px;
  color: #fffaf0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: rgba(16, 19, 17, 0.94);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

@media (max-width: 1500px) {
  .agent-grid,
  .agent-grid.wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .app-shell,
  .hero,
  .command-grid,
  .operations-grid,
  .connect-grid {
    grid-template-columns: 1fr;
  }

  .sidebar,
  .detail-panel {
    position: static;
    height: auto;
  }

  .sidebar {
    border-right: 0;
  }

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

  .search-box {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .main {
    padding: 18px;
  }

  .hero-actions,
  .kpi-strip,
  .agent-grid,
  .agent-grid.wide,
  .profile-stats,
  .table-row,
  .cron-card,
  .approval-card {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .agent-profile,
  .approval-actions,
  .row-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .hero h1 {
    font-size: 38px;
  }
}
