:root {
  /* Brand Primary Colors */
  --brand-primary: #1471FA;
  --brand-dark: #182942;
  --brand-accent: #086CFB;

  /* Extended Brand Palette */
  --blue-50: #F0F7FF;
  --blue-100: #DCEAFC;
  --blue-200: #BAD5F9;
  --blue-300: #7EBBF5;
  --blue-400: #4B9FF0;
  --blue-500: #1471FA;
  --blue-600: #0A6CFB;
  --blue-700: #0557D0;
  --blue-900: #182942;

  /* Semantic Colors */
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;

  /* Neutral Scale */
  --gray-50: #FAFBFC;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-900: #111827;

  /* UI Application */
  --bg-primary: var(--gray-50);
  --bg-secondary: #FFFFFF;
  --bg-tertiary: var(--gray-100);
  --text-primary: var(--brand-dark);
  --text-secondary: var(--gray-600);
  --text-tertiary: var(--gray-400);
  --border: var(--gray-200);
  --border-light: var(--gray-100);

  /* Interactive */
  --button-primary-bg: var(--brand-primary);
  --button-primary-hover: var(--brand-accent);
  --button-secondary-bg: #FFFFFF;
  --button-secondary-border: var(--blue-200);
  --button-secondary-text: var(--brand-primary);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

.booting {
  padding: 1.2rem;
  font-family: "IBM Plex Mono", monospace;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  background: var(--bg-primary);
}

.nav-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-brand {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1rem;
}

.nav-brand .logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-primary);
  letter-spacing: -0.02em;
}

.nav-brand .tagline {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

nav > .nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

nav > .nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: 0.5rem 0.75rem 0.25rem;
  margin-top: 0.5rem;
}

nav > .nav-section-title:first-child {
  margin-top: 0;
}

.nav-item {
  text-decoration: none;
  color: var(--text-primary);
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 0.75rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.95rem;
  font-weight: 500;
}

.nav-item:hover {
  background: var(--blue-50);
  color: var(--brand-primary);
  border-color: var(--blue-200);
}

.nav-item.active {
  background: var(--blue-100);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  box-shadow: 0 4px 12px rgba(20, 113, 250, 0.15);
}

.nav-item small {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-weight: 400;
}

.workbench {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  overflow-y: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.topbar-content h2 {
  margin: 0;
  font-size: 1.75rem;
  color: var(--text-primary);
}

.topbar-content p {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.topbar-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.settings-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  align-items: flex-end;
}

.notice {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  color: var(--text-secondary);
  border-left: 3px solid var(--brand-primary);
  padding-left: 0.75rem;
  font-size: 0.9rem;
}

.status-banner {
  margin: 0;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.status-banner.info {
  color: #1E40AF;
  background: #EFF6FF;
  border-color: #BAE6FD;
}

.status-banner.success {
  color: #065F46;
  background: #ECFDF5;
  border-color: #A7F3D0;
}

.status-banner.error {
  color: #991B1B;
  background: #FEF2F2;
  border-color: #FCA5A5;
}

.status-banner.warning {
  color: #92400E;
  background: #FFFBEB;
  border-color: #FDE68A;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.panel-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 6px rgba(0, 0, 0, 0.07);
  transition: box-shadow 150ms ease;
}

.panel:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 8px 16px rgba(0, 0, 0, 0.1);
}

.panel.card-accent {
  background: linear-gradient(135deg, var(--brand-dark) 0%, #1a4d8f 100%);
  color: #E8F3FF;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.panel h3 {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.panel.card-accent h3 {
  color: #E8F3FF;
}

.panel h4 {
  margin: 0 0 0.75rem 0;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.panel p {
  margin: 0 0 1rem 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.panel.card-accent p {
  color: rgba(232, 243, 255, 0.9);
}

.inline-link {
  color: #8ac5ff;
  text-decoration: underline;
}

.row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.secret-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 150ms ease;
  font-size: 0.95rem;
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--gray-300);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(20, 113, 250, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--button-primary-bg);
  color: white;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: var(--button-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(20, 113, 250, 0.25);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-primary {
  background: var(--button-primary-bg);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--button-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(20, 113, 250, 0.25);
}

.btn-secondary {
  background: var(--button-secondary-bg);
  color: var(--button-secondary-text);
  border: 2px solid var(--button-secondary-border);
  font-weight: 600;
  padding: 0.6rem 1.2rem;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--blue-50);
  border-color: var(--brand-primary);
}

.btn-danger {
  background: #DC2626;
}

.btn-danger:hover:not(:disabled) {
  background: #B91C1C;
  box-shadow: 0 8px 16px rgba(220, 38, 38, 0.25);
}

.btn-success {
  background: var(--success);
}

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  transition: color 150ms ease;
}

.btn-close:hover {
  color: var(--brand-primary);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.55rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.lookup-card {
  display: grid;
  gap: 0.2rem;
  background: #f4f9ff;
  border: 1px solid #cadcf2;
  border-radius: 12px;
  padding: 0.7rem;
}

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

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-gate-card,
.login-card {
  width: min(760px, 100%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(13, 27, 42, 0.1);
  border-radius: 24px;
  box-shadow: 0 24px 90px rgba(16, 38, 61, 0.18);
  padding: 2rem;
}

.login-shell {
  min-height: 100vh;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 2rem;
}

.login-card-frame {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
}

.login-card {
  animation: riseIn 420ms ease both;
}

.login-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(20px);
  opacity: 0.75;
}

.login-orb-a {
  width: 320px;
  height: 320px;
  left: -70px;
  top: 8vh;
  background: radial-gradient(circle, #a9f0df 0%, rgba(169, 240, 223, 0) 72%);
}

.login-orb-b {
  width: 280px;
  height: 280px;
  right: -40px;
  bottom: 10vh;
  background: radial-gradient(circle, #ffda8f 0%, rgba(255, 218, 143, 0) 70%);
}

.login-form {
  margin-top: 1rem;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.placeholder-form {
  display: grid;
  gap: 0.5rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.summary-grid div {
  display: grid;
  gap: 0.15rem;
  padding: 0.65rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.summary-grid strong {
  font-size: 1.25rem;
}

.summary-grid span {
  font-size: 0.86rem;
  opacity: 0.85;
}

.dashboard-links {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.row-space-between {
  justify-content: space-between;
  align-items: center;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 42, 0.55);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.preview-panel {
  width: min(1100px, 96vw);
  max-height: 90vh;
  overflow: auto;
}

.preview-body {
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  background: #ffffff;
}

.preview-source {
  max-height: 28vh;
  overflow: auto;
  background: #f4f8fc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
}

#blazor-error-ui {
  background: #fff3cd;
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .nav-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    height: auto;
    position: static;
  }

  nav {
    max-height: 220px;
    overflow: auto;
  }

  .settings-inline,
  .panel-grid,
  .row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}

/* ===== MODERN COMPONENTS ===== */

/* Card Variants */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 150ms ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(20, 113, 250, 0.1);
  border-color: var(--blue-200);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.card-header h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-footer {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  justify-content: flex-end;
}

/* Badge/Status Indicators */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge.queued {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
}

.badge.in-progress {
  background: #DBEAFE;
  color: #1E40AF;
  border: 1px solid #93C5FD;
}

.badge.completed {
  background: #D1FAE5;
  color: #065F46;
  border: 1px solid #6EE7B7;
}

.badge.failed {
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #FECACA;
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
  font-size: 1.25rem;
}

.empty-state p {
  margin: 0 0 1.5rem 0;
  max-width: 400px;
  color: var(--text-secondary);
}

/* Loading Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: 8px;
  height: 1rem;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead {
  background: var(--gray-50);
  border-bottom: 2px solid var(--border);
}

th {
  padding: 0.875rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
}

td {
  padding: 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

tbody tr:hover {
  background: var(--blue-50);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.form-group small {
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Modal/Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--bg-secondary);
  border-radius: 16px;
  box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  gap: 0;
}

.tab-button {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 1rem 1.5rem;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 500;
  transition: all 150ms ease;
  margin-bottom: -2px;
}

.tab-button:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.tab-button.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

/* Alert/Callout */
.alert {
  padding: 1rem;
  border-radius: 10px;
  border-left: 4px solid;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.alert.info {
  background: #EFF6FF;
  border-color: #3B82F6;
  color: #1E40AF;
}

.alert.success {
  background: #ECFDF5;
  border-color: var(--success);
  color: #065F46;
}

.alert.warning {
  background: #FFFBEB;
  border-color: #F59E0B;
  color: #92400E;
}

.alert.danger {
  background: #FEF2F2;
  border-color: #EF4444;
  color: #991B1B;
}
