:root {
  /* Life Fitness / Hammer Strength brand palette - black, white, and their
     signature red as the sole accent color. */
  --graphite-900: #121212;
  --graphite-800: #1c1c1c;
  --graphite-700: #262626;
  --graphite-600: #313131;
  --line: #3a3a3a;
  --ivory: #f5f5f5;
  --muted: #9a9a9a;
  --brand-red: #c8102e;
  --brand-red-hot: #e2273f;
  --teal: #3f9d5c;
  --red: #8f1c2b;
  --font-display: 'Iowan Old Style', 'Georgia', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  /* Enterprise-panel shell: a persistent top bar above the sidebar, flatter
     bordered depth over shadows. Additive to the palette above - nothing
     existing is renamed. */
  --header-height: 56px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.22);
  --shadow-md: 0 8px 20px rgba(0,0,0,0.3);
  --shadow-card: 0 1px 2px rgba(0,0,0,0.16), 0 6px 16px rgba(0,0,0,0.14);
  --shadow-card-hover: 0 4px 10px rgba(0,0,0,0.2), 0 14px 30px rgba(0,0,0,0.22);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* Light theme - overrides the same variable names, so every rule in this
   file (all color-based on these custom properties, none hardcoded) adapts
   automatically with no per-rule duplication. Toggled via Settings; see
   app.js's applyTheme/loadTheme - sets data-theme on <html> and persists the
   choice in localStorage. */
:root[data-theme="light"] {
  --graphite-900: #f0f1f3;
  --graphite-800: #ffffff;
  --graphite-700: #eceef1;
  --graphite-600: #dfe2e6;
  --line: #d7dade;
  --ivory: #1a1a1a;
  --muted: #666666;
  --brand-red-hot: #a80d26;
  --teal: #2f7d49;
  --red: #b3202f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--graphite-900);
  color: var(--ivory);
  font-family: var(--font-body);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(200,16,46,0.10), transparent 40%),
    var(--graphite-900);
}
.login-card {
  width: 360px;
  padding: 40px 36px;
  background: var(--graphite-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.login-mark {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-red);
  color: var(--graphite-900);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
/* A real uploaded logo replaces the square initials mark - let it keep its
   own natural (usually wide/rectangular) aspect ratio instead of being
   force-cropped into the 40px square built for a 2-letter initials mark. */
.login-mark.has-logo { width: auto; height: auto; max-width: 240px; background: none; border-radius: 0; }
.login-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 6px;
}
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
input, select, textarea {
  font-family: var(--font-body);
  background: var(--graphite-700);
  border: 1px solid var(--line);
  color: var(--ivory);
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(200,16,46,0.16);
}
/* Custom dropdown arrow so selects share the same rounded, boxed look as
   text inputs instead of falling back to the OS's own square-cornered
   native chevron widget. */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239a9a9a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}

.btn-primary, .btn-secondary, .btn-ghost {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
.btn-primary { background: var(--brand-red); color: var(--graphite-900); box-shadow: 0 1px 2px rgba(0,0,0,0.15); }
.btn-primary:hover { background: var(--brand-red-hot); box-shadow: 0 4px 14px rgba(200,16,46,0.3); transform: translateY(-1px); }
.btn-secondary { background: var(--graphite-700); border-color: var(--line); color: var(--ivory); }
.btn-secondary:hover { border-color: var(--brand-red); background: var(--graphite-600); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--ivory); border-color: var(--muted); }
.btn-primary:active, .btn-secondary:active, .btn-ghost:active { transform: scale(0.97); }
.btn-primary:disabled, .btn-secondary:disabled, .btn-ghost:disabled {
  opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none;
}
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-ghost:focus-visible {
  outline: 2px solid var(--brand-red-hot); outline-offset: 2px;
}

/* Small inline loading spinner, used inside buttons mid-action (see app.js) */
.spinner {
  display: inline-block; width: 13px; height: 13px; flex-shrink: 0;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite; opacity: 0.85;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-text { color: var(--red); font-size: 12px; min-height: 16px; margin: 0; }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; }

/* ---------- Top bar ---------- */
/* Traditional enterprise-admin panels (SAP/ServiceNow/classic intranet
   portals) separate a persistent top identity bar from the side nav - this
   app previously had no such bar, with branding and the user menu buried
   inside the sidebar instead. */
.topbar {
  height: var(--header-height); flex-shrink: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 0 18px;
  background: var(--graphite-900);
  border-bottom: 3px solid var(--brand-red);
  position: sticky; top: 0; z-index: 50;
}
.sidebar-toggle {
  display: none; background: transparent; border: 1px solid var(--line); border-radius: 3px;
  width: 34px; height: 34px; align-items: center; justify-content: center; cursor: pointer; color: var(--ivory);
  flex-shrink: 0;
}
.sidebar-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.topbar-brand {
  font-family: var(--font-display); font-size: 16px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0; color: var(--ivory);
}
.brand-mark {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-red); color: var(--graphite-900); font-family: var(--font-mono); font-size: 11px; font-weight: 700; border-radius: 3px;
  overflow: hidden;
}
/* A real uploaded logo replaces the square initials mark - let it keep its
   own natural (usually wide) aspect ratio instead of being force-cropped. */
.brand-mark.has-logo { width: auto; height: 30px; max-width: 160px; background: none; border-radius: 0; }
.topbar-title {
  font-family: var(--font-display); font-size: 15px; color: var(--muted);
  padding-left: 16px; border-left: 1px solid var(--line);
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-user { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.whoami { font-size: 12px; color: var(--muted); }
#logout-btn { justify-content: flex-start; }

.theme-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  background: transparent; border: 1px solid var(--line); border-radius: 3px;
  color: var(--ivory); cursor: pointer;
}
.theme-toggle-btn:hover { border-color: var(--muted); }
.theme-toggle-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* Sun/moon swap by theme: dark mode shows the sun (switch to light), light mode shows the moon (switch to dark). */
.theme-toggle-btn .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle-btn .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle-btn .icon-moon { display: block; }

.app-body { display: flex; min-height: calc(100vh - var(--header-height)); }

.sidebar {
  width: 220px; flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: var(--graphite-800);
  position: sticky; top: var(--header-height); height: calc(100vh - var(--header-height));
}
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 14px 12px 6px;
}
.nav-group-label:first-child { padding-top: 4px; }
.side-nav-btn {
  text-align: left;
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: none; border-left: 2px solid transparent; color: var(--muted); padding: 9px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 3px;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.side-nav-btn.active { color: var(--ivory); background: var(--graphite-700); border-left-color: var(--brand-red); }
.side-nav-btn:hover { color: var(--ivory); background: rgba(255,255,255,0.03); }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-scrim { display: none; }

.app-main { flex: 1; padding: 24px; max-width: 1600px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.panel-header h2 { font-family: var(--font-display); font-size: 22px; margin: 0; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade-in 0.15s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.muted { color: var(--muted); font-size: 13px; }

/* ---------- Skills grid ---------- */
/* minmax(...,360px) previously capped how wide a column could grow, which -
   with few cards - left the grid computing a single narrow column instead of
   using the available page width. 1fr lets columns actually fill the row,
   same fix as .settings-grid uses. */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.skill-card {
  background: var(--graphite-800); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 20px; cursor: pointer;
  border-top: 3px solid var(--brand-red);
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s, transform 0.18s, box-shadow 0.18s;
  display: flex; flex-direction: column; gap: 10px;
}
.skill-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); }
.skill-card h4 { margin: 0; font-size: 15px; }
/* Clamped to 3 lines so a long instructions-style description doesn't make
   one card tower over its neighbors - full text is one click away in the
   report's own workspace. */
.skill-card p {
  margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.skill-card-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line);
}
.skill-card-schedule { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* ---------- Activity Log: per-user card view ---------- */
.activity-search { max-width: 360px; margin: 4px 0 16px; }
.activity-users-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 320px)); gap: 14px; }
.activity-user-card {
  background: var(--graphite-800); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 16px; cursor: pointer; border-top: 3px solid var(--brand-red);
  box-shadow: var(--shadow-card);
  transition: transform 0.18s, box-shadow 0.18s;
}
.activity-user-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-hover); }
.activity-user-card h4 { margin: 0 0 2px; font-size: 14px; }
.activity-user-card .muted { display: block; margin-bottom: 12px; font-size: 12px; word-break: break-all; }
.activity-user-card-stats { display: flex; gap: 18px; }
.activity-user-card-stat { font-size: 12px; color: var(--muted); }
.activity-user-card-stat strong { display: block; font-size: 18px; font-family: var(--font-display); color: var(--ivory); }

.modal-card-wide { width: 800px; max-width: 92vw; }
.user-activity-kpis { display: flex; gap: 24px; margin: 0 0 18px; flex-wrap: wrap; }
.user-activity-kpis .activity-user-card-stat { font-size: 13px; }

.skill-detail { margin-top: 10px; }
.skill-detail h3 { font-family: var(--font-display); font-size: 20px; margin: 14px 0 4px; }

.skill-run-row { display: flex; align-items: center; gap: 14px; margin: 12px 0; }

#uploader-admin-only .delete-btn { border-color: var(--red); color: var(--red); }
#uploader-admin-only .delete-btn:hover { background: var(--red); color: var(--ivory); }

/* ---------- Dashboards tab ---------- */
.dashboards-layout { display: flex; gap: 20px; margin-top: 16px; align-items: flex-start; }
.dashboards-nav { width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.dashboards-content { flex: 1; min-width: 0; }
.dashboard-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.dashboard-toolbar select {
  background: var(--graphite-700); border: 1px solid var(--line); color: var(--ivory);
  padding: 8px 10px; border-radius: 3px; font-size: 13px;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dashboard-frame-wrap {
  background: var(--graphite-700); border: 1px solid var(--line); border-radius: 4px;
  overflow: hidden; height: 75vh;
}
.dashboard-frame-wrap:fullscreen { height: 100vh; border-radius: 0; }
.dashboard-frame { width: 100%; height: 100%; border: none; background: #fff; }

@media (max-width: 900px) {
  .dashboards-layout { flex-direction: column; }
  .dashboards-nav { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .dashboard-frame-wrap { height: 60vh; }
}

/* Per-report left-tab workspace: Skill Uploader / Input Files / Output Files */
.skill-workspace { display: flex; gap: 20px; margin-top: 20px; align-items: flex-start; }
.skill-subnav { width: 170px; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; }
.subnav-btn {
  text-align: left; background: var(--graphite-800); border: 1px solid var(--line); color: var(--muted);
  padding: 10px 14px; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.subnav-btn.active { color: var(--ivory); border-color: var(--brand-red); background: var(--graphite-700); }
.subnav-btn:hover { color: var(--ivory); border-color: var(--muted); }
.skill-subpanel { flex: 1; background: var(--graphite-800); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 22px; min-width: 0; }
.subtab-content { display: none; }
.subtab-content.active { display: block; }
.subtab-content h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.subtab-content h4:not(:first-child) { margin-top: 20px; }

.instructions-view {
  white-space: pre-wrap; word-break: break-word; font-family: var(--font-mono); font-size: 12px;
  background: var(--graphite-700); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px;
  max-height: 360px; overflow-y: auto; margin: 0;
}
.uploader-row { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }

.cron-builder {
  display: flex; flex-direction: column; gap: 14px; margin: 10px 0 12px;
  padding: 16px; background: var(--graphite-700); border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.cron-field-row {
  display: grid; grid-template-columns: minmax(100px, 160px) 1fr; grid-template-rows: auto auto;
  grid-template-areas: "label label" "input preset"; gap: 6px 12px; align-items: center;
}
.cron-field-label { grid-area: label; font-weight: 600; font-size: 13px; color: var(--ivory); }
.cron-field-input { grid-area: input; }
.cron-field-preset { grid-area: preset; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ivory); margin-bottom: 4px; cursor: pointer; }
.checkbox-row input { width: 16px; height: 16px; }

.report-config-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 8px; }
.report-config-form input, .report-config-form select {
  background: var(--graphite-700); border: 1px solid var(--line); color: var(--ivory);
  padding: 7px 9px; border-radius: 3px; font-size: 12px;
}
.report-config-form select#rc-endpoint { flex: 1 1 220px; min-width: 160px; }
.report-config-form input[type="number"] { width: 70px; }
#rc-instructions {
  width: 100%; margin-bottom: 10px; resize: vertical;
  font-family: var(--font-mono); font-size: 12px;
}

.data-source-grid { margin: 0 0 20px; display: grid; grid-template-columns: 1fr; gap: 4px; max-width: 640px; }
.ds-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.ds-row dt { color: var(--muted); margin: 0; }
.ds-row dd { margin: 0; text-align: right; color: var(--ivory); }
.ds-name-edit-btn { margin-left: 8px; padding: 1px 8px; font-size: 12px; }
.ds-name-edit-row { display: inline-flex; align-items: center; gap: 6px; }
.ds-name-edit-row input { font-size: 13px; padding: 3px 6px; min-width: 200px; }

.folder-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.folder-col-head h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.upload-btn { font-size: 12px; padding: 6px 12px; }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--graphite-700); border: 1px solid var(--line);
  padding: 9px 12px; border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 12px;
  transition: border-color 0.15s, transform 0.15s;
}
.file-list li:hover { border-color: var(--muted); transform: translateX(2px); }
.file-actions { display: flex; gap: 8px; }
.file-actions button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; }
.file-actions button:hover { color: var(--brand-red-hot); }
.file-actions .delete-btn:hover { color: var(--red); }
.empty-state {
  color: var(--muted); font-size: 12px; padding: 20px 14px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius-md);
}

/* ---------- Users table ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em;
  color: var(--muted); border-bottom: 1px solid var(--line); padding: 10px 8px;
}
.data-table td { padding: 9px 8px; border-bottom: 1px solid var(--graphite-700); }
.data-table td.mono { font-family: var(--font-mono); font-size: 12px; }
.data-table td.endpoint-cell {
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: help;
}
.data-table tbody tr { transition: background-color 0.1s; }
/* Zebra-striping - a dense, spreadsheet-like row cue common to traditional
   enterprise admin tables, absent from the previous hover-only design. */
.data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.data-table tbody tr:hover { background: rgba(255,255,255,0.045); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.role-badge {
  font-family: var(--font-mono); font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--graphite-700); color: var(--muted);
}
.role-badge.masteradmin { background: rgba(200,16,46,0.15); color: var(--brand-red-hot); }
.access-tag { font-family: var(--font-mono); font-size: 11px; color: var(--teal); margin-right: 6px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(10,13,17,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: modal-backdrop-in 0.15s ease-out;
}
.modal-card {
  width: 460px; max-height: 80vh; overflow-y: auto;
  background: var(--graphite-800); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 28px;
  box-shadow: var(--shadow-md);
  animation: modal-card-in 0.18s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes modal-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-card-in { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-card h3 { font-family: var(--font-display); margin: 0 0 18px; }
.modal-card form { display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.access-list { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--line); border-radius: 3px; padding: 12px; }
.access-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; padding: 4px 0; }
.access-row span.skill-label { flex: 1 1 100%; text-transform: none; letter-spacing: 0; color: var(--ivory); font-weight: 600; margin-bottom: 2px; }
.access-row label { flex-direction: row; align-items: center; gap: 4px; text-transform: none; white-space: nowrap; }

.permissions-grid { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: 3px; padding: 12px; }
.perm-row { display: flex; flex-direction: column; gap: 3px; font-size: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--graphite-700); }
.perm-row:last-child { padding-bottom: 0; border-bottom: none; }
.perm-row-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.perm-row .perm-label { color: var(--ivory); text-transform: none; letter-spacing: 0; font-weight: 600; }
.perm-row .perm-select { width: auto; min-width: 150px; padding: 4px 8px; font-size: 12px; flex-shrink: 0; }
.perm-hint { margin: 0; font-size: 11px; color: var(--muted); text-transform: none; letter-spacing: 0; }

.extra-field-row { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; }
.extra-field-row input { flex: 1; min-width: 0; }
.extra-field-row .extra-field-remove { flex-shrink: 0; font-size: 11px; padding: 8px 10px; }

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

/* ---------- Settings card grid ---------- */
.settings-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px; margin-top: 20px; align-items: start;
}
.settings-card {
  background: var(--graphite-800); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 22px;
  box-shadow: var(--shadow-card);
}
.settings-card h3 { font-family: var(--font-display); font-size: 16px; margin: 0 0 16px; }
.settings-card .modal-actions { justify-content: flex-start; }
/* For cards with meaningfully more content than a simple single-field card
   (tab strips, multiple field groups) - spans the full grid row instead of
   being squeezed into the same ~320px auto-fit column as Branding/Claude API,
   which left tab labels almost touching the card edge. Form width is still
   capped so text inputs don't stretch uncomfortably wide just because the
   card itself is wide. */
.settings-card-wide { grid-column: 1 / -1; }
.settings-card-wide .settings-form { max-width: 640px; }

.modal-divider { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0; }

.email-preview-card { max-height: 90vh; }
.email-preview-iframe {
  width: 100%; height: 60vh; border: 1px solid var(--line); border-radius: 3px;
  background: #f0f1f3; margin-top: 6px;
}

.smtp-provider-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.smtp-provider-tab {
  font-family: var(--font-body); font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 8px 4px; margin-bottom: -1px; cursor: pointer;
}
.smtp-provider-tab:hover { color: var(--ivory); }
.smtp-provider-tab.active { color: var(--ivory); border-bottom-color: var(--brand-red); }

/* Same visual pattern as .smtp-provider-tab, kept as a separate class (not
   shared) so this tab group's JS toggle logic can't cross-talk with SMTP's -
   see the Email Templates card in Settings. */
.email-template-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.email-template-tab {
  font-family: var(--font-body); font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 8px 4px; margin-bottom: -1px; cursor: pointer;
}
.email-template-tab:hover { color: var(--ivory); }
.email-template-tab.active { color: var(--ivory); border-bottom-color: var(--brand-red); }
.email-template-fields { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.smtp-provider-fields { display: flex; flex-direction: column; gap: 14px; padding-top: 4px; }
.upload-skill-block { display: flex; flex-direction: column; gap: 10px; }
.upload-skill-block label { gap: 8px; }

/* Top-level page tables (Users, Roles, Connectors, Activity Log) get a card
   frame; tables already nested inside a card (skill workspace, modals) don't
   get this class, to avoid a double-boxed look. */
.panel-card { background: var(--graphite-800); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 4px 16px; box-shadow: var(--shadow-card); }

/* ---------- Responsive ---------- */
.table-scroll { overflow-x: auto; }

@media (max-width: 900px) {
  .app-main { max-width: 100%; }
}

@media (max-width: 768px) {
  .login-card { width: min(360px, 92vw); padding: 32px 24px; }

  .sidebar-toggle { display: flex; }
  .topbar-brand span:not(.brand-mark-target) { display: none; }
  .topbar-title { padding-left: 10px; font-size: 13px; }
  .whoami { display: none; }

  /* Off-canvas drawer: slides in from the left over the content, instead of
     the old approach of squashing every nav button into a wrapped horizontal
     bar - that doesn't scale once Dashboards can hold a variable number of
     per-user entries (see renderDashboardsNavEntries in app.js). Animates
     `left` rather than `transform` - equally valid for a simple drawer and
     avoids any compositor-layer edge cases with transform-based positioning. */
  .app-body { position: relative; }
  .sidebar {
    position: fixed; top: var(--header-height); left: -260px; bottom: 0; z-index: 60;
    width: 260px; max-width: 80vw; height: auto;
    transition: left 0.2s ease-out;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { left: 0; }
  .sidebar-scrim.hidden { display: none; }
  .sidebar-scrim {
    display: block; position: fixed; inset: var(--header-height) 0 0 0; z-index: 55;
    background: rgba(0,0,0,0.5);
  }

  .app-main { padding: 16px; }
  .panel-header { flex-wrap: wrap; gap: 10px; }

  .skill-workspace { flex-direction: column; }
  .skill-subnav { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .dashboards-nav { max-height: none; }

  .data-table { font-size: 12px; }
  .data-table td.endpoint-cell { max-width: 160px; }
  .modal-card { width: min(460px, 92vw); padding: 20px; }

  .dashboard-frame-wrap { height: 55vh; }
  /* The generated output filename (long, timestamped) shouldn't compete with
     the toolbar buttons for space on a narrow screen - give it its own row. */
  .dashboard-toolbar select { flex: 1 1 100%; max-width: none; order: -1; }
}

@media (max-width: 480px) {
  .skills-grid { grid-template-columns: 1fr; }
  .report-config-form input[type="text"] { flex-basis: 100%; }
  .row-actions { flex-wrap: wrap; justify-content: flex-start; }
  .uploader-row { flex-wrap: wrap; }
  .ds-row { flex-direction: column; gap: 2px; }
  .ds-row dd { text-align: left; word-break: break-word; }
  .dashboard-toolbar { gap: 8px; }
  .dashboard-toolbar .btn-secondary { flex: 1 1 auto; font-size: 12px; padding: 8px 10px; }
}

/* ---------- Toast notifications ---------- */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 1000;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  background: var(--graphite-800); border: 1px solid var(--line); border-left: 4px solid var(--teal);
  color: var(--ivory); padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease-out;
  display: flex; align-items: center; gap: 10px;
}
.toast::before { font-weight: 700; font-size: 15px; flex-shrink: 0; content: "\2713"; color: var(--teal); }
.toast.error { border-left-color: var(--red); }
.toast.error::before { content: "\2715"; color: var(--red); }
.toast.warning { border-left-color: var(--brand-red); }
.toast.warning::before { content: "!"; color: var(--brand-red-hot); }
.toast.fade-out { animation: toast-out 0.25s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateX(24px); } }

@media (max-width: 480px) {
  .toast-container { left: 12px; right: 12px; top: 12px; max-width: none; }
}

/* ---------- Branding ---------- */
.brand-logo-img { display: block; width: 100%; height: auto; border-radius: 4px; }
.logo-preview { width: 40px; height: 40px; object-fit: contain; border: 1px solid var(--line); border-radius: 3px; background: var(--graphite-700); }

/* ---------- Status badges (run history) ---------- */
.status-badge {
  display: inline-block; font-family: var(--font-mono); font-size: 11px; padding: 2px 8px;
  border-radius: 10px; text-transform: capitalize;
}
.status-badge.success { background: rgba(63,157,92,0.15); color: var(--teal); }
.status-badge.failed { background: rgba(200,16,46,0.15); color: var(--brand-red-hot); }
.status-badge.running { background: rgba(154,154,154,0.15); color: var(--muted); }
.error-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Scrollbars (dark theme) ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--graphite-600) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--graphite-600); border-radius: 5px; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }
