:root {
  color-scheme: light;

  /* Phenikaa-X universal tokens — design-language.md v0.4.4 */
  --blue-50: #eaedf5;
  --blue-100: #c5cce0;
  --blue-200: #8c9ac4;
  --blue-300: #6e7ca8;
  --blue-500: #223771;
  --blue-700: #1a2a57;
  --blue-900: #1e2243;
  --orange-100: #fcd9c4;
  --orange-300: #f58220;
  --orange-500: #f26522;
  --orange-700: #c44e14;
  --neutral-0: #ffffff;
  --neutral-50: #f7f8fb;
  --neutral-100: #eeedf6;
  --neutral-200: #dddfea;
  --neutral-300: #c5c8d8;
  --neutral-400: #9fa3b8;
  --neutral-450: #8c90a8;
  --neutral-500: #757a91;
  --neutral-600: #565b70;
  --neutral-700: #3c4054;
  --neutral-800: #272a3a;
  --neutral-900: #161824;

  --surface-base: var(--neutral-0);
  --surface-raised: var(--neutral-50);
  --surface-brand-tint: var(--neutral-100);
  --text-primary: var(--neutral-900);
  --text-secondary: var(--neutral-600);
  --text-tertiary: var(--neutral-500);
  --border-subtle: var(--neutral-300);
  --border-strong: var(--neutral-450);
  --brand-primary: var(--blue-500);
  --brand-primary-strong: var(--blue-700);
  --brand-accent: var(--orange-500);
  --brand-accent-strong: var(--orange-700);

  --semantic-success: #2e7d32;
  --semantic-success-bg: #e8f5e9;
  --semantic-warning: #9a5b00;
  --semantic-warning-icon: #cb6119;
  --semantic-warning-bg: #fff4db;
  --semantic-error: #c62828;
  --semantic-error-bg: #ffebee;
  --semantic-info: #1565c0;
  --semantic-info-bg: #e7f1fc;

  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --elevation-1: 0 1px 3px rgba(22, 24, 36, 0.12);
  --elevation-2: 0 4px 12px rgba(22, 24, 36, 0.18);

  /* Compatibility aliases used by the existing components. */
  --primary: var(--brand-primary);
  --primary-dim: var(--brand-primary-strong);
  --primary-container: var(--blue-50);
  --on-primary: var(--neutral-0);
  --background: var(--surface-raised);
  --surface-lowest: var(--surface-base);
  --surface-low: var(--surface-raised);
  --surface: var(--surface-brand-tint);
  --surface-high: var(--neutral-200);
  --on-surface: var(--text-primary);
  --on-surface-variant: var(--text-secondary);
  --outline: var(--border-strong);
  --outline-variant: var(--border-subtle);
  --danger: var(--semantic-error);
  --danger-bg: var(--semantic-error-bg);
  --success: var(--semantic-success);
  --success-bg: var(--semantic-success-bg);
  --warning: var(--semantic-warning);
  --warning-bg: var(--semantic-warning-bg);
  --info: var(--semantic-info);
  --info-bg: var(--semantic-info-bg);
  --muted-bg: var(--neutral-200);
  --radius: var(--radius-md);
  --shadow-sm: var(--elevation-1);
  --shadow-lg: var(--elevation-2);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  width: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--on-surface);
  font-family: "Montserrat Variable", Montserrat, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

a {
  color: inherit;
  text-decoration: none;
}

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

h1,
h2,
.brand-copy strong {
  font-family: "Montserrat Variable", Montserrat, "Segoe UI", sans-serif;
}

code {
  background: #111827;
  border-radius: 6px;
  color: #f8fafc;
  display: block;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  margin-top: 6px;
  overflow-wrap: anywhere;
  padding: 8px 10px;
}

.app-shell {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.sidebar {
  background: #f1f5f9;
  border-right: 1px solid rgba(169, 180, 185, 0.25);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  width: 256px;
}

.brand-block {
  align-items: center;
  display: flex;
  gap: 10px;
  min-height: 64px;
  padding: 14px;
}

.brand-mark,
.status-icon {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}

.brand-mark {
  background: var(--primary);
  border-radius: var(--radius);
  color: var(--on-primary);
  height: 38px;
  width: 38px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-copy strong {
  color: #111827;
  font-size: 14px;
  font-weight: 800;
}

.brand-copy span,
.endpoint-summary-row span,
.settings-field span,
.nav-label {
  color: var(--on-surface-variant);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-section {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding: 8px 12px 14px;
}

.nav-label {
  padding: 8px 2px 0;
}

.status-box {
  align-items: center;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(169, 180, 185, 0.35);
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  grid-template-columns: 34px minmax(0, 1fr);
  min-height: 56px;
  padding: 10px;
}

.status-box strong,
.status-box span,
.settings-field span {
  display: block;
}

.status-box strong {
  color: #111827;
  font-size: 12px;
  font-weight: 800;
}

.status-box div > span {
  color: #64748b;
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-icon {
  background: var(--muted-bg);
  border-radius: var(--radius);
  color: #475569;
  height: 34px;
  width: 34px;
}

.tone-success .status-icon,
.tone-success.status-box .status-icon {
  background: var(--success-bg);
  color: var(--success);
}

.tone-danger .status-icon,
.tone-danger.status-box .status-icon {
  background: var(--danger-bg);
  color: var(--danger);
}

.tone-warning .status-icon,
.tone-warning.status-box .status-icon {
  background: var(--warning-bg);
  color: var(--warning);
}

.tone-info .status-icon,
.tone-info.status-box .status-icon {
  background: var(--info-bg);
  color: var(--info);
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.endpoint-summary {
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(169, 180, 185, 0.35);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 10px;
}

.endpoint-summary-row {
  min-width: 0;
}

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

.endpoint-summary-row strong {
  color: #172033;
  font-size: 12px;
  font-weight: 800;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-field input,
.filter-field input,
.filter-field select {
  background: var(--surface-low);
  border: 1px solid #d8e1e8;
  border-radius: var(--radius);
  color: var(--on-surface);
  min-height: 34px;
  outline: 0;
  padding: 7px 10px;
  width: 100%;
}

.settings-field input {
  font-size: 12px;
}

.settings-field input:focus,
.filter-field input:focus,
.filter-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(55, 85, 195, 0.14);
}

.main-shell {
  display: flex;
  flex: 1;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
}

.topbar {
  align-items: center;
  background: rgba(248, 250, 252, 0.92);
  border-bottom: 1px solid rgba(169, 180, 185, 0.22);
  display: flex;
  flex-shrink: 0;
  height: 56px;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-title span {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar-title strong {
  color: #111827;
  font-size: 13px;
}

.topbar-actions,
.page-actions,
.action-group {
  align-items: center;
  display: flex;
  gap: 8px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 16px 24px 24px;
}

.panel-header p {
  color: var(--on-surface-variant);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 4px;
}

.btn,
.icon-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
  justify-content: center;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
  white-space: nowrap;
}

.btn {
  min-height: 36px;
  padding: 8px 12px;
}

.btn.compact {
  min-height: 32px;
  padding: 6px 10px;
}

.btn.full {
  width: 100%;
}

.btn:active,
.icon-button:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  background: var(--primary-dim);
}

.btn-secondary {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
}

.btn-secondary:hover {
  background: #f1f5f9;
}

.btn-warning {
  background: #f59e0b;
  color: #111827;
}

.btn-warning:hover {
  background: #d97706;
  color: #ffffff;
}

.icon-button {
  background: #ffffff;
  border-color: #dbe3ea;
  color: #475569;
  height: 34px;
  padding: 0;
  width: 34px;
}

.icon-button:hover,
.icon-button.subtle:hover {
  background: #eef2ff;
  color: var(--primary);
}

.icon-button.subtle {
  background: transparent;
  border-color: transparent;
  color: #64748b;
}

.icon-button.danger {
  background: transparent;
  border-color: transparent;
  color: #ef4444;
}

.icon-button.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.agent-status-button {
  align-items: center;
  background: #ffffff;
  border: 1px solid #dbe3ea;
  border-radius: var(--radius);
  color: #334155;
  display: inline-grid;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 38px;
  max-width: 360px;
  padding: 6px 10px;
  text-align: left;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.agent-status-button:active {
  transform: scale(0.98);
}

.agent-status-button:hover {
  background: #f8fafc;
}

.agent-status-icon {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.agent-status-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.agent-status-copy strong,
.agent-status-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-status-copy strong {
  color: #111827;
  font-size: 12px;
  font-weight: 800;
}

.agent-status-copy small {
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

.agent-status-button.tone-success {
  background: var(--success-bg);
  border-color: rgba(6, 118, 71, 0.28);
}

.agent-status-button.tone-success .agent-status-icon,
.agent-status-button.tone-success .agent-status-copy strong {
  color: var(--success);
}

.agent-status-button.tone-danger {
  background: var(--danger-bg);
  border-color: rgba(180, 35, 24, 0.24);
}

.agent-status-button.tone-danger .agent-status-icon,
.agent-status-button.tone-danger .agent-status-copy strong {
  color: var(--danger);
}

.agent-status-button.tone-warning {
  background: var(--warning-bg);
  border-color: rgba(181, 71, 8, 0.28);
}

.agent-status-button.tone-warning .agent-status-icon,
.agent-status-button.tone-warning .agent-status-copy strong {
  color: var(--warning);
}

.agent-status-button.tone-info .agent-status-icon,
.agent-status-button.tone-info .agent-status-copy strong {
  color: var(--info);
}

.panel,
.table-panel,
.offline-banner {
  background: var(--surface-lowest);
  border: 1px solid rgba(169, 180, 185, 0.4);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.filter-field span,
.detail-list dt,
.component-list-title {
  color: var(--on-surface-variant);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.offline-banner {
  align-items: center;
  display: grid;
  flex-shrink: 0;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  margin-bottom: 14px;
  padding: 12px 14px;
}

.offline-banner > svg {
  color: var(--warning);
}

.agent-update-banner {
  border-color: rgba(181, 71, 8, 0.35);
}

.client-os-banner {
  background: #fffbeb;
  border-color: rgba(181, 71, 8, 0.35);
  grid-template-columns: auto minmax(0, 1fr);
}

.client-os-banner.command-visible {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.offline-banner strong {
  color: #111827;
  display: block;
  font-size: 13px;
}

.client-os-banner p {
  color: var(--on-surface-variant);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 4px;
}

.workbench-grid {
  display: grid;
  flex: 1;
  gap: 16px;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  min-height: 0;
}

.table-panel,
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.side-stack > .panel:not(.app-detail-panel) {
  flex-shrink: 0;
}

.app-detail-panel {
  flex: 1 1 auto;
  overflow: auto;
}

.app-detail-panel .component-list {
  flex: 0 0 auto;
  overflow: visible;
}

.app-detail-panel .detail-list {
  display: grid;
  gap: 0 18px;
  grid-template-columns: 1fr;
}

.app-detail-panel .detail-list div {
  grid-template-columns: 82px minmax(0, 1fr);
}

.page-filters {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 12px;
  margin-bottom: 14px;
}

.page-filters.inline {
  margin: 0;
  padding: 14px 16px;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-field.wide {
  flex: 1;
}

.input-with-icon {
  align-items: center;
  display: flex;
  position: relative;
}

.input-with-icon svg {
  color: #64748b;
  left: 10px;
  position: absolute;
}

.input-with-icon input {
  padding-left: 32px;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 860px;
  text-align: left;
  width: 100%;
}

thead {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 5;
}

th {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
  padding: 10px 16px;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: #475569;
  font-size: 13px;
  padding: 12px 16px;
  vertical-align: middle;
}

tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.16s ease;
}

tbody tr:hover,
tbody tr.selected-row {
  background: #f8fafc;
}

.table-title {
  color: #172033;
  display: block;
  font-weight: 800;
  line-height: 1.35;
}

.table-title.as-button {
  background: transparent;
  border: 0;
  padding: 0;
  text-align: left;
}

.table-title:hover {
  color: var(--primary);
}

.table-subtitle {
  color: #64748b;
  display: block;
  font-size: 11px;
  line-height: 1.45;
  margin-top: 2px;
}

.table-empty {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  padding: 22px 16px;
  text-align: center;
}

.compact-empty {
  padding: 16px;
}

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

.success-text {
  color: var(--success);
}

.action-col {
  position: sticky;
  right: 0;
  text-align: right;
  white-space: nowrap;
}

td.action-col {
  background: #ffffff;
  box-shadow: -10px 0 12px -14px rgba(15, 23, 42, 0.45);
}

tbody tr:hover td.action-col,
tbody tr.selected-row td.action-col {
  background: #f8fafc;
}

.badge {
  border-radius: 6px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 8px;
  white-space: nowrap;
}

.badge-primary,
.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-muted {
  background: var(--muted-bg);
  color: #475569;
}

.status-inline {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.status-inline small {
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.status-stack {
  align-items: flex-start;
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
}

.status-stack > small {
  font-size: 10px;
  font-weight: 800;
}

.page-pager {
  align-items: center;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  color: #64748b;
  display: flex;
  flex-shrink: 0;
  font-size: 12px;
  justify-content: space-between;
  padding: 10px 14px;
}

.panel-header {
  align-items: flex-start;
  border-bottom: 1px solid #eef2f7;
  display: flex;
  flex-shrink: 0;
  gap: 14px;
  justify-content: space-between;
  padding: 15px 16px;
}

.panel-header h2 {
  color: #111827;
  font-size: 15px;
  font-weight: 800;
}

.panel-state {
  color: #64748b;
  flex-shrink: 0;
}

.panel-state.success {
  color: var(--success);
}

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

.panel-state.warning {
  color: var(--warning);
}

.panel-actions {
  align-items: center;
  display: inline-flex;
  flex-shrink: 0;
  gap: 7px;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 4px 16px 12px;
}

.detail-list div {
  border-bottom: 1px solid #eef2f7;
  display: grid;
  gap: 10px;
  grid-template-columns: 92px minmax(0, 1fr);
  padding: 10px 0;
}

.detail-list div:last-child {
  border-bottom: 0;
}

.detail-list dd {
  color: #172033;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-list dt {
  margin: 0;
}

.agent-metrics {
  border-top: 1px solid #eef2f7;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  padding: 12px 16px 14px;
}

.agent-metrics span {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  color: #64748b;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  padding: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-update-action {
  border-top: 1px solid #eef2f7;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 14px;
}

.agent-update-action .btn {
  flex: 1 1 150px;
}

.component-list {
  border-top: 1px solid #eef2f7;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 14px;
}

.component-list-title {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.component-item {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 9px 10px;
}

.component-item strong,
.component-item span {
  display: block;
}

.component-item strong {
  color: #172033;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.component-item div > span {
  color: #64748b;
  font-size: 11px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-panel {
  flex: 0 0 auto;
}

.task-progress {
  background: #e2e8f0;
  border-radius: 999px;
  height: 8px;
  margin: 12px 16px 0;
  overflow: hidden;
}

.task-progress-bar {
  background: var(--primary);
  height: 100%;
  transition: width 0.22s ease, background 0.16s ease;
}

.task-progress-bar.tone-success {
  background: var(--success);
}

.task-progress-bar.tone-danger {
  background: var(--danger);
}

.task-progress-bar.tone-warning {
  background: var(--warning);
}

.task-components {
  padding-top: 10px;
}

.task-component-item .badge {
  min-width: 44px;
  justify-content: center;
}

.service-check-list {
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  grid-column: 1 / -1;
  padding-top: 8px;
}

.service-check-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-width: 0;
}

.service-check-name {
  align-items: center;
  display: flex;
  gap: 7px;
  min-width: 0;
}

.service-check-icon.healthy {
  color: var(--success);
  flex: 0 0 auto;
}

.service-check-icon.unhealthy {
  color: var(--danger);
  flex: 0 0 auto;
}

.component-item .service-check-name > span,
.service-check-name > span {
  color: inherit;
  font-size: inherit;
  margin-top: 0;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.component-item .service-check-name strong,
.service-check-name strong {
  font-size: 11px;
}

.component-item .service-check-name small,
.service-check-name small {
  color: #64748b;
  display: block;
  font-size: 10px;
  margin-top: 2px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.service-check-row > .badge {
  display: inline-flex;
  flex: 0 0 auto;
}

.service-check-empty {
  align-items: center;
  color: #64748b;
  display: flex;
  font-size: 11px;
  font-weight: 700;
  gap: 6px;
}

.service-health-panel {
  border-top: 1px solid #eef2f7;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 14px;
}

.service-health-panel > .component-list-title {
  justify-content: space-between;
}

.service-health-panel .service-check-list {
  border-top: 0;
  padding-top: 0;
}

.task-log-list {
  border-top: 1px solid #eef2f7;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 190px;
  overflow: auto;
  padding: 4px 16px 12px;
}

.task-log-line {
  border-bottom: 1px solid #eef2f7;
  display: grid;
  gap: 8px;
  grid-template-columns: 64px 46px minmax(0, 1fr);
  padding: 8px 0;
}

.task-log-line:last-child {
  border-bottom: 0;
}

.task-log-line span,
.task-log-line strong {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.4;
  text-transform: uppercase;
}

.task-log-line p {
  color: #172033;
  font-size: 11px;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.dialog-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.36);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 110;
}

.dialog-panel {
  background: var(--surface-lowest);
  border: 1px solid rgba(169, 180, 185, 0.5);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 48px);
  overflow: auto;
  width: min(480px, 100%);
}

.agent-dialog-panel {
  width: min(640px, 100%);
}

.agent-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.agent-detail .panel-header {
  padding: 16px;
}

.agent-detail .detail-list {
  padding-top: 6px;
}

.dialog-panel form {
  display: flex;
  flex-direction: column;
}

.dialog-header {
  align-items: flex-start;
  border-bottom: 1px solid #eef2f7;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 16px;
}

.dialog-header h2 {
  color: #111827;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.dialog-header p {
  color: var(--on-surface-variant);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 4px;
}

.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.dialog-actions {
  align-items: center;
  border-top: 1px solid #eef2f7;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 16px 16px;
}

.toast {
  align-items: center;
  background: #111827;
  border-radius: var(--radius);
  bottom: 20px;
  box-shadow: var(--shadow-lg);
  color: #ffffff;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  position: fixed;
  right: 20px;
  z-index: 120;
}

.toast.tone-success {
  background: var(--success);
}

.toast.tone-danger {
  background: var(--danger);
}

.toast.tone-warning {
  background: var(--warning);
}

.spin {
  animation: spin 0.8s linear infinite;
}

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

@media (max-width: 1320px) {
  .workbench-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .side-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

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

  .sidebar {
    border-bottom: 1px solid rgba(169, 180, 185, 0.25);
    border-right: 0;
    height: auto;
    width: 100%;
  }

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

  .nav-label {
    grid-column: 1 / -1;
  }

  .main-shell {
    height: auto;
    min-height: 0;
  }

  .page {
    overflow: visible;
  }

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

  .side-stack {
    overflow: visible;
  }
}

@media (max-width: 680px) {
  .topbar,
  .page-filters,
  .offline-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    height: auto;
    gap: 12px;
    padding: 12px 16px;
  }

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

  .topbar-actions .btn,
  .topbar-actions .agent-status-button {
    flex: 1;
    max-width: none;
  }

  .page {
    padding: 16px;
  }

  .side-stack,
  .nav-section {
    grid-template-columns: 1fr;
  }

  .app-detail-panel .detail-list {
    grid-template-columns: 1fr;
  }

  .offline-banner {
    display: flex;
  }

  table {
    min-width: 760px;
  }

  .page-pager {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .dialog-backdrop {
    align-items: flex-start;
    padding: 16px;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .dialog-actions .btn {
    width: 100%;
  }

}

/* --------------------------------------------------------------------------
   Phenikaa-X application theme
   Keeps the existing component contract while applying the Layer-1 language.
   -------------------------------------------------------------------------- */

::selection {
  background: var(--orange-100);
  color: var(--text-primary);
}

:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

.sidebar {
  background: var(--blue-900);
  border-color: var(--neutral-700);
}

.brand-block {
  border-bottom: 1px solid rgba(197, 204, 224, 0.18);
  min-height: 72px;
  padding: var(--space-md);
}

.brand-mark {
  background: var(--brand-accent);
  border-radius: var(--radius-md);
  box-shadow: none;
  color: var(--neutral-0);
  height: 40px;
  width: 40px;
}

.brand-copy strong,
.sidebar .status-box strong,
.sidebar .endpoint-summary-row strong {
  color: var(--neutral-0);
}

.brand-copy strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-copy span,
.sidebar .nav-label,
.sidebar .endpoint-summary-row span,
.sidebar .status-box div > span {
  color: var(--blue-100);
}

.brand-copy span,
.nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.sidebar .status-box,
.sidebar .endpoint-summary {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(197, 204, 224, 0.2);
}

.sidebar .status-box:hover,
.sidebar .endpoint-summary:hover {
  background: rgba(255, 255, 255, 0.085);
  border-color: rgba(197, 204, 224, 0.35);
}

.sidebar .btn-secondary {
  background: transparent;
  border-color: var(--blue-300);
  color: var(--neutral-0);
}

.sidebar .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--blue-100);
}

.topbar {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--border-subtle);
  min-height: 64px;
}

.topbar-title span {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.topbar-title strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.page {
  padding: var(--space-lg);
}

.page h1 {
  color: var(--text-primary);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.panel,
.table-panel,
.dialog-panel,
.offline-banner,
.agent-status-button {
  border-color: var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-1);
}

.panel,
.table-panel,
.dialog-panel {
  background: var(--surface-base);
}

.panel-header,
.dialog-header,
.dialog-actions,
.table-wrap thead,
.page-filters {
  border-color: var(--border-subtle);
}

.btn,
.icon-button,
input,
select,
textarea {
  border-radius: var(--radius-md);
}

.btn {
  font-size: 13px;
  font-weight: 600;
}

.btn-primary {
  background: var(--brand-primary);
  color: var(--neutral-0);
}

.btn-primary:hover {
  background: var(--brand-primary-strong);
}

.btn-warning {
  background: var(--brand-accent);
  color: var(--neutral-900);
}

.btn-warning:hover {
  background: var(--brand-accent-strong);
  color: var(--neutral-0);
}

.btn-secondary,
.icon-button {
  background: var(--surface-base);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
}

.btn-secondary:hover,
.icon-button:hover,
.icon-button.subtle:hover {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--brand-primary);
}

.settings-field input,
.filter-field input,
.filter-field select,
input,
select,
textarea {
  background: var(--surface-base);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.settings-field input:focus,
.filter-field input:focus,
.filter-field select:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(34, 55, 113, 0.16);
}

table {
  color: var(--text-primary);
}

thead {
  background: var(--surface-brand-tint);
}

th {
  color: var(--blue-700);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.045em;
}

td {
  border-color: var(--neutral-200);
  font-size: 13px;
}

tbody tr:hover,
.selected-row {
  background: var(--blue-50);
}

.badge {
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.badge-success {
  background: var(--semantic-success-bg);
  color: var(--semantic-success);
}

.badge-danger {
  background: var(--semantic-error-bg);
  color: var(--semantic-error);
}

.badge-warning {
  background: var(--semantic-warning-bg);
  color: var(--semantic-warning);
}

.badge-info,
.badge-primary {
  background: var(--semantic-info-bg);
  color: var(--semantic-info);
}

code,
.task-log-list {
  background: var(--blue-900);
  color: var(--neutral-100);
}

@media (max-width: 980px) {
  .sidebar {
    border-bottom-color: var(--neutral-700);
  }
}

@media (max-width: 680px) {
  .page {
    padding: var(--space-md);
  }
}

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