:root {
  --primary: #3755c3;
  --primary-dim: #2848b7;
  --primary-container: #dde1ff;
  --on-primary: #f8f7ff;
  --background: #f7f9fb;
  --surface-lowest: #ffffff;
  --surface-low: #f0f4f7;
  --surface: #e8eff3;
  --surface-high: #e1e9ee;
  --on-surface: #2a3439;
  --on-surface-variant: #566166;
  --outline: #717c82;
  --outline-variant: #a9b4b9;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --success: #067647;
  --success-bg: #dcfae6;
  --warning: #b54708;
  --warning-bg: #fef0c7;
  --info: #175cd3;
  --info-bg: #d1e9ff;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--background);
  color: var(--on-surface);
  font-family: "Inter", Arial, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

h1,
h2,
h3,
.brand-copy strong {
  font-family: "Manrope", Arial, sans-serif;
}

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

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

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

button {
  cursor: pointer;
}

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

.material-symbols-outlined {
  direction: ltr;
  display: inline-flex;
  font-family: "Material Symbols Outlined";
  font-size: 1.25rem;
  font-style: normal;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 20;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
}

.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: 224px;
}

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

.brand-mark {
  align-items: center;
  background: var(--primary);
  border-radius: var(--radius);
  color: var(--on-primary);
  display: inline-flex;
  height: 38px;
  justify-content: center;
  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,
.profile-meta span,
.sidebar-status span {
  color: var(--on-surface-variant);
  font-size: 11px;
}

.nav-section {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
}

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

.nav-label {
  padding: 8px 10px;
}

.nav-item {
  align-items: center;
  border-left: 4px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: #475569;
  display: flex;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item:hover {
  background: rgba(226, 232, 240, 0.72);
  color: #0f172a;
}

.nav-item.active {
  background: rgba(226, 232, 240, 0.88);
  border-left-color: var(--primary);
  color: #0f172a;
  font-weight: 800;
}

.sidebar-status {
  align-items: center;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(169, 180, 185, 0.32);
  border-radius: var(--radius);
  display: flex;
  gap: 9px;
  margin: 12px;
  padding: 10px;
}

.sidebar-status strong {
  display: block;
  font-size: 12px;
}

.status-dot {
  background: #12b76a;
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.15);
  display: inline-flex;
  height: 8px;
  width: 8px;
}

#sidebarBackdrop,
#mobileMenuBtn {
  display: none;
}

.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-left,
.topbar-actions,
.page-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.page-actions form {
  display: inline-flex;
  margin: 0;
}

.profile-chip {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: inherit;
  display: flex;
  gap: 9px;
  min-height: 38px;
  padding: 2px 6px 2px 4px;
}

.profile-chip-button {
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.profile-chip-button:hover,
.profile-chip-button:focus-visible {
  background: #ffffff;
  border-color: #dbe3ea;
}

.profile-chip-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(55, 85, 195, 0.14);
  outline: 0;
}

.profile-chip-button:active {
  transform: scale(0.98);
}

.profile-avatar {
  align-items: center;
  background: var(--primary-container);
  border-radius: var(--radius);
  color: var(--primary);
  display: inline-flex;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.profile-meta strong {
  color: #111827;
  font-size: 12px;
}

.main-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

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

.page-header {
  align-items: flex-start;
  display: flex;
  flex-shrink: 0;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  color: #111827;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

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

.btn {
  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;
  min-height: 36px;
  padding: 8px 12px;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
  white-space: nowrap;
}

.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-danger {
  background: #dc2626;
  color: #ffffff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.icon-button {
  align-items: center;
  background: #ffffff;
  border: 1px solid #dbe3ea;
  border-radius: var(--radius);
  color: #475569;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  padding: 0;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
  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);
}

.dashboard-stats {
  display: grid;
  flex-shrink: 0;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

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

.metric-card {
  display: flex;
  flex-direction: column;
  min-height: 96px;
  padding: 15px;
}

.metric-card div {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin-top: auto;
}

.metric-card strong {
  color: #111827;
  font-family: "Manrope", Arial, sans-serif;
  font-size: 28px;
  font-weight: 800;
}

.metric-card small {
  color: var(--on-surface-variant);
  font-size: 11px;
  font-weight: 700;
}

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

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

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

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

.text-link {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.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,
.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-field.wide,
.form-field.full {
  flex: 1;
}

.filter-field input,
.filter-field select,
.form-field input,
.form-field select,
.form-field textarea,
.mini-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%;
}

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

.form-field textarea {
  min-height: 86px;
  resize: vertical;
}

.table-panel {
  flex: 1;
}

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

.table-wrap.compact {
  flex: 1;
}

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

.compact table {
  min-width: 640px;
}

.builder-table table {
  min-width: 740px;
}

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 {
  background: #f8fafc;
}

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

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

.notes-cell {
  max-width: 280px;
  white-space: normal;
}

.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 {
  background: #f8fafc;
}

.action-group {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}

.action-group form {
  display: inline-flex;
  margin: 0;
}

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

.badge-primary {
  background: var(--primary-container);
  color: var(--primary);
}

.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-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-muted {
  background: #e2e8f0;
  color: #475569;
}

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

.page-pager div {
  align-items: center;
  display: flex;
  gap: 8px;
}

.page-pager button {
  background: #ffffff;
  border: 1px solid #dbe3ea;
  border-radius: 6px;
  color: #475569;
  font-size: 12px;
  min-height: 28px;
  padding: 4px 9px;
}

.activity-list {
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 8px;
}

.activity-item {
  align-items: center;
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  padding: 10px 8px;
}

.activity-item:hover {
  background: #f8fafc;
}

.activity-icon {
  align-items: center;
  background: var(--surface-low);
  border-radius: var(--radius);
  color: var(--primary);
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

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

.activity-item strong {
  color: #172033;
  font-size: 13px;
}

.activity-item span,
.activity-item time {
  color: #64748b;
  font-size: 12px;
}

.breadcrumb {
  align-items: center;
  color: #64748b;
  display: flex;
  font-size: 12px;
  font-weight: 700;
  gap: 8px;
  margin-bottom: 8px;
}

.breadcrumb a {
  color: var(--primary);
}

.detail-grid,
.builder-layout,
.agent-layout {
  display: grid;
  flex: 1;
  gap: 16px;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 0;
}

.agent-layout {
  grid-template-columns: 380px minmax(0, 1fr);
}

.wide-panel {
  min-width: 0;
}

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

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

.detail-list dt,
.detail-list dd {
  margin: 0;
}

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

.mono {
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

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

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.builder-layout .panel {
  overflow: auto;
}

.builder-layout .panel .form-grid,
.builder-layout .panel .form-stack,
.agent-upload-form .form-grid {
  padding: 16px;
}

.agent-upload-form {
  overflow: auto;
}

.agent-upload-form .modal-actions {
  padding: 0 16px 16px;
}

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

.agent-command-list input {
  font-size: 11px;
}

.agent-table {
  min-width: 920px;
}

.checkbox {
  accent-color: var(--primary);
  height: 16px;
  width: 16px;
}

.mini-select {
  min-height: 30px;
  min-width: 116px;
  padding: 5px 8px;
}

.file-input {
  height: 1px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 1px;
}

.file-dropzone {
  background: #f8fafc;
  border: 1px dashed #a9b4b9;
  border-radius: var(--radius);
  color: #475569;
  min-height: 148px;
  padding: 12px;
  position: relative;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.file-dropzone:hover,
.file-dropzone.dragover {
  background: #eef2ff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(55, 85, 195, 0.12);
}

.file-dropzone-content {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  min-height: 122px;
  text-align: center;
}

.file-dropzone-content > .material-symbols-outlined {
  color: var(--primary);
  font-size: 34px;
}

.file-dropzone-content strong {
  color: #172033;
  font-size: 13px;
}

.file-dropzone-content small,
.file-preview small {
  color: #64748b;
  font-size: 11px;
  line-height: 1.45;
}

.file-preview {
  align-items: center;
  background: #ffffff;
  border: 1px solid #dbe3ea;
  border-radius: var(--radius);
  display: grid;
  gap: 10px;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  margin-top: 10px;
  padding: 10px;
}

.file-preview > .material-symbols-outlined {
  align-items: center;
  background: var(--primary-container);
  border-radius: var(--radius);
  color: var(--primary);
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.file-preview strong {
  color: #172033;
  display: block;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-backdrop {
  align-items: center;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.18s ease;
  z-index: 100;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #ffffff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 720px);
  overflow: hidden;
  transform: scale(0.97);
  transition: transform 0.18s ease;
  width: min(560px, calc(100vw - 32px));
}

.modal-content.wide {
  width: min(760px, calc(100vw - 32px));
}

.modal-backdrop.open .modal-content {
  transform: scale(1);
}

.modal-header {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid #eef2f7;
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  padding: 14px 18px;
}

.modal-header h3 {
  color: #111827;
  font-size: 16px;
  font-weight: 800;
}

.modal-form {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  scrollbar-gutter: stable;
}

.modal-actions {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), #ffffff 30%);
  border-top: 1px solid #eef2f7;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin: 18px -18px -18px;
  padding: 14px 18px 18px;
  position: sticky;
  bottom: 0;
}

.modal-actions .btn {
  min-width: 112px;
}

.profile-summary {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
}

.profile-summary > div > strong,
.profile-summary > div > span {
  display: block;
}

.profile-summary > div > strong {
  color: #172033;
  font-size: 13px;
  font-weight: 800;
}

.profile-summary > div > span {
  color: #64748b;
  font-size: 12px;
  margin-top: 2px;
}

.modal-mini-table {
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 14px;
  overflow: hidden;
}

.modal-mini-table label {
  align-items: center;
  border-bottom: 1px solid #eef2f7;
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr) 140px;
  padding: 10px;
}

.modal-mini-table label:last-child {
  border-bottom: 0;
}

.modal-mini-table strong,
.modal-mini-table small {
  display: block;
}

.modal-mini-table small {
  color: #64748b;
  font-size: 11px;
  margin-top: 2px;
}

.modal-mini-table .mini-select:disabled {
  opacity: 0.55;
}

.toast {
  background: #111827;
  border-radius: var(--radius);
  bottom: 20px;
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.24);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  max-width: min(420px, calc(100vw - 32px));
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  right: 20px;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 120;
}

.toast.open {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  align-items: center;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: auto;
  max-width: 460px;
  padding: 28px;
  text-align: center;
}

.empty-state .material-symbols-outlined {
  color: var(--primary);
  font-size: 42px;
}

.empty-state h1 {
  font-size: 22px;
}

.empty-state p {
  color: var(--on-surface-variant);
  line-height: 1.5;
}

.error-state .material-symbols-outlined {
  color: var(--danger);
}

.error-detail {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-sm);
  color: #9a3412;
  display: block;
  line-height: 1.45;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  text-align: left;
}

.center-page {
  align-items: center;
  justify-content: center;
}

.logout-form {
  margin: 0;
}

.auth-shell {
  background:
    linear-gradient(135deg, rgba(55, 85, 195, 0.08), rgba(6, 118, 71, 0.08)),
    var(--background);
  display: block;
  min-height: 100vh;
  overflow: auto;
}

.auth-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-panel {
  background: var(--surface-lowest);
  border: 1px solid rgba(169, 180, 185, 0.42);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: min(460px, 100%);
  padding: 24px;
}

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

.auth-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-heading h1 {
  color: #111827;
  font-size: 26px;
  font-weight: 800;
}

.auth-heading p,
.auth-switch {
  color: var(--on-surface-variant);
  line-height: 1.5;
}

.auth-confirm-icon {
  align-items: center;
  background: var(--primary-container);
  border-radius: var(--radius);
  color: var(--primary);
  display: inline-flex;
  height: 46px;
  justify-content: center;
  width: 46px;
}

.auth-confirm-icon .material-symbols-outlined {
  font-size: 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field-feedback {
  color: var(--on-surface-variant);
  display: none;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.form-field.has-error input {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

.form-field.has-success input {
  border-color: var(--success);
}

.form-field.has-error .field-feedback {
  color: var(--danger);
  display: block;
}

.form-field.has-success .field-feedback {
  color: var(--success);
  display: block;
}

.auth-submit {
  width: 100%;
}

.auth-switch {
  font-size: 13px;
  text-align: center;
}

.auth-switch a {
  color: var(--primary);
  font-weight: 800;
}

.users-layout {
  display: grid;
  flex: 1;
  gap: 16px;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 0;
}

.user-create-form {
  overflow: auto;
  padding: 16px;
}

.access-form {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  justify-content: flex-end;
}

.user-actions {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}

.user-actions form {
  margin: 0;
}

.edit-active-toggle {
  padding-top: 2px;
}

.user-detail-list {
  padding: 0;
}

.inline-checkbox {
  align-items: center;
  color: #475569;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 5px;
  white-space: nowrap;
}

.users-table {
  min-width: 980px;
}

@media (max-width: 1100px) {
  .dashboard-grid,
  .detail-grid,
  .builder-layout,
  .agent-layout,
  .users-layout {
    grid-template-columns: 1fr;
  }

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

  .detail-grid,
  .builder-layout,
  .agent-layout,
  .users-layout {
    overflow: auto;
  }
}

@media (max-width: 900px) {
  body.app-shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    position: relative;
  }

  #mobileMenuBtn {
    display: inline-flex;
  }

  #sidebarBackdrop {
    background: rgba(15, 23, 42, 0.45);
    display: block;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    position: fixed;
    transition: opacity 0.18s ease;
    z-index: 70;
  }

  .sidebar {
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.34);
    height: 100dvh;
    inset: 0 auto 0 0;
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    width: min(82vw, 256px);
    z-index: 80;
  }

  body.mobile-nav-open #sidebarBackdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .topbar {
    padding: 0 14px;
  }

  .profile-meta {
    display: none;
  }

  .page {
    padding: 16px;
  }

  .page-header,
  .page-filters {
    align-items: stretch;
    flex-direction: column;
  }

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

  .page-actions .btn {
    flex: 1;
  }

  .table-wrap table {
    min-width: 760px;
  }

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

  .modal-backdrop {
    align-items: flex-end;
  }

  .modal-content,
  .modal-content.wide {
    border-radius: var(--radius);
    margin: 8px;
    max-height: min(88dvh, 720px);
    width: calc(100% - 16px);
  }
}

@media (max-width: 560px) {
  .dashboard-stats,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .modal-mini-table label {
    align-items: stretch;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .modal-mini-table .mini-select {
    grid-column: 1 / -1;
    width: 100%;
  }
}
