/* NYX Copper: one palette for administration, report workspaces and tools.
   Document previews intentionally keep their own paper, ink and formatting. */
:root {
  color-scheme: dark;
  --bg: #181310;
  --surface: #251e19;
  --surface-raised: #302720;
  --surface-subtle: #201a16;
  --text: #f1e7d8;
  --secondary: #c4b3a2;
  --muted: #af9c89;
  --border: #594939;
  --divider: #44372d;
  --control-bg: #1b1612;
  --control-border: #8d735e;
  --field-border: transparent;
  --button-bg: #3d3026;
  --button-hover: #4a392c;
  --button-radius: 7px;
  --button-min-height: 32px;
  --button-padding: 7px 11px;
  --primary: #e2a779;
  --primary-hover: #efbd95;
  --primary-soft: #493225;
  --on-primary: #23170f;
  --success: #a6d3b5;
  --success-soft: #20362c;
  --success-border: #587b65;
  --warning: #e7c081;
  --warning-soft: #403020;
  --warning-border: #9a7848;
  --error: #f0aaa0;
  --error-soft: #402723;
  --error-border: #9e6760;
  --info: #b5c9db;
  --info-soft: #29333b;
  --shadow-color: #100c0970;
  --overlay: #100c09b8;
  --radius: 12px;
  /* Aliases for the standalone Excel workspace. */
  --ink: var(--text);
  --line: var(--border);
  --paper: var(--surface);
  --accent: var(--primary);
  --wash: var(--surface-subtle);
  --danger: var(--error);
  --sheet-paper: #fff;
  --sheet-ink: #20252b;
  --sheet-muted: #536478;
  --sheet-header: #ede8df;
  --sheet-grid: #d9d2c7;
  --sheet-selection: #af6334;
}
html { background: var(--bg); }
body {
  background: radial-gradient(ellipse at 85% 0, #8151371c, transparent 48%), var(--bg);
  color: var(--text);
}
::selection { color: var(--text); background: #745139; }
:focus-visible { outline-color: var(--primary); }
input, select, textarea { color: var(--text); accent-color: var(--primary); }
::placeholder { color: var(--muted); opacity: 1; }
/* Exclude Monaco's hidden input: its dimensions, padding and colors are managed
   by the editor. Never use bare .main selectors (Monaco also has a .main). */
:root :where(input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]), select, textarea, [role=combobox]):not(.inputarea):not(.monaco-mouse-cursor-text) {
  background-color: var(--control-bg);
  color: var(--text);
  border-color: var(--field-border);
}
input[type=file]::file-selector-button {
  background: var(--button-bg);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--button-radius);
  font-size: 12px;
  font-weight: 600;
  padding: 7px 11px;
  margin-right: 10px;
  cursor: pointer;
}
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
/* Cover the browser's autofill fill without disabling saved credentials or focus. */
:root .login-page input:is(:autofill, :-webkit-autofill) {
  box-shadow: inset 0 0 0 1000px var(--control-bg);
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}
input:disabled, select:disabled, textarea:disabled { color: var(--muted); }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
dialog { background: var(--surface); color: var(--text); border-color: var(--border); }
dialog::backdrop { background: var(--overlay); }
pre, code { color: inherit; }
.sidebar, .settings-navigation {
  background: linear-gradient(165deg, #30271f, var(--surface-subtle) 70%);
  border-right-color: var(--border);
}
.brand { color: var(--text); }
.brand span { color: var(--primary); }
nav a.active, .settings-navigation nav button[aria-current=page] {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: transparent;
  box-shadow: inset 3px 0 var(--primary);
}
nav a:hover, .settings-navigation nav button:hover { background: var(--surface-raised); }
nav a.active:hover, .settings-navigation nav button[aria-current=page]:hover { background: var(--primary-soft); }
.card, .settings-panel, .settings-mail-drawer, .file-editor, .mail-editor-card {
  box-shadow: inset 0 1px 0 #f1e7d808, 0 6px 18px #100c091c;
}
h1, h2, h3, .stat .big { text-wrap: balance; }
/* Three action variants. Component-specific sizing stays compact in SQL and
   table tools; colors, corner shape and interaction states are shared. */
.btn, .run-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 11px;
  min-height: 32px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  cursor: pointer;
}
:root .btn, :root .run-btn {
  border: 1px solid transparent;
  border-radius: var(--button-radius);
  background: var(--button-bg);
  color: var(--text);
  box-shadow: none;
  transition: background-color .15s ease, color .15s ease;
}
:root .btn:hover:not(:disabled), :root .run-btn:hover:not(:disabled) {
  background: var(--button-hover);
  border-color: transparent;
  text-decoration: none;
}
:root .btn.primary, :root button.primary {
  color: var(--on-primary);
  background: var(--primary);
  border-color: transparent;
}
:root .btn.primary:hover:not(:disabled), :root button.primary:hover:not(:disabled) {
  background: var(--primary-hover);
  color: var(--on-primary);
  border-color: transparent;
}
:root .btn.quiet, :root .btn.tertiary {
  color: var(--secondary);
  background: transparent;
  border-color: transparent;
  font-size: 12px;
  line-height: 1.35;
  min-height: var(--button-min-height);
  padding: var(--button-padding);
}
:root .btn.quiet:hover:not(:disabled), :root .btn.tertiary:hover:not(:disabled) {
  background: var(--button-bg);
  color: var(--text);
}
:root .btn.danger, :root .btn.danger:hover:not(:disabled) {
  color: var(--error);
  border-color: transparent;
  background: transparent;
}
:root .btn.danger:hover:not(:disabled) { background: var(--error-soft); }
:root .btn:disabled, :root button:disabled, :root .btn[aria-disabled=true] {
  opacity: .45;
  cursor: not-allowed;
}
:root .btn:disabled:hover { background: var(--button-bg); }
:root .btn.primary:disabled:hover { background: var(--primary); }
:root .btn.quiet:disabled:hover, :root .btn.danger:disabled:hover { background: transparent; }
:root .btn.active, :root .btn[aria-expanded=true], :root .btn[aria-pressed=true], .create-steps button[aria-current=step], .visual-stages [aria-current=step],
.visual-sheets [aria-pressed=true], .role-choice.selected {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}
.visual-stages [aria-current=step] span { background: var(--primary); color: var(--on-primary); }
.role-choice.selected, .excel-role.is-active .role-choice { box-shadow: none; background: var(--primary-soft); }
.role-value { color: var(--text); }
.settings-draft-strip { background: var(--surface-subtle); }
.settings-draft-strip strong:not(.err) { color: var(--success); }
.settings-savebar, .create-savebar { background: var(--surface-subtle); }

.settings-overview-card:hover { background: var(--surface-raised); border-color: var(--primary); }

.badge.running, .badge.claimed, .badge.busy { color: var(--info); background: var(--info-soft); }
.badge.queued, .badge.waiting { color: var(--warning); background: var(--warning-soft); }
.badge.canceled { color: var(--secondary); background: var(--surface-raised); }
.chart-bar, .legend span::before { background: var(--primary); }
.chart-bar .bad, .legend .bad::before { background: var(--error); }
.history-gridline { stroke: var(--border); }
.toast { color: var(--text); background: var(--surface-raised); border: 1px solid var(--primary); }
.qd-page { --button-min-height: 26px; --button-padding: 4px 8px; }
/* Tool chrome uses the same visual language as report configuration. */
.qd-appbar { background: var(--surface-subtle); border-bottom: 1px solid var(--border); }
.qd-logo { background: var(--primary); color: var(--on-primary); }
.qd-page input:not([type=checkbox]), .qd-page select, .qd-page textarea,
.create-panel input:not([type=checkbox]):not([type=radio]):not([type=color]), .create-panel select, .create-panel textarea,
.settings-mail-drawer input, .workspace-code-tools select {
  background: var(--control-bg);
  color: var(--text);
  border-color: var(--field-border);
}
/* Labels and filled surfaces identify fields. Focus never moves the layout.
   aria-invalid remains visible after blur; keyboard buttons get the same ring. */
:root :where(input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]), select, textarea, [role=combobox]):not(.inputarea):not(.monaco-mouse-cursor-text) {
  border-color: transparent;
  border-radius: var(--button-radius);
  box-shadow: none;
}
:root :where(input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]), select, textarea, [role=combobox]):not(.inputarea):not(.monaco-mouse-cursor-text):focus {
  outline: 1px solid var(--primary);
  outline-offset: 0;
}
:root [aria-invalid=true]:not(.inputarea), :root [aria-invalid=true]:not(.inputarea):focus {
  border-color: var(--error-border);
  outline: 1px solid var(--error);
  outline-offset: 0;
}
:root :is(button, a.btn, summary):focus-visible {
  outline: 1px solid var(--primary);
  outline-offset: 0;
}
:root .create-panel .weekday {
  background: var(--button-bg);
  border-color: transparent;
  border-radius: var(--button-radius);
}
:root .create-panel .weekday:has(:checked) { background: var(--primary-soft); color: var(--primary); }
:root .create-steps button, :root .file-filters button, :root .recipient-tabs button,
:root .help-icon, :root .settings-help, :root .role-choice { border-color: transparent; }
:root .help-icon, :root .settings-help { background: transparent; color: var(--secondary); }
:root .help-icon:hover, :root .settings-help:hover { background: var(--button-bg); color: var(--text); }
:root .recipient-tabs { display: flex; gap: 6px; }
:root .recipient-tabs button { border-radius: var(--button-radius); }
.settings-mail-tabs, .event-tabs, .visual-stages { border-bottom-color: transparent; }
:root .settings-mail-tabs button, :root .event-tabs button, :root .qd-drawer-tabs button {
  border-color: transparent;
  border-radius: var(--button-radius);
  background: transparent;
  color: var(--secondary);
}
:root .settings-mail-tabs button[aria-selected=true], :root .event-tabs button[aria-selected=true],
:root .qd-drawer-tabs button[aria-selected=true], :root .file-filters button[aria-pressed=true],
:root .recipient-tabs button[aria-pressed=true], :root .tool-row button[aria-pressed=true] {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
}
:root .version-trigger { border-color: transparent; background: var(--surface-raised); }
:root .version-trigger:hover { border-color: transparent; background: var(--button-hover); }
#workspace-mail-code, #mail-code, #code-editor, #hook-code-editor { border-color: transparent; }
/* Preserve the workbook, including unformatted cells and conditional colors.
   Selection adds an outline, never a replacement fill over template styles. */
.excel-scroll, .excel-table, .preview-scroll, .preview table, #style-sample {
  color-scheme: light;
  background: var(--sheet-paper);
  color: var(--sheet-ink);
}
.excel-table th, .excel-table td, .preview td, .preview th {
  border-color: var(--sheet-grid);
}
.excel-table thead th, .excel-table tr>th:first-child, .preview th,
.preview tbody th.preview-row-number, .preview th.preview-hidden-column {
  color: var(--sheet-muted);
  background: var(--sheet-header);
}
.excel-table thead span, .preview th.preview-row-number { color: var(--sheet-muted); }
.excel-table button, .preview th button { color: inherit; }
.excel-table tbody tr:hover, .preview table tbody tr:hover { background: transparent; }
.excel-table .selected-row>*, .excel-table .selected-column, .excel-table .selected-cell {
  box-shadow: inset 0 0 0 2px var(--sheet-selection);
}
.excel-table button:hover { box-shadow: inset 0 0 0 2px var(--sheet-selection); }
.preview .preview-selected, .preview td:focus-visible { outline-color: var(--sheet-selection); }
:root .excel-table button:focus-visible, :root .preview th button:focus-visible { outline-color: var(--sheet-selection); outline-offset: -2px; }
.preview .preview-placeholder { color: var(--sheet-muted) !important; }
.preview .preview-issue { box-shadow: inset 0 -3px #b23f30; }
#workspace-mail-frame, #mail-preview-frame {
  color-scheme: light;
  background: var(--sheet-paper);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}


/* Respect the user's Windows high-contrast mode even though the normal theme
   intentionally uses borderless surfaces. */
@media (forced-colors: active) {
  :root .btn, :root input:not(.inputarea), :root select, :root textarea:not(.inputarea), :root [role=combobox] {
    border: 1px solid ButtonText !important;
  }
}
