:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --bg-soft: #f1eee7;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --text: #172033;
  --muted: #697386;
  --border: #e5e1d8;
  --primary: #172033;
  --primary-contrast: #ffffff;
  --primary-soft: #e9edf4;
  --healthy: #178a7a;
  --healthy-soft: #e8f4f1;
  --warning: #c17a17;
  --warning-soft: #fff4de;
  --danger: #b54747;
  --danger-soft: #fceaea;
  --unknown: #8290a3;
  --shadow: 0 8px 24px rgb(23 32 51 / 0.06);
  --radius: 14px;
  --nav-width: 0px;
  --focus: #178a7a;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090d14;
  --bg-soft: #0d1420;
  --surface: #111927;
  --surface-2: #151f2e;
  --text: #f4f7fa;
  --muted: #8fa3b8;
  --border: #263548;
  --primary: #39d6e6;
  --primary-contrast: #061016;
  --primary-soft: #12313c;
  --healthy: #39d6e6;
  --healthy-soft: #102d36;
  --warning: #f5b84b;
  --warning-soft: #302512;
  --danger: #ff7b7b;
  --danger-soft: #34191d;
  --unknown: #71869b;
  --shadow: 0 8px 30px rgb(0 0 0 / 0.22);
  --radius: 11px;
  --focus: #39d6e6;
}

html[data-theme="hybrid"] {
  color-scheme: light;
  --bg: #f5f5f2;
  --bg-soft: #eeeeea;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --text: #202331;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #635bff;
  --primary-contrast: #ffffff;
  --primary-soft: #eeecff;
  --healthy: #22a06b;
  --healthy-soft: #e8f6ef;
  --warning: #d18418;
  --warning-soft: #fff3df;
  --danger: #ba3d4f;
  --danger-soft: #fce9ec;
  --unknown: #7b8495;
  --shadow: 0 8px 28px rgb(32 35 49 / 0.08);
  --radius: 12px;
  --nav-width: 188px;
  --focus: #635bff;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  transition:
    background-color 160ms ease-out,
    color 160ms ease-out;
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 65%, transparent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow.warning {
  color: var(--warning);
}

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

h1 {
  margin-bottom: 2px;
  font-size: clamp(1.8rem, 3vw, 2.35rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.3rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.02rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 3px);
  padding: 10px 18px;
  font-weight: 750;
  transition:
    transform 150ms ease-out,
    box-shadow 150ms ease-out,
    opacity 150ms ease-out;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgb(0 0 0 / 0.11);
}

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

.button-primary {
  background: var(--primary);
  color: var(--primary-contrast);
}

.button-secondary {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.button-warning {
  background: var(--warning);
  color: #1e1608;
}

.button-danger-quiet {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: transparent;
  color: var(--danger);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 1.2rem;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--unknown);
}

.status-dot.ok,
.status-dot.online {
  background: var(--healthy);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--healthy) 14%, transparent);
}

.status-dot.offline,
.status-dot.error {
  background: var(--danger);
}

.status-dot.warning {
  background: var(--warning);
}

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

.brand-mark {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  border-radius: 18px;
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 850;
  letter-spacing: -0.08em;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(
      circle at 12% 10%,
      color-mix(in srgb, var(--primary) 12%, transparent),
      transparent 36%
    ),
    var(--bg);
}

.login-panel {
  width: min(100%, 460px);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 38px;
  background: var(--surface);
  box-shadow: 0 28px 80px rgb(17 24 39 / 0.12);
}

.login-panel .brand-mark {
  margin-bottom: 28px;
}

.login-panel > p:not(.eyebrow, .local-note) {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

input,
select {
  min-height: 44px;
  padding: 8px 12px;
}

textarea {
  min-height: 76px;
  resize: vertical;
  padding: 15px;
}

.form-error {
  min-height: 1.4em;
  margin: 0;
  color: var(--danger);
  font-size: 0.86rem;
}

.local-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.app-shell {
  min-height: 100vh;
}

.side-nav {
  position: sticky;
  z-index: 90;
  top: 0;
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  padding: 7px 18px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(14px);
}

.side-nav > .side-brand,
.side-nav > .side-network {
  display: none;
}

.side-nav nav {
  display: flex;
  gap: 5px;
}

.side-nav .nav-item {
  min-height: 40px;
  color: var(--muted);
}

.side-nav .nav-item:hover,
.side-nav .nav-item.active {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: none;
}

.side-nav .nav-item.active {
  color: var(--primary);
}

html[data-theme="hybrid"] .app-shell {
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
}

html[data-theme="hybrid"] .side-nav {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 26px;
  padding: 24px 14px;
  background: #171a23;
  color: #f5f7fb;
}

html[data-theme="hybrid"] .side-nav > .side-brand,
html[data-theme="hybrid"] .side-nav > .side-network {
  display: flex;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}

.side-brand strong,
.side-brand span {
  display: block;
}

.side-brand strong {
  font-size: 0.92rem;
}

.side-brand span {
  color: #929aad;
  font-size: 0.68rem;
}

html[data-theme="hybrid"] .side-nav nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: #c7ccda;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: #43485a;
  background: #252936;
  color: #ffffff;
}

.nav-item.active {
  box-shadow: inset 3px 0 #756fff;
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  font-weight: 800;
}

.side-network {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  border-top: 1px solid #343949;
  padding: 20px 8px 4px;
}

.side-network strong,
.side-network span {
  display: block;
}

.side-network strong {
  font-size: 0.78rem;
}

.side-network span {
  margin-top: 2px;
  color: #929aad;
  font-size: 0.68rem;
}

.main-content {
  width: min(100%, 1540px);
  margin: 0 auto;
  padding: 26px clamp(18px, 3vw, 38px) 18px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.topbar p:last-child {
  margin: 5px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.network-pill,
.privacy-label {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  border: 1px solid color-mix(in srgb, var(--healthy) 35%, var(--border));
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--healthy-soft);
  color: var(--healthy);
  font-weight: 700;
}

.privacy-label {
  min-height: auto;
  font-size: 0.78rem;
}

.theme-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.theme-control select {
  width: 162px;
}

.security-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  border: 1px solid color-mix(in srgb, var(--warning) 55%, var(--border));
  border-radius: 10px;
  padding: 12px 15px;
  background: var(--warning-soft);
  color: var(--warning);
}

.security-warning span {
  color: var(--text);
  font-size: 0.88rem;
}

.view {
  display: none;
  animation: view-in 180ms ease-out;
}

.view.active {
  display: block;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.composer {
  margin-bottom: 26px;
  padding: 20px 22px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.section-heading.inline {
  align-items: center;
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 14px;
}

.composer-row .button {
  min-width: 220px;
}

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

.service-card {
  min-height: 146px;
  padding: 18px;
}

.service-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.service-icon,
.agent-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 850;
}

.service-card h3 {
  margin: 18px 0 3px;
}

.service-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--healthy);
  font-weight: 700;
}

.service-state.offline {
  color: var(--danger);
}

.service-detail {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.latency {
  color: var(--muted);
  font-size: 0.72rem;
}

.skeleton-grid::before {
  content: "Vérification des services locaux…";
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
}

.agent-list,
.approval-list,
.activity-list {
  display: grid;
  gap: 8px;
}

.agent-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
}

.agent-row strong,
.agent-row span {
  display: block;
}

.agent-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.agent-status,
.status-badge,
.count-badge {
  border: 1px solid color-mix(in srgb, var(--healthy) 30%, var(--border));
  border-radius: 8px;
  padding: 5px 8px;
  background: var(--healthy-soft);
  color: var(--healthy);
  font-size: 0.72rem;
  font-weight: 750;
}

.count-badge {
  min-width: 28px;
  text-align: center;
}

.approval-panel {
  border-color: color-mix(in srgb, var(--warning) 55%, var(--border));
}

.approval-item {
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  padding: 14px;
  background: var(--warning-soft);
}

.approval-item h3 {
  margin-bottom: 4px;
}

.approval-item p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.83rem;
}

.command-preview {
  display: flex;
  overflow-x: auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.approval-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.risk-label {
  color: var(--warning);
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
}

.approval-actions {
  display: flex;
  gap: 8px;
}

.approval-actions .button {
  min-height: 38px;
  padding: 7px 12px;
  font-size: 0.78rem;
}

.empty-state {
  display: grid;
  min-height: 132px;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

.activity-panel {
  margin-bottom: 20px;
}

.activity-row {
  display: grid;
  grid-template-columns: 94px 120px minmax(0, 1fr) auto;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 10px 2px;
  font-size: 0.8rem;
}

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

.activity-time,
.activity-agent {
  color: var(--muted);
}

.activity-status {
  color: var(--primary);
  font-weight: 750;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 18px 0 24px;
}

.page-heading h2 {
  font-size: 1.8rem;
}

.page-heading p:last-child {
  max-width: 720px;
  margin: 7px 0 0;
  color: var(--muted);
}

.task-list {
  display: grid;
  gap: 12px;
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 18px;
  cursor: pointer;
  transition:
    transform 150ms ease-out,
    border-color 150ms ease-out;
}

.task-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.task-card p {
  margin: 5px 0 0;
  color: var(--muted);
}

.task-card-meta {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.76rem;
}

.status-badge.pending,
.status-badge.diagnosing,
.status-badge.running {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: var(--primary-soft);
  color: var(--primary);
}

.status-badge.awaiting_approval {
  border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge.failed {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

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

.agent-detail {
  padding: 22px;
}

.agent-detail .agent-icon {
  margin-bottom: 22px;
}

.agent-detail p {
  color: var(--muted);
}

.permission-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  font-size: 0.8rem;
}

.safety-card {
  margin-top: 18px;
  border-left: 4px solid var(--healthy);
  padding: 20px;
}

.safety-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.search-control input {
  width: min(340px, 70vw);
}

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

.runbook-card {
  overflow: hidden;
}

.runbook-summary {
  padding: 20px;
}

.runbook-summary p {
  color: var(--muted);
}

.runbook-category {
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.runbook-card details {
  border-top: 1px solid var(--border);
}

.runbook-card summary {
  padding: 13px 20px;
  color: var(--primary);
  font-weight: 750;
}

.runbook-steps {
  margin: 0;
  padding: 0 36px 20px;
}

.runbook-steps li {
  margin-top: 8px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.settings-card {
  padding: 22px;
}

.settings-card > p {
  color: var(--muted);
}

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

.theme-card {
  display: grid;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
}

.theme-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent);
}

.theme-card > span:last-child {
  color: var(--muted);
  font-size: 0.7rem;
}

.theme-swatch {
  height: 52px;
  border: 1px solid #d5d9df;
  border-radius: 7px;
}

.theme-swatch.light {
  background: linear-gradient(135deg, #f7f5ef 50%, #ffffff 50%);
}

.theme-swatch.dark {
  border-color: #263548;
  background: linear-gradient(135deg, #090d14 50%, #151f2e 50%);
}

.theme-swatch.hybrid {
  background: linear-gradient(90deg, #171a23 25%, #f5f5f2 25%);
}

.config-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.config-list div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 10px 0;
}

.config-list div:first-child {
  border-top: 0;
}

.config-list dt {
  color: var(--muted);
}

.config-list dd {
  overflow-wrap: anywhere;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.72rem;
}

.toast-region {
  position: fixed;
  z-index: 1000;
  top: 18px;
  right: 18px;
  display: grid;
  width: min(380px, calc(100vw - 36px));
  gap: 8px;
}

.toast {
  border: 1px solid var(--border);
  border-left: 4px solid var(--healthy);
  border-radius: 9px;
  padding: 12px 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-left-color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
}

.task-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 100px rgb(0 0 0 / 0.25);
}

.task-dialog::backdrop {
  background: rgb(4 10 18 / 0.58);
  backdrop-filter: blur(3px);
}

.dialog-close {
  position: sticky;
  z-index: 1;
  top: 0;
  float: right;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-size: 1.3rem;
}

.dialog-section {
  clear: both;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 2px solid var(--border);
  padding-left: 13px;
}

.timeline-item strong {
  display: block;
}

.timeline-item span {
  color: var(--muted);
  font-size: 0.76rem;
}

.diagnostic-output {
  max-height: 240px;
  overflow: auto;
  border-radius: 9px;
  padding: 12px;
  background: var(--bg-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  white-space: pre-wrap;
}

html[data-theme="dark"] .main-content {
  max-width: 1640px;
}

html[data-theme="dark"] .topbar {
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
}

html[data-theme="dark"] .service-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

html[data-theme="dark"] .service-card,
html[data-theme="dark"] .agent-row,
html[data-theme="dark"] .task-card {
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
}

html[data-theme="dark"] .button-warning {
  color: #130e04;
}

html[data-theme="hybrid"] .topbar .eyebrow {
  display: none;
}

html[data-theme="hybrid"] .main-content {
  padding-left: 32px;
  padding-right: 32px;
}

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

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

  html[data-theme="hybrid"] {
    --nav-width: 74px;
  }

  html[data-theme="hybrid"] .side-brand > div:last-child,
  html[data-theme="hybrid"] .nav-item span:last-child,
  html[data-theme="hybrid"] .side-network div {
    display: none;
  }

  html[data-theme="hybrid"] .side-brand {
    justify-content: center;
  }

  html[data-theme="hybrid"] .nav-item {
    justify-content: center;
    padding-inline: 8px;
  }
}

@media (max-width: 820px) {
  .main-content {
    padding: 18px 14px 84px;
  }

  .topbar,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .network-pill {
    margin-right: auto;
  }

  .theme-control > span {
    display: none;
  }

  .theme-control select {
    width: 145px;
  }

  .composer-row,
  .dashboard-columns,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .composer-row .button {
    width: 100%;
  }

  .agent-detail-grid,
  .runbook-list {
    grid-template-columns: 1fr;
  }

  .theme-cards {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .activity-row {
    grid-template-columns: 74px 90px minmax(0, 1fr);
  }

  .activity-status {
    display: none;
  }

  html[data-theme="hybrid"] .app-shell {
    display: block;
  }

  html[data-theme="hybrid"] .side-nav {
    position: fixed;
    z-index: 100;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    width: auto;
    height: 68px;
    padding: 7px 10px;
  }

  html[data-theme="hybrid"] .side-brand,
  html[data-theme="hybrid"] .side-network {
    display: none;
  }

  html[data-theme="hybrid"] .side-nav nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
  }

  html[data-theme="hybrid"] .nav-item {
    min-height: 52px;
    flex-direction: column;
    gap: 0;
    padding: 3px;
    font-size: 0.65rem;
  }

  html[data-theme="hybrid"] .nav-item span:last-child {
    display: block;
  }

  html[data-theme="hybrid"] .nav-item.active {
    box-shadow: inset 0 -3px #756fff;
  }
}

@media (max-width: 560px) {
  .login-shell {
    padding: 12px;
  }

  .login-panel {
    padding: 26px 20px;
  }

  .topbar-actions .network-pill {
    width: 100%;
  }

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

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .privacy-label {
    align-self: flex-start;
  }

  .task-card {
    grid-template-columns: 1fr;
  }

  .task-card-meta {
    align-items: flex-start;
    flex-direction: row;
  }

  .approval-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .approval-actions {
    width: 100%;
  }

  .approval-actions .button {
    flex: 1;
  }

  .activity-row {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .activity-agent {
    display: none;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@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;
  }
}
