:root {
  /* Surfaces */
  --bg: #eef4f9;
  --card-bg: linear-gradient(135deg, #0a1f3d 0%, #142d52 100%);
  --card-inner: rgba(255, 255, 255, 0.04);
  --card-inner-border: rgba(255, 255, 255, 0.1);

  --text: #ffffff;
  --text-on-light: #0f1e2d;
  --text-muted-on-dark: #b8c5d4;
  --text-secondary: #475569;

  --border-on-light: #e2e8f0;
  --border-on-dark: rgba(255, 255, 255, 0.15);
  --border-hover-on-dark: rgba(255, 255, 255, 0.3);

  /* Asure brand */
  --primary: #1ab5c9; /* cyan CTA */
  --primary-hover: #0fa0b3;
  --primary-soft: rgba(26, 181, 201, 0.15);
  --primary-border-soft: rgba(26, 181, 201, 0.35);

  --accent: #47c3d3; /* lighter cyan for eyebrow text, focus rings */
  --accent-light: rgba(71, 195, 211, 0.15);

  --secondary: #475569;
  --secondary-hover: #334155;

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --success-border: rgba(52, 211, 153, 0.3);

  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.12);
  --error-border: rgba(248, 113, 113, 0.3);

  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --warning-border: rgba(251, 191, 36, 0.3);

  --shadow-card: 0 12px 32px -8px rgba(10, 31, 61, 0.35);
  --shadow-sm: 0 1px 2px 0 rgba(15, 30, 45, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text-on-light);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* Site header */
.site-header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
}

.site-logo {
  height: 40px;
  width: auto;
  display: block;
}

/* Signed-in user (shown by auth.js once Entra sign-in completes) */
.auth-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.auth-user[hidden] {
  display: none;
}

.auth-signout {
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  background: transparent;
  color: var(--text-on-light);
  border: 1px solid var(--border-on-light);
}

/* Hero card */
.container {
  max-width: 1100px;
  margin: 0 auto 3rem auto;
  padding: 2.75rem 3rem;
  background: var(--card-bg);
  color: var(--text);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  position: relative;
}

h1 {
  margin: 0 0 2rem 0;
  color: var(--text);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: left;
}

h2 {
  margin: 2rem 0 1rem 0;
  color: var(--text);
  font-size: 1.375rem;
  font-weight: 600;
}

h3 {
  margin: 1.5rem 0 1rem 0;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 600;
}

/* Forms */
.field-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

label {
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
  padding-top: 0.625rem;
}

select,
input[type='text'],
input[type='password'],
input[type='url'] {
  width: 100%;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border-on-dark);
  border-radius: 6px;
  font-size: 0.875rem;
  background: rgba(255, 255, 255, 0.06);
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
  color: var(--text);
}

select option {
  background: #0a1f3d;
  color: var(--text);
}

select:focus,
input[type='text']:focus,
input[type='password']:focus,
input[type='url']:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px var(--accent-light);
}

select:hover,
input[type='text']:hover,
input[type='url']:hover {
  border-color: var(--border-hover-on-dark);
}

input::placeholder {
  color: var(--text-muted-on-dark);
}

/* Buttons */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    transform 0.1s ease;
  text-decoration: none;
  white-space: nowrap;
  background: var(--primary);
  color: white;
}

button:hover {
  background: var(--primary-hover);
}

button:active {
  transform: scale(0.98);
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

button:disabled,
button:disabled:hover {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--primary);
  transform: none;
}

button.secondary:disabled,
button.secondary:disabled:hover {
  background: transparent;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-on-dark);
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover-on-dark);
}

button.secondary:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* Panels (result cards) */
.panel {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--card-inner);
  border: 1px solid var(--card-inner-border);
  border-radius: 8px;
}

.panel p {
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  color: var(--text);
}

/* Alerts */
.alert {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert.success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.alert.error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
}

.alert.warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

/* Field help text */
.field-input {
  min-width: 0;
}

.hint {
  margin: 0.375rem 0 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-muted-on-dark);
}

.hint code {
  font-family:
    ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, 'Liberation Mono',
    monospace;
  font-size: 0.95em;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
}

/* Table toolbars */
.table-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.count-note {
  font-size: 0.75rem;
  color: var(--text-muted-on-dark);
}

.empty-cell {
  color: var(--text-muted-on-dark);
  font-style: italic;
  text-align: center;
}

/* Delete column — hidden until an admin passphrase is set */
table.no-actions .actions-col {
  display: none;
}

.row-action {
  padding: 0.3rem 0.85rem;
  font-size: 0.75rem;
}

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

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

/* Code output */
.sfid-output {
  font-family:
    ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, 'Liberation Mono',
    monospace;
  font-size: 0.875rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--card-inner-border);
  word-break: break-all;
  color: var(--text);
  margin: 0.5rem 0;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--card-inner-border);
}

th,
td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--card-inner-border);
  font-size: 0.875rem;
  color: var(--text);
}

th {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 600;
  color: var(--text-muted-on-dark);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

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

tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* Tabs */
.tabs {
  display: flex;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--card-inner-border);
  gap: 0.25rem;
}

.tab {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted-on-dark);
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
  font-size: 0.875rem;
  border-radius: 0;
}

.tab:hover {
  color: var(--text);
  background: transparent;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: transparent;
}

.tab.active:hover {
  background: transparent;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.hidden {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .site-header {
    padding: 1rem 1.25rem;
  }

  .container {
    margin: 0 1rem 2rem 1rem;
    padding: 1.75rem 1.5rem;
  }

  h1 {
    font-size: 1.625rem;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  label {
    padding-top: 0;
    margin-bottom: 0.25rem;
  }

  .tabs {
    flex-direction: column;
    border-bottom: none;
    gap: 0.125rem;
  }

  .tab {
    border-radius: 6px;
    border-bottom: none;
    text-align: left;
  }

  .tab.active {
    border-bottom: none;
    background: rgba(255, 255, 255, 0.06);
  }

  table {
    font-size: 0.75rem;
  }

  th,
  td {
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 480px) {
  .container {
    margin: 0 0.5rem 1.5rem 0.5rem;
    padding: 1.25rem 1rem;
  }

  button {
    width: 100%;
  }

  /* Table row buttons stay inline; full-width would wreck the grid */
  .row-action {
    width: auto;
  }
}
