/* base.css — reset, focus ring, reduced-motion, buttons/chips/status, modal, toast. */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: var(--bg); color: var(--ink-primary); font-family: var(--font-body); font-size: 13px; line-height: 1.45; }
button { font-family: var(--font-body); cursor: pointer; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }

/* One focus ring for the whole panel — instantly shown, never animated
   (WCAG 2.4.7): buttons, inputs, selects, chips and clickable cards. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible {
  outline-offset: 0;
}

/* Reduced-motion rules must sit AFTER the rules they override — a media
   query earlier in the cascade loses to a later defining declaration
   (.toast is defined below; its reduced-motion rule lives after it). */

/* ---------- buttons & chips ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 7px;
  padding: 0 12px;
  height: var(--control-h);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-primary);
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}
.btn:hover { border-color: var(--border-strong); }
.btn:active:not(:disabled) {
  transform: scale(0.98);
}
.btn.primary { background: var(--accent-deep); color: var(--bg); border-color: var(--accent-deep); }
.btn.primary:hover { background: var(--ink-primary); box-shadow: 0 2px 8px rgba(35, 42, 38, 0.18); }
.btn.primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.danger { color: var(--err-ink); border-color: var(--err-ink); }
.btn.small { height: var(--control-h-sm); padding: 0 8px; font-size: 12px; }
.awin-src-card .down { color: var(--err-ink); }

/* ---------- modern select dropdowns ---------- */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23707973' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px !important;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select:hover {
  border-color: var(--border-strong);
}
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(111,116,87,.18);
}

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-family: var(--font-mono); border: 1px solid var(--border); background: var(--bg-inset); }
.chip.drag { cursor: grab; }
.chip.drag:active { cursor: grabbing; }

.status { font-family: var(--font-mono); font-size: 11.5px; padding: 3px 9px; border-radius: 12px; }
.status.queued { background: var(--amber-bg); color: var(--warn-ink); }
.status.running, .status.previewing { background: var(--chip-run-bg); color: var(--chip-run-ink); }
.status.succeeded, .status.confirmed { background: var(--chip-ok-bg); color: var(--ok-ink); }
.status.failed, .status.interrupted { background: var(--chip-err-bg); color: var(--err-ink); }
.status.cancelled { background: var(--bg-inset); color: var(--ink-secondary); }
.status.proposed, .status.warn { background: var(--amber-bg); color: var(--warn-ink); }
.status.superseded { background: var(--bg-inset); color: var(--ink-tertiary); }

/* modal — visibility (not display) so the fade/slide can actually
   transition; reduced-motion users get an instant swap. */
.modal-back { position: fixed; inset: 0; background: rgba(35,42,38,.35); display: flex; align-items: center; justify-content: center; z-index: 40; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s ease-out, visibility .15s; }
.modal-back.open { opacity: 1; visibility: visible; pointer-events: auto; }
.modal-back .modal { transform: translateY(6px) scale(.985); transition: transform .15s ease-out; }
.modal-back.open .modal { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .modal-back, .modal-back .modal { transition: none; }
}
.modal { background: var(--bg); border-radius: 12px; padding: 26px; width: 460px; border: 1px solid var(--border); }
.modal h3 { margin-bottom: 16px; font-size: 19px; }
.modal label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-secondary); margin: 10px 0 4px; }
.modal input, .modal select { width: 100%; height: var(--control-h); padding: 0 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-card); font-family: var(--font-body); font-size: 13.5px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--accent-deep); color: var(--bg); padding: 11px 22px; border-radius: 8px; font-size: 13px; z-index: 100; opacity: 0; transition: opacity .25s; pointer-events: none; display: flex; gap: 12px; align-items: center; }
.toast.show { opacity: 1; pointer-events: auto; }
.toast.err { background: var(--err); }
.toast-x { background: none; border: none; color: inherit; font-size: 13px; cursor: pointer; padding: 2px 4px; margin: -2px -8px -2px 0; opacity: .7; min-width: 24px; min-height: 24px; }
.toast-x:hover { opacity: 1; }
.toast .toast-link { background: none; border: 0; padding: 0; margin: 0; color: inherit; font-size: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; opacity: .9; }
.toast .toast-link:hover { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  /* Must follow .toast's own rule above — the later transition declaration
     used to win the cascade, leaving reduced-motion latent (carried fix). */
  .toast { transition: none; }
}

/* ---------- rule modal extras ---------- */
.modal textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg-card); font-family: var(--font-body); font-size: 13.5px; min-height: 64px; resize: vertical; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--ink-secondary); }
.modal .checkbox-row input { width: 14px; height: 14px; }

/* ---------- global table row selection ---------- */
tr.selected-row td {
  background: var(--bg-hover) !important;
}
tr.selected-row td:first-child {
  border-left: 2px solid var(--accent);
}
