: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);
  --radius: var(--radius-md);
  --shadow-sm: var(--elevation-1);
  --shadow-lg: var(--elevation-2);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 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;
}

h1,
h2,
h3,
.brand-copy strong {
  font-family: "Montserrat Variable", Montserrat, "Segoe UI", 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;
}

.fluent-icon {
  background: currentColor;
  display: inline-flex;
  flex: 0 0 auto;
  height: 1.25rem;
  mask: var(--fluent-icon-url) center / contain no-repeat;
  width: 1.25rem;
}

.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 {
  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-copyright {
  color: var(--on-surface-variant);
  font-size: 11px;
  line-height: 1.4;
  margin: 12px;
  padding: 4px 2px;
  text-align: center;
}

#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;
  position: relative;
  z-index: 60;
}

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

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

.notification-center {
  position: relative;
}

.notification-button {
  position: relative;
}

.notification-badge {
  align-items: center;
  background: #d92d20;
  border: 2px solid #f8fafc;
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  font-size: 9px;
  font-weight: 800;
  height: 18px;
  justify-content: center;
  line-height: 1;
  min-width: 18px;
  padding: 0 4px;
  position: absolute;
  right: -7px;
  top: -7px;
}

.notification-panel {
  background: #ffffff;
  border: 1px solid #dbe3ea;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(400px, calc(100vw - 28px));
  z-index: 120;
}

.notification-panel[hidden],
.notification-badge[hidden],
.notification-empty[hidden] {
  display: none;
}

.notification-panel-header {
  align-items: center;
  border-bottom: 1px solid #eef2f7;
  display: flex;
  justify-content: space-between;
  padding: 14px 16px 10px;
}

.notification-panel-header > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notification-panel-header strong {
  color: #111827;
  font-family: "Montserrat Variable", Montserrat, "Segoe UI", sans-serif;
  font-size: 15px;
}

.notification-panel-header span {
  color: #64748b;
  font-size: 11px;
}

.text-button {
  background: transparent;
  border: 0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  padding: 5px;
}

.text-button:hover,
.text-button:focus-visible {
  text-decoration: underline;
}

.notification-tabs {
  border-bottom: 1px solid #eef2f7;
  display: flex;
  gap: 16px;
  padding: 0 16px;
}

.notification-tabs button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  padding: 9px 0 7px;
}

.notification-tabs button.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

.notification-list {
  max-height: min(440px, calc(100vh - 190px));
  overflow-y: auto;
}

.notification-item {
  align-items: flex-start;
  background: #ffffff;
  border: 0;
  border-bottom: 1px solid #f0f3f7;
  color: inherit;
  display: grid;
  gap: 10px;
  grid-template-columns: 34px minmax(0, 1fr) 7px;
  padding: 12px 14px;
  text-align: left;
  width: 100%;
}

.notification-item:hover,
.notification-item:focus-visible {
  background: #f8fafc;
  outline: 0;
}

.notification-item.unread {
  background: #f7f8ff;
}

.notification-item.unread:hover,
.notification-item.unread:focus-visible {
  background: #eef1ff;
}

.notification-item-icon {
  align-items: center;
  background: var(--info-bg);
  border-radius: 50%;
  color: var(--info);
  display: inline-flex;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.notification-item-icon .material-symbols-outlined,
.notification-item-icon .fluent-icon {
  height: 19px;
  width: 19px;
}

.notification-item.tone-success .notification-item-icon {
  background: var(--success-bg);
  color: var(--success);
}

.notification-item.tone-warning .notification-item-icon {
  background: var(--warning-bg);
  color: var(--warning);
}

.notification-item.tone-error .notification-item-icon {
  background: var(--danger-bg);
  color: var(--danger);
}

.notification-item-copy {
  min-width: 0;
}

.notification-item-copy strong,
.notification-item-copy span,
.notification-item-copy time {
  display: block;
}

.notification-item-copy strong {
  color: #172033;
  font-size: 12px;
  line-height: 1.4;
}

.notification-item-copy span {
  color: #52606d;
  font-size: 11px;
  line-height: 1.45;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.notification-item-copy time {
  color: #84909a;
  font-size: 10px;
  margin-top: 5px;
}

.notification-unread-dot {
  align-self: center;
  background: var(--primary);
  border-radius: 50%;
  height: 7px;
  opacity: 0;
  width: 7px;
}

.notification-item.unread .notification-unread-dot {
  opacity: 1;
}

.notification-empty {
  align-items: center;
  color: #64748b;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 180px;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.notification-empty .material-symbols-outlined,
.notification-empty .fluent-icon {
  color: #94a3b8;
  height: 32px;
  width: 32px;
}

.notification-empty strong {
  color: #334155;
  font-size: 12px;
}

.notification-empty span:last-child {
  font-size: 11px;
}

.notification-panel-footer {
  background: #f8fafc;
  border-top: 1px solid #eef2f7;
  padding: 10px 14px;
}

.notification-panel-footer .btn {
  width: 100%;
}

.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: "Montserrat Variable", Montserrat, "Segoe UI", 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,
.file-dropzone-content > .fluent-icon {
  color: var(--primary);
  height: 34px;
  width: 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,
.file-preview > .fluent-icon {
  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-header p {
  color: #64748b;
  font-size: 11px;
  line-height: 1.45;
  margin-top: 3px;
}

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

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

.document-title-cell {
  max-width: 360px;
  min-width: 240px;
}

.document-title-cell .table-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-file-name {
  color: var(--text-primary);
  display: block;
  font-size: 12px;
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.document-meta-panel,
.document-reader-panel {
  min-width: 0;
}

.document-reader {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  overflow: auto;
  padding: 20px;
}

.document-copy {
  color: var(--text-primary);
  font-family: "Montserrat Variable", Montserrat, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.document-preview-block {
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
}

.document-section-heading {
  align-items: center;
  color: var(--text-secondary);
  display: flex;
  font-size: 12px;
  gap: 6px;
}

.document-section-heading .material-symbols-outlined {
  color: var(--brand-primary);
  font-size: 18px;
}

.document-file-preview {
  background: var(--neutral-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  min-height: 540px;
  width: 100%;
}

.document-image-preview {
  align-self: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  height: auto;
  max-height: 70vh;
  max-width: 100%;
  object-fit: contain;
}

.document-attachment-state {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: grid;
  gap: 14px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  padding: 16px;
}

.document-attachment-state > .material-symbols-outlined {
  color: var(--brand-primary);
  font-size: 34px;
}

.document-attachment-state strong,
.document-attachment-state p {
  display: block;
  overflow-wrap: anywhere;
}

.document-attachment-state p {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 3px;
}

.document-remove-option {
  align-items: flex-start;
  background: var(--semantic-warning-bg);
  border: 1px solid #f3d28c;
  border-radius: var(--radius-md);
  color: var(--semantic-warning);
  display: flex;
  font-size: 12px;
  gap: 8px;
  padding: 10px 12px;
}

.document-remove-option input {
  flex: 0 0 auto;
  margin-top: 3px;
}

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

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

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

  .document-reader-panel {
    min-height: 620px;
  }
}

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

  .notification-panel {
    left: 8px;
    max-height: calc(100dvh - 72px);
    position: fixed;
    right: 8px;
    top: 64px;
    width: auto;
  }

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

  .document-attachment-state {
    align-items: flex-start;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .document-attachment-state .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

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

/* --------------------------------------------------------------------------
   Phenikaa-X application theme
   Keeps the existing EJS/JavaScript contract while applying Layer-1 tokens.
   -------------------------------------------------------------------------- */

::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 {
  color: var(--neutral-0);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-copy span,
.sidebar .nav-label,
.sidebar-copyright {
  color: var(--blue-100);
}

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

.nav-section {
  gap: var(--space-xxs);
  padding: var(--space-sm);
}

.nav-item {
  border-left-width: 4px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--blue-100);
  font-size: 13px;
  font-weight: 500;
  gap: var(--space-sm);
  min-height: 44px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--neutral-0);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: var(--brand-accent);
  color: var(--neutral-0);
  font-weight: 600;
}

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

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

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

.panel,
.table-panel,
.metric-card,
.modal-content,
.notification-panel,
.empty-state,
.auth-panel {
  background: var(--surface-base);
  border-color: var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-1);
}

.modal-content,
.notification-panel,
.auth-panel {
  box-shadow: var(--elevation-2);
}

.panel-header,
.modal-header,
.modal-actions,
.page-filters,
thead,
td {
  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);
}

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

.form-field input:focus,
.form-field select:focus,
.form-field textarea: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);
}

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

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

td {
  font-size: 13px;
}

tbody tr:hover {
  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);
}

.empty-state > .fluent-icon {
  color: var(--brand-primary);
  height: 42px;
  width: 42px;
}

.error-state > .fluent-icon {
  color: var(--semantic-error);
}

.auth-shell {
  background:
    linear-gradient(135deg, rgba(30, 34, 67, 0.98), rgba(34, 55, 113, 0.93) 42%, rgba(247, 248, 251, 0.98) 42.1%),
    var(--surface-raised);
}

.auth-panel {
  border-top: 4px solid var(--brand-accent);
  gap: var(--space-lg);
  padding: var(--space-lg);
}

.auth-brand .brand-copy strong {
  color: var(--text-primary);
}

.auth-brand .brand-copy span {
  color: var(--text-tertiary);
}

.auth-confirm-icon {
  background: var(--blue-50);
  border-radius: var(--radius-md);
  color: var(--brand-primary);
}

.auth-confirm-icon .fluent-icon {
  height: 28px;
  width: 28px;
}

.toast {
  background: var(--blue-900);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-2);
}

@media (max-width: 900px) {
  .sidebar {
    box-shadow: var(--elevation-2);
  }
}

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

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