/* ══════════════════════════════════════════════════════════════════
   kma.css — Pure extraction from HEAD~1:unified.html L1183-1249
   ══════════════════════════════════════════════════════════════════ */
    /* ── DAT & Markets sub-tabs ── */
    .dat-subtab-btn {
      padding: 7px 14px;
      border-radius: 8px 8px 0 0;
      border: 1px solid transparent;
      background: transparent;
      color: var(--text-muted);
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      transition: all .18s;
      margin-bottom: -11px;
    }

    .dat-subtab-btn:hover {
      color: var(--text-sec);
    }

    .dat-subtab-btn.active {
      color: var(--amber);
      border-color: var(--border);
      border-bottom-color: var(--surface-1);
      background: var(--surface-2);
    }

    .dat-pill {
      display: inline-block;
      padding: 2px 9px;
      border-radius: 999px;
      font-size: 0.75rem;
      font-weight: 700;
    }

    .dat-pill-global {
      background: var(--warn-border);
      color: var(--amber);
    }

    .dat-pill-client {
      background: var(--accent-border);
      color: var(--accent);
    }

    .dat-pos {
      color: var(--accent);
      font-weight: 700;
    }

    .dat-neg {
      color: var(--neg);
      font-weight: 700;
    }

    .dat-icon-btn {
      background: none;
      border: none;
      cursor: pointer;
      color: var(--text-muted);
      padding: 4px;
      border-radius: 6px;
      transition: all .15s;
    }

    .dat-icon-btn:hover {
      color: var(--amber);
      background: var(--surface-2);
    }

    /* ── DAT & Markets step navigation ─────────────────────────────────
       Line + icon node stay exactly as-is (untouched, no tint). The only
       clickable-area cue is a border around the label pill itself — sized
       to the text, not the whole column — that's always visible in gray
       and turns green on the active tab. ──────────────────────────────── */
    .dat-stepper {
      position: relative;
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 4px;
      margin: 4px 0 22px;
      padding: 0 4px;
    }

    .dat-stepper-track {
      position: absolute;
      top: 15px;
      left: calc(100% / 6);
      right: calc(100% / 6);
      height: 2px;
      background: var(--border-strong);
      border-radius: 2px;
      z-index: 0;
    }

    .dat-stepper-fill {
      position: absolute;
      top: 0;
      left: 0;
      height: 100%;
      width: 0%;
      background: var(--accent-bright);
      border-radius: 2px;
      transition: width .28s ease;
    }

    .dat-step {
      position: relative;
      z-index: 1;
      flex: 1 1 0;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 10px;
      background: none;
      border: none;
      padding: 0;
      cursor: pointer;
      font-family: inherit;
    }

    .dat-step:focus-visible .dat-step-label {
      outline: 2px solid var(--accent-border);
      outline-offset: 1px;
    }

    .dat-step-node {
      position: relative;
      width: 32px;
      height: 32px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--surface);
      border: 2px solid var(--border-strong);
      color: transparent;
      transition: all .2s ease;
      align-self: center;
    }

    .dat-step-node-dot {
      width: 9px;
      height: 9px;
      border-radius: 50%;
      background: var(--border-strong);
      transition: all .2s ease;
    }

    .dat-step-node-icon {
      display: none;
    }

    /* The label box: this is the only element that shows a border, and its
       border is always visible (not just on hover). It's stretched to the
       full width of its column — matching the actual clickable width of
       the whole .dat-step button — so what you see bordered is exactly
       what you can click, with no dead space to either side. It still
       starts below the node/line, never covering them. */
    .dat-step-label {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      font-size: 0.85rem;
      font-weight: 600;
      color: var(--text-muted);
      padding: 8px 12px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--surface);
      transition: color .16s ease, border-color .16s ease, background .16s ease;
      white-space: nowrap;
      width: 100%;
      box-sizing: border-box;
    }

    .dat-step:hover .dat-step-label {
      color: var(--text-sec);
      border-color: var(--border-strong);
      background: var(--surface-2);
    }

    /* completed step: filled track dot, no icon, accent label */
    .dat-step.is-done .dat-step-node {
      border-color: transparent;
      background: transparent;
    }

    .dat-step.is-done .dat-step-node-dot {
      background: var(--accent-bright);
      width: 11px;
      height: 11px;
    }

    .dat-step.is-done .dat-step-label {
      color: var(--accent);
    }

    /* active step: solid dark node carrying the icon */
    .dat-step.active .dat-step-node {
      width: 38px;
      height: 38px;
      background: var(--pine);
      border-color: var(--pine);
      color: var(--on-accent, #fff);
    }

    .dat-step.active .dat-step-node-dot {
      display: none;
    }

    .dat-step.active .dat-step-node-icon {
      display: block;
    }

    .dat-step.active .dat-step-label {
      color: var(--accent);
      font-weight: 700;
      border-color: var(--accent);
      background: var(--accent-soft);
    }

    /* upcoming step: hollow ring, muted label */
    .dat-step:not(.active):not(.is-done) .dat-step-label {
      color: var(--text-muted);
    }

    @media (max-width: 640px) {
      .dat-step-label { font-size: 0.72rem; }
      .dat-stepper-track { left: 19px; right: 19px; }
    }

    /* ── Fixed-size tab bar (sits under the step track) ──────────────────
       One continuous surface split by hairlines instead of three separate
       pill buttons. Icon, label, and badge keep constant size and position
       in every state — the active tab is marked with a subtle background
       tint only, no moving highlight, so switching sections never reflows
       or resizes the row. */
    .dat-tabbar {
      position: relative;
      display: flex;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      overflow: hidden;
      margin: 0 0 22px;
    }

    .dat-tab {
      position: relative;
      z-index: 1;
      flex: 1 1 0;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      background: none;
      border: none;
      border-right: 1px solid var(--border);
      cursor: pointer;
      font-family: inherit;
      padding: 14px 12px;
      color: var(--text-muted);
      transition: color .16s ease, background-color .16s ease;
    }

    .dat-tab:last-child { border-right: none; }

    .dat-tab:focus-visible {
      outline: 2px solid var(--accent-border);
      outline-offset: -2px;
    }

    .dat-tab svg { flex: none; }

    .dat-tab-label {
      font-size: 0.85rem;
      font-weight: 600;
      white-space: nowrap;
    }

    .dat-tab-badge {
      flex: none;
      min-width: 18px;
      padding: 1px 7px;
      border-radius: 10px;
      font-size: 0.7rem;
      font-weight: 700;
      text-align: center;
      background: var(--surface-2);
      color: var(--text-muted);
    }

    /* Active tab: a subtle background tint on the tab itself — no moving
       parts, just a color fade. */
    .dat-tab.active {
      color: var(--accent);
      background: var(--accent-soft);
    }

    .dat-tab.active .dat-tab-badge {
      background: var(--surface);
      color: var(--accent);
    }

    @media (max-width: 640px) {
      .dat-tab-label { font-size: 0.72rem; }
      .dat-tab { gap: 6px; padding: 12px 8px; }
    }

    /* ── Expandable detail rows (DAT Config / KMA Markets / Regions) ──────
       A chevron column toggles a hidden sub-row showing Applies-to/Created/
       Created by/Last modified/Modified by. The whole row is clickable
       (except Actions and any chip "more/less" toggles, which stop
       propagation) so tapping anywhere on it opens the detail panel. */
    .dat-clickable-row {
      cursor: pointer;
    }

    .dat-clickable-row:hover {
      background: var(--surface-2);
    }

    .dat-chev {
      transition: transform .18s ease;
      color: var(--text-muted);
      flex-shrink: 0;
    }

    tr.dat-row-open .dat-chev {
      transform: rotate(180deg);
      color: var(--accent);
    }

    .dat-expand-row td {
      padding: 0;
      border-bottom: 1px solid var(--border);
    }

    .dat-expand-panel {
      max-height: 0;
      overflow: hidden;
      transition: max-height .22s ease;
      background: var(--surface-1);
    }

    tr.dat-row-open + .dat-expand-row .dat-expand-panel {
      max-height: 220px;
    }

    .dat-expand-inner {
      padding: 16px 20px 18px 48px;
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
      gap: 18px;
      border-top: 1px dashed var(--border);
    }

    .dat-expand-inner .k {
      font-size: 0.68rem;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
      margin-bottom: 4px;
    }

    .dat-expand-inner .v {
      font-size: 0.85rem;
      font-weight: 600;
      color: var(--text-primary);
    }

    .dat-expand-inner .v.mono {
      font-family: var(--font-mono, monospace);
      font-weight: 600;
    }

    .dat-full-chips {
      grid-column: 1 / -1;
    }

    /* Chip row used inside expand panels (all prefixes) and, for KMA
       Markets, given a little extra breathing room via .dat-chip-row-kma. */
    .dat-chip-row {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      max-width: none;
    }

    .dat-chip-row-kma {
      gap: 11px;
    }

    .dat-zip-chip {
      font-family: var(--font-mono, monospace);
      font-size: 0.72rem;
      background: var(--surface-2);
      color: var(--text-sec);
      padding: 2px 7px;
      border-radius: 5px;
      border: 1px solid var(--border);
    }

    /* ── Combined name/prefix search box (replaces the old two-input
       search + reverse-lookup pair in KMA Markets / Regions) ── */
    .combo-search {
      display: flex;
      align-items: center;
      gap: 8px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 0 14px;
      flex: 1;
      min-width: 260px;
      transition: border-color .2s ease, box-shadow .2s ease;
    }

    .combo-search:focus-within {
      border-color: var(--amber);
      box-shadow: 0 0 0 3px var(--amber-glow);
    }

    .combo-search svg {
      color: var(--text-muted);
      flex-shrink: 0;
    }

    .combo-search input {
      padding: 10px 0;
      height: 38px;
    }

    /* ══════════════════════════════════════════════════════════════════
       Add/Edit dialog redesign (DAT Config · KMA Market · Region)
       Shared building blocks: section labels, segmented controls, option
       cards, a toggle switch, and icon-prefixed inputs. Namespaced "dm-"
       (dialog modal) so it never collides with existing table/page CSS.
       ══════════════════════════════════════════════════════════════════ */

    .dm-modal-box {
      max-width: 560px;
      width: 95%;
    }

    .dm-header-icon {
      width: 38px;
      height: 38px;
      border-radius: 10px;
      background: var(--accent-soft);
      color: var(--accent);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }

    .dm-header-text h3 {
      margin: 0;
      font-size: 1.1rem;
      font-weight: 800;
      letter-spacing: -0.2px;
      color: var(--text-primary);
    }

    .dm-header-text p {
      margin: 2px 0 0;
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    .dm-section {
      margin-bottom: 20px;
    }

    .dm-section:last-child {
      margin-bottom: 0;
    }

    .dm-label {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 0.72rem;
      font-weight: 700;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      margin-bottom: 8px;
    }

    .dm-sublabel {
      font-size: 0.8rem;
      color: var(--text-muted);
      margin: -4px 0 8px;
      line-height: 1.4;
    }

    .dm-sublabel code {
      background: var(--surface-3);
      padding: 1px 5px;
      border-radius: 4px;
      font-size: 0.75rem;
    }

    /* Icon-prefixed text input */
    .dm-input-icon {
      position: relative;
      display: flex;
      align-items: center;
    }

    .dm-input-icon svg {
      position: absolute;
      left: 12px;
      color: var(--text-muted);
      pointer-events: none;
      flex-shrink: 0;
    }

    .dm-input-icon input {
      width: 100%;
      box-sizing: border-box;
      padding: 10px 12px 10px 34px;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--surface);
      color: var(--text-primary);
      font-size: 0.88rem;
      font-family: inherit;
      transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

    .dm-input-icon input:focus {
      outline: none;
      border-color: var(--amber);
      box-shadow: 0 0 0 3px var(--amber-glow);
    }

    /* Segmented control — used for Scope and Time Frame */
    .dm-seg {
      display: flex;
      gap: 6px;
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 4px;
    }

    .dm-seg-btn {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 9px 10px;
      border: none;
      border-radius: 7px;
      background: transparent;
      color: var(--text-sec);
      font-size: 0.84rem;
      font-weight: 600;
      font-family: inherit;
      cursor: pointer;
      transition: all 0.15s ease;
      white-space: nowrap;
    }

    .dm-seg-btn:hover {
      color: var(--text-primary);
    }

    .dm-seg-btn.active {
      background: var(--surface);
      color: var(--accent);
      box-shadow: var(--shadow-sm);
    }

    /* Selectable option cards — used for Market Type */
    .dm-options {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .dm-option-card {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      padding: 11px 13px;
      border: 1.5px solid var(--border);
      border-radius: 10px;
      cursor: pointer;
      transition: all 0.15s ease;
      background: var(--surface);
    }

    .dm-option-card:hover {
      border-color: var(--accent-border);
      background: var(--surface-2);
    }

    .dm-option-card.selected {
      border-color: var(--accent);
      background: var(--accent-soft);
    }

    .dm-option-card input[type="radio"] {
      margin-top: 3px;
      accent-color: var(--accent);
      flex-shrink: 0;
      cursor: pointer;
    }

    .dm-option-main {
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .dm-option-title {
      font-size: 0.86rem;
      font-weight: 700;
      color: var(--text-primary);
    }

    .dm-option-desc {
      font-size: 0.78rem;
      color: var(--text-muted);
      line-height: 1.35;
    }

    /* Toggle switch — used for Active */
    .dm-section-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 12px 14px;
      background: var(--surface-2);
      border-radius: 10px;
      border: 1px solid var(--border);
    }

    .dm-switch {
      position: relative;
      display: inline-block;
      width: 42px;
      height: 24px;
      flex-shrink: 0;
      cursor: pointer;
    }

    .dm-switch input {
      opacity: 0;
      width: 0;
      height: 0;
    }

    .dm-switch-track {
      position: absolute;
      inset: 0;
      background: var(--border-strong);
      border-radius: 999px;
      transition: background 0.18s ease;
    }

    .dm-switch-track::before {
      content: "";
      position: absolute;
      width: 18px;
      height: 18px;
      left: 3px;
      top: 3px;
      background: #fff;
      border-radius: 50%;
      transition: transform 0.18s ease;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    }

    .dm-switch input:checked + .dm-switch-track {
      background: var(--accent);
    }

    .dm-switch input:checked + .dm-switch-track::before {
      transform: translateX(18px);
    }

    .dm-switch input:focus-visible + .dm-switch-track {
      box-shadow: 0 0 0 3px var(--amber-glow);
    }

    /* Time Frame slider — replaces the old 3-option segmented control now
       that there are 8 windows (3d through 365d). Ticks are clickable and
       jump the slider straight there; the track fills in behind the thumb
       so progress reads at a glance instead of a bare gray line. */
    .dm-tf-track-wrap {
      position: relative;
      display: flex;
      align-items: center;
      height: 20px;
      margin: 6px 0 4px;
    }

    .dm-tf-fill {
      position: absolute;
      left: 0;
      top: 8px;
      height: 4px;
      border-radius: 999px;
      background: var(--accent);
      pointer-events: none;
      transition: width 0.15s ease;
    }

    .dm-tf-slider {
      position: relative;
      width: 100%;
      margin: 0;
      -webkit-appearance: none;
      appearance: none;
      background: transparent;
      cursor: pointer;
      z-index: 1;
    }

    .dm-tf-slider::-webkit-slider-runnable-track {
      height: 4px;
      border-radius: 999px;
      background: var(--border-strong);
    }

    .dm-tf-slider::-moz-range-track {
      height: 4px;
      border-radius: 999px;
      background: var(--border-strong);
    }

    .dm-tf-slider::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 18px;
      height: 18px;
      margin-top: -7px;
      border-radius: 50%;
      background: var(--accent);
      border: 3px solid var(--surface);
      box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
      transition: transform 0.12s ease;
    }

    .dm-tf-slider:hover::-webkit-slider-thumb,
    .dm-tf-slider:active::-webkit-slider-thumb {
      transform: scale(1.12);
    }

    .dm-tf-slider::-moz-range-thumb {
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: var(--accent);
      border: 3px solid var(--surface);
      box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
    }

    .dm-tf-ticks {
      position: relative;
      height: 20px;
    }

    /* Each tick's `left` is set inline per-item using the same thumb-inset
       formula as the slider thumb (see dat-config.js), then centered under
       that point with translateX(-50%) — this is what keeps the dot exactly
       above its number at every step, including the two end labels. */
    .dm-tf-tick {
      position: absolute;
      top: 0;
      transform: translateX(-50%);
      white-space: nowrap;
      font-size: 0.68rem;
      font-weight: 600;
      color: var(--text-muted);
      cursor: pointer;
      padding: 2px 4px;
      border-radius: 5px;
      transition: color 0.12s ease, background 0.12s ease;
    }

    .dm-tf-tick:hover {
      color: var(--text-primary);
      background: var(--surface-2);
    }

    .dm-tf-tick.active {
      color: var(--accent);
      font-weight: 800;
    }

    .dm-tf-readout {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      margin-top: 10px;
      padding: 5px 12px;
      border-radius: 999px;
      background: var(--accent-soft);
      color: var(--accent);
      font-size: 0.82rem;
      font-weight: 700;
    }

    /* Escalation Type — zoom rings diagram + legend, used in place of the
       old Market Type option cards. */
    .dm-esc-wrap {
      display: flex;
      align-items: center;
      gap: 18px;
    }

    .dm-esc-legend {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 2px;
      min-width: 0;
    }

    .dm-esc-item {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 8px;
      border-radius: 7px;
      cursor: pointer;
      transition: background 0.15s ease;
    }

    .dm-esc-item:hover {
      background: var(--surface-2);
    }

    .dm-esc-item.selected {
      background: var(--accent-soft);
    }

    .dm-esc-dot {
      width: 9px;
      height: 9px;
      border-radius: 50%;
      flex-shrink: 0;
      background: var(--border-strong);
    }

    .dm-esc-item.selected .dm-esc-dot {
      background: var(--accent);
    }

    .dm-esc-item-label {
      font-size: 0.84rem;
      font-weight: 600;
      color: var(--text-sec);
    }

    .dm-esc-item.selected .dm-esc-item-label {
      color: var(--accent);
    }

    /* Card wrapper used around ZIP/prefix textarea blocks (KMA + Regions) */
    .dm-card {
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 14px;
      background: var(--surface-2);
    }

    .dm-card textarea,
    .dm-card input {
      background: var(--surface);
    }