/* *******************************
 * Grundens Dashboard — light/dark theme
 * Palette is driven by [data-theme="light|dark"] on <html>.
 * The store persists the choice; the App shell hook applies it on load.
 * ******************************* */

:root,
[data-theme="light"] {
    --bg-primary:      #ffffff;
    --bg-secondary:    #f8f9fa;
    --bg-tertiary:     #edf0f3;
    --bg-elevated:     #ffffff;
    --text-primary:    #1f2937;
    --text-secondary:  #4b5563;
    --text-muted:      #9ca3af;
    --border-color:    #e5e7eb;
    --border-strong:   #d1d5db;
    --shadow-light:    rgba(17, 24, 39, 0.06);
    --shadow-medium:   rgba(17, 24, 39, 0.12);
    --accent-primary:  #4f46e5;
    --accent-hover:    #4338ca;
    --success:         #10b981;
    --warning:         #f59e0b;
    --error:           #ef4444;
    --info:            #3b82f6;
    --muted:           #9ca3af;
}

[data-theme="dark"] {
    --bg-primary:      #0f172a;
    --bg-secondary:    #111827;
    --bg-tertiary:     #1f2937;
    --bg-elevated:     #1e293b;
    --text-primary:    #f9fafb;
    --text-secondary:  #d1d5db;
    --text-muted:      #9ca3af;
    --border-color:    #334155;
    --border-strong:   #475569;
    --shadow-light:    rgba(0, 0, 0, 0.3);
    --shadow-medium:   rgba(0, 0, 0, 0.5);
    --accent-primary:  #818cf8;
    --accent-hover:    #a5b4fc;
    --success:         #34d399;
    --warning:         #fbbf24;
    --error:           #f87171;
    --info:            #60a5fa;
    --muted:           #64748b;
}

/* Base reset */
* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; text-decoration: none; }
button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

/* ============================================================
 * App shell
 * ============================================================ */

.gd_app_shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.gd_main_content {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

@media (max-width: 640px) {
    .gd_main_content {
        padding: 16px;
        padding-bottom: 88px; /* room for bottom nav */
    }
}

/* ============================================================
 * Navigation
 * ============================================================ */

.gd_nav {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 2px var(--shadow-light);
}

.gd_nav_brand {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.gd_nav_logo_text {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
}
.gd_nav_subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.gd_nav_tabs {
    display: flex;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.gd_nav_tab { display: flex; }
.gd_nav_tab_link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.gd_nav_tab_link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.gd_nav_tab_active .gd_nav_tab_link {
    background: var(--accent-primary);
    color: #fff;
}

.gd_nav_icon { width: 18px; height: 18px; flex-shrink: 0; }
.gd_nav_label { white-space: nowrap; }

.gd_nav_actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gd_theme_toggle {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
}
.gd_theme_toggle:hover {
    background: var(--border-color);
    color: var(--text-primary);
}
.gd_theme_toggle svg { width: 18px; height: 18px; }

/* Mobile: bottom tab bar */
@media (max-width: 640px) {
    .gd_nav {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        top: auto;
        padding: 8px;
        z-index: 100;
        border-top: 1px solid var(--border-color);
        border-bottom: none;
        justify-content: space-between;
    }
    .gd_desktop_only { display: none; }
    .gd_nav_tabs {
        justify-content: space-around;
        width: 100%;
    }
    .gd_nav_tab_link {
        flex-direction: column;
        padding: 6px 8px;
        gap: 2px;
        font-size: 10px;
    }
    .gd_nav_actions {
        position: fixed;
        top: 12px;
        right: 12px;
    }
}

/* ============================================================
 * Page layout primitives
 * ============================================================ */

.gd_tab_page {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.gd_page_header h1 {
    margin: 0 0 4px 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}
.gd_page_subtitle {
    margin: 0;
    color: var(--text-secondary);
}

.gd_section {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 2px var(--shadow-light);
}
.gd_section_title {
    margin: 0 0 16px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.gd_section_header_row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

/* ============================================================
 * Home tab
 * ============================================================ */

.gd_home_status_strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.gd_status_card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}
.gd_status_dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.gd_status_ok     { background: var(--success); }
.gd_status_warn   { background: var(--warning); }
.gd_status_error  { background: var(--error); }
.gd_status_muted  { background: var(--muted); }

.gd_status_value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}
.gd_status_label {
    font-size: 12px;
    color: var(--text-muted);
}
.gd_status_card_clickable {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.15s;
}
.gd_status_card_clickable:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}
.gd_activity_row_clickable {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.15s;
}
.gd_activity_row_clickable:hover {
    background-color: var(--bg-elevated);
}

.gd_card_grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.gd_quick_action_card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: border-color 0.15s, transform 0.15s;
}
.gd_quick_action_card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}
.gd_quick_action_icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    color: var(--accent-primary);
}
.gd_quick_action_title {
    font-weight: 600;
    color: var(--text-primary);
}
.gd_quick_action_desc {
    font-size: 12px;
    color: var(--text-muted);
}
.gd_chevron {
    width: 18px;
    height: 18px;
    margin-left: auto;
    color: var(--text-muted);
}

.gd_activity_feed { display: flex; flex-direction: column; }
.gd_activity_row {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.gd_activity_row:last-child { border-bottom: none; }
.gd_activity_dot { width: 8px; height: 8px; border-radius: 50%; }
.gd_activity_text { color: var(--text-primary); }
.gd_activity_time {
    color: var(--text-muted);
    font-size: 12px;
}

/* ============================================================
 * Forms
 * ============================================================ */

.gd_form_grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.gd_form_field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.gd_form_label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.gd_form_hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.gd_input {
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.gd_input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.gd_input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-tertiary);
}
.gd_textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Toggle switch */
.gd_toggle {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 999px;
    background: var(--border-strong);
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 0;
}
.gd_toggle_knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}
.gd_toggle_on {
    background: var(--accent-primary);
}
.gd_toggle_on .gd_toggle_knob {
    transform: translateX(20px);
}

/* Buttons */
.gd_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.15s, transform 0.1s, border-color 0.15s;
}
.gd_btn:active { transform: translateY(1px); }

.gd_btn_primary {
    background: var(--accent-primary);
    color: #fff;
}
.gd_btn_primary:hover:not(.gd_btn_disabled) {
    background: var(--accent-hover);
}
.gd_btn_secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.gd_btn_secondary:hover {
    border-color: var(--accent-primary);
}
.gd_btn_active {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}
.gd_btn_disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gd_form_actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.gd_theme_switcher {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

/* ============================================================
 * Empty state & utility cards
 * ============================================================ */

.gd_empty_state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
}
.gd_empty_state p {
    margin: 4px 0;
}

.gd_utility_card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
}
.gd_utility_card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}
.gd_utility_icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}
.gd_utility_icon svg { width: 20px; height: 20px; }
.gd_utility_text { display: flex; flex-direction: column; gap: 2px; }
.gd_utility_title { font-weight: 600; color: var(--text-primary); }
.gd_utility_desc { font-size: 12px; color: var(--text-muted); }

/* ============================================================
 * Access-restricted (outside-iframe) screen
 * ============================================================ */

.gd_locked_shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-secondary);
}
.gd_locked_card {
    max-width: 420px;
    width: 100%;
    text-align: center;
    padding: 40px 32px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 24px var(--shadow-medium);
}
.gd_locked_icon_wrap {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}
.gd_locked_svg { width: 28px; height: 28px; }
.gd_locked_title {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}
.gd_locked_body {
    margin: 0 0 8px 0;
    color: var(--text-secondary);
}
.gd_locked_sub {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
 * Not-found page
 * ============================================================ */

.gd_not_found {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gd_not_found_body { text-align: center; }
.gd_not_found_body h1 {
    font-size: 72px;
    margin: 0;
    color: var(--text-muted);
}

/* ── NAV Connection panel ────────────────────────────────────────────────── */

.gd_nav_connection .gd_section_header_row {
    align-items: center;
}

.gd_subsection_title {
    font-size: 14px;
    font-weight: 600;
    margin: 24px 0 8px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.gd_table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin-top: 8px;
}
.gd_table thead th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.gd_table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.gd_table tbody tr:hover { background: var(--surface-hover, rgba(0, 0, 0, 0.02)); }
.gd_table code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
    background: var(--surface-muted, rgba(0, 0, 0, 0.04));
    padding: 2px 6px;
    border-radius: 4px;
}
.gd_table_arrow { color: var(--text-muted); text-align: center; }
.gd_text_muted { color: var(--text-muted); margin-left: 4px; }

.gd_nav_profile_row_active {
    background: rgba(72, 95, 199, 0.04);
}
.gd_nav_profile_row_active td:first-child {
    border-left: 3px solid var(--accent, #485fc7);
    padding-left: 9px;
}

.gd_nav_col_active { width: 60px; text-align: center; }
.gd_nav_col_actions { white-space: nowrap; text-align: right; width: 220px; }
.gd_nav_col_actions .gd_btn { margin-left: 6px; }

/* Profile table: 4 columns (Active radio / Profile cell / Status / Actions).
   Connection details live stacked inside the Profile cell rather than as
   separate columns — fits a narrow Shopify admin iframe without horizontal
   scroll, and reads naturally as a row of metadata. */
.gd_nav_profile_table {
    table-layout: auto;
}
.gd_nav_profile_table tbody td {
    padding: 14px 12px;
    vertical-align: top;
}

.gd_nav_profile_cell {
    width: 100%;
}
.gd_nav_profile_name_row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    margin-bottom: 8px;
}
.gd_nav_profile_name_row strong {
    font-size: 14px;
}

/* Definition-list-style key/value rows under the profile name. dt is a fixed-
   width muted label, dd carries the value (usually a <code> chip). */
.gd_nav_profile_meta {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.gd_nav_profile_meta_row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 12.5px;
    line-height: 1.4;
}
.gd_nav_profile_meta_row dt {
    flex: 0 0 44px;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.gd_nav_profile_meta_row dd {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.gd_nav_profile_meta_row code {
    font-size: 12px;
    padding: 1px 6px;
}

.gd_nav_profile_pill {
    display: inline-block;
    margin-left: 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--success, #2e8540);
    color: white;
    padding: 2px 7px;
    border-radius: 999px;
}

/* Test/prod pills next to the profile name. Test = muted gray (the safe
   default — easy to overlook because most profiles are test). Prod = bright
   warn color so it's impossible to miss when scanning the list. */
.gd_nav_profile_pill_test {
    background: var(--surface-muted, #6b7280);
    color: white;
}
.gd_nav_profile_pill_prod {
    background: var(--danger, #c0392b);
    color: white;
}

/* Inline live-action warning inside the toggle modal when switching to a
   prod profile. Loud enough that an operator can't dismiss it without
   reading. */
.gd_modal_warn {
    background: rgba(192, 57, 43, 0.08);
    border: 1px solid var(--danger, #c0392b);
    color: var(--danger, #c0392b);
    padding: 10px 12px;
    border-radius: 6px;
    margin: 12px 0;
    line-height: 1.45;
    font-size: 13.5px;
}
.gd_modal_warn code {
    background: rgba(192, 57, 43, 0.12);
    color: inherit;
}

.gd_text_warn {
    color: var(--danger, #c0392b);
}

.gd_text_small {
    font-size: 12px;
}

/* Cutover checklist on the Home tab — scoped styling so it visually
   reads as a list of discrete steps with collapsible body content. */
.gd_cutover_checklist {
    list-style: none;
    padding: 0;
    margin: 12px 0 0 0;
    counter-reset: cutover-step;
}
.gd_cutover_item {
    counter-increment: cutover-step;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent, #6366f1);
}
.gd_cutover_item label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
}
.gd_cutover_item label::before {
    content: counter(cutover-step);
    flex: 0 0 auto;
    min-width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent, #6366f1);
    color: white;
    text-align: center;
    line-height: 24px;
    font-size: 12px;
    font-weight: 700;
}
.gd_cutover_checkbox {
    margin-top: 6px;
    cursor: pointer;
}
.gd_cutover_step_title {
    font-weight: 600;
    font-size: 14px;
}
.gd_cutover_step_body {
    margin: 6px 0 0 60px;
}
.gd_cutover_item input[type="checkbox"]:checked ~ .gd_cutover_step_title {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Phase B Back-sync page — simulate/live banner. Sits above the feed and is
   the operator's "what mode am I in" anchor. */
.gd_banner {
    border-radius: 6px;
    padding: 10px 14px;
    margin: 12px 0 18px;
    line-height: 1.45;
    font-size: 14px;
    border: 1px solid transparent;
}
.gd_banner_info {
    background: rgba(46, 133, 240, 0.08);
    border-color: rgba(46, 133, 240, 0.4);
    color: #1f4e8a;
}
.gd_banner_warn {
    background: rgba(192, 57, 43, 0.08);
    border-color: var(--danger, #c0392b);
    color: var(--danger, #c0392b);
}
.gd_banner_live {
    background: rgba(192, 57, 43, 0.10);
    border-color: var(--danger, #c0392b);
    color: var(--danger, #c0392b);
}
.gd_banner_muted {
    background: var(--surface-muted-bg, #f4f4f5);
    border-color: var(--border, #e5e7eb);
    color: var(--text-muted, #6b7280);
}

/* Per-row status pills inside the back-sync feed table. */
.gd_status_pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.gd_status_pill_ok      { background: rgba(46, 133, 64, 0.14); color: #1f6e35; }
.gd_status_pill_pending { background: rgba(154, 154, 154, 0.18); color: #4b4b4b; }
.gd_status_pill_error   { background: rgba(192, 57, 43, 0.14); color: var(--danger, #c0392b); }

/* Inline form messages */
.gd_form_success {
    color: #1f6e35;
    background: rgba(46, 133, 64, 0.08);
    border: 1px solid rgba(46, 133, 64, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 12px;
}
.gd_error_inline {
    color: var(--danger, #c0392b);
    background: rgba(192, 57, 43, 0.06);
    border: 1px solid rgba(192, 57, 43, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    margin: 8px 0;
}

/* Section header that puts a title on the left and action buttons on the
   right. Used by the back-sync feed for "Refresh + last-refreshed" affordance. */
.gd_section_header_actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Numbered "test workflow" lists with breathing room around <pre> blocks. */
.gd_list_ordered {
    padding-left: 20px;
    line-height: 1.6;
}
.gd_list_ordered li {
    margin-bottom: 8px;
}
.gd_code_block {
    background: var(--surface-muted-bg, #f4f4f5);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    font-size: 12.5px;
    margin: 6px 0 8px;
}

/* Expand affordance in the back-sync feed table.
   The first column is the toggle. Expanded row is a single-cell <tr> below. */
.gd_col_expand {
    width: 28px;
    text-align: center;
    padding: 4px 6px;
}
.gd_btn_expand {
    background: transparent;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    color: var(--text, #111827);
}
.gd_btn_expand:hover {
    background: var(--surface-muted-bg, #f4f4f5);
}
.gd_expand_row > td {
    background: var(--surface-muted-bg, #fafafa);
    padding: 12px 16px;
}
.gd_expand_grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.gd_expand_pane_title {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 600;
}
.gd_expand_pane pre.gd_code_block {
    max-height: 360px;
    overflow: auto;
}

@media (max-width: 900px) {
    .gd_expand_grid { grid-template-columns: 1fr; }
}

/* Currently-effective rollout row + pill. Subtle row-tint so the row stands
   out without screaming, plus a green pill in the From column to anchor the
   eye. Matches the simulate/live banner color language (green = "this one is
   live right now"). */
.gd_rollout_row_active {
    background: rgba(46, 133, 64, 0.06);
}
.gd_rollout_row_active td {
    border-left: none;
}
.gd_rollout_row_active td:first-child {
    border-left: 3px solid #2e8540;
}
.gd_rollout_active_pill {
    display: inline-block;
    margin-left: 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #2e8540;
    color: white;
    padding: 2px 7px;
    border-radius: 999px;
}

/* WebhookEventLog — daily-grouped event list with per-row JSON expand. */
.gd_webhook_day_group {
    margin: 14px 0;
}
.gd_webhook_day_label {
    margin: 0 0 6px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text, #111827);
    border-bottom: 1px solid var(--border, #e5e7eb);
    padding-bottom: 4px;
}
.gd_webhook_event_list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.gd_webhook_event_row {
    border-bottom: 1px solid var(--border, #f0f0f0);
    padding: 4px 0;
}
.gd_webhook_event_row:last-child {
    border-bottom: none;
}
.gd_webhook_event_summary {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: 4px;
}
.gd_webhook_event_summary:hover {
    background: var(--surface-muted-bg, #f4f4f5);
}
.gd_webhook_event_summary .gd_btn_expand {
    pointer-events: none; /* whole row click toggles; button is decorative */
}
.gd_webhook_event_body {
    margin: 4px 0 10px 32px;
}
.gd_webhook_event_body pre.gd_code_block {
    max-height: 360px;
    overflow: auto;
}

/* Pagination footer used by the WebhookEventLog. */
.gd_pagination {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border, #e5e7eb);
}

/* Live testing filter card — multi-line textareas + toggle button. */
.gd_filter_textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.5;
    min-height: 90px;
    padding: 8px 10px;
}
.gd_filter_toggle_row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.gd_nav_status_cell {
    /* Long failure messages contain unbroken hostname:port tokens (e.g.
       Azure SQL routing targets) — without a width cap + overflow-wrap
       they push the whole row past the table's right edge. Width cap
       only kicks in once the label is long; short "connected · NNN ms"
       sits on one line. */
    max-width: 280px;
    min-width: 140px;
    vertical-align: middle;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.gd_nav_profile_status_label {
    margin-left: 6px;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.35;
}
.gd_status_pulse {
    animation: gd_status_pulse 1s ease-in-out infinite;
}
@keyframes gd_status_pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ── Modal overlay ──────────────────────────────────────────────────────── */

.gd_modal_backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 18, 28, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    overflow: auto; /* allow scroll if the card is taller than the viewport */
    backdrop-filter: blur(2px);
}
.gd_modal_card {
    background: var(--surface, white);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    /* Cap the card width but never let it exceed the visible viewport
       (minus a comfortable margin). Without the min(...) clamp the
       720px ceiling caused the card to overflow inside narrower
       Shopify-admin iframes — left/right edges would clip. */
    max-width: min(460px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.gd_modal_card_wide {
    max-width: min(720px, calc(100vw - 32px));
}

@media (max-width: 600px) {
    .gd_modal_backdrop { padding: 8px; }
    .gd_modal_card { padding: 18px; }
}
.gd_modal_title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}
.gd_modal_intro {
    color: var(--text-muted);
    font-size: 13.5px;
    line-height: 1.55;
    margin: 0 0 20px;
}

.gd_form_section {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 16px 8px;
    margin-bottom: 16px;
    background: var(--surface-muted, rgba(0, 0, 0, 0.015));
}
.gd_form_section_header {
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.gd_form_section_title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 4px;
    color: var(--text);
}
.gd_form_section_desc {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
}

.gd_form_field em {
    font-style: normal;
    color: var(--text-muted);
    font-weight: 400;
}
.gd_form_field_hint {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.45;
    margin-top: 2px;
}

/* Highlight critical fields (SQL password, admin password) so screenshot
   readers know these are the load-bearing ones. */
.gd_form_field_highlight .gd_input {
    border-color: var(--accent, #485fc7);
    background: rgba(72, 95, 199, 0.04);
}
.gd_form_field_highlight .gd_input:focus {
    background: var(--surface, white);
}
.gd_modal_body {
    color: var(--text-muted);
    margin: 0 0 16px;
    line-height: 1.5;
}
.gd_modal_body code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    color: var(--text);
}
.gd_modal_actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ── Form fields (used by Create/Edit modal) ────────────────────────────── */

.gd_form_grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 8px;
}
@media (max-width: 600px) {
    .gd_form_grid { grid-template-columns: 1fr; }
}
.gd_form_field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}
.gd_form_label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.gd_input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface, white);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}
.gd_input:focus {
    outline: none;
    border-color: var(--accent, #485fc7);
    box-shadow: 0 0 0 3px rgba(72, 95, 199, 0.15);
}
.gd_form_hint {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 4px 0 0;
}
.gd_form_error {
    color: var(--error, #d62828);
    font-size: 13px;
    margin: 8px 0 0;
    padding: 8px 10px;
    background: rgba(214, 40, 40, 0.08);
    border-radius: 4px;
    border-left: 3px solid var(--error, #d62828);
}

/* ── Buttons (small/danger variants used in profile row) ────────────────── */

.gd_btn_small {
    padding: 4px 10px;
    font-size: 12px;
}
.gd_btn_danger {
    color: var(--error, #d62828);
    border-color: rgba(214, 40, 40, 0.3);
}
.gd_btn_danger:hover {
    background: rgba(214, 40, 40, 0.08);
}
.gd_btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Empty state (no NAV profiles yet) ──────────────────────────────────── */

.gd_empty_state {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}
.gd_empty_state p:first-child {
    font-weight: 600;
    margin: 0 0 6px;
    color: var(--text);
}

/* ── Middleware tab — NAV connection pill ───────────────────────────────── */

.gd_nav_pill_row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin: 0 0 18px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 13px;
}
.gd_nav_pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}
.gd_nav_pill_label {
    color: var(--text-primary);
}
.gd_nav_pill_hint {
    color: var(--text-muted);
}
.gd_nav_pill_detail {
    color: var(--text-muted);
    font-style: italic;
    flex-basis: 100%;
}
.gd_link {
    color: var(--accent-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.gd_link:hover {
    color: var(--accent-hover);
}

/* ── Section header with inline subtitle ────────────────────────────────── */

.gd_section_subtitle_inline {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Pipeline cards (clickable + muted variants) ────────────────────────── */

.gd_pipeline_grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.gd_pipeline_card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: inherit;
}
.gd_pipeline_card_active {
    cursor: pointer;
}
.gd_pipeline_card_active:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-light);
}
.gd_pipeline_card_active:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
.gd_pipeline_card_muted {
    opacity: 0.78;
    background: var(--bg-secondary);
    border-style: dashed;
}

.gd_pipeline_card_header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.gd_pipeline_card_title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}
.gd_pipeline_card_phase {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-primary);
    background: rgba(79, 70, 229, 0.08);
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}
.gd_pipeline_card_muted .gd_pipeline_card_phase {
    color: var(--text-muted);
    background: rgba(156, 163, 175, 0.12);
}
.gd_pipeline_card_desc {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
}
.gd_pipeline_card_footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.gd_pipeline_card_status {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 11px;
    font-weight: 600;
    /* Wrap long underscore-tokens (e.g. phase keys) at any character
       instead of overflowing the card. */
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
}
.gd_pipeline_card_chevron {
    font-size: 16px;
    color: var(--accent-primary);
    transition: transform 0.15s;
}
.gd_pipeline_card_active:hover .gd_pipeline_card_chevron {
    transform: translateX(3px);
}

/* ── Pipeline detail pages ──────────────────────────────────────────────── */

.gd_pipeline_detail .gd_page_header {
    position: relative;
}
.gd_breadcrumb {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--accent-primary);
    text-decoration: none;
}
.gd_breadcrumb:hover {
    text-decoration: underline;
}

.gd_pipeline_summary_grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 18px;
}
.gd_pipeline_summary_block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.gd_pipeline_summary_label {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.gd_pipeline_summary_value {
    margin: 0;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}
.gd_pipeline_summary_list {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}
.gd_pipeline_summary_list li + li {
    margin-top: 3px;
}

.gd_detail_card_summary {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.gd_detail_card_bullets {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}
.gd_detail_card_bullets li + li {
    margin-top: 4px;
}

.gd_doc_pointer {
    background: rgba(79, 70, 229, 0.04);
    border-color: rgba(79, 70, 229, 0.25);
}
.gd_doc_pointer_title {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-primary);
}
.gd_doc_pointer_section {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}
.gd_doc_pointer_tldr {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ── Mobile — Shopify embed iframe gets narrow on phones ────────────────── */

@media (max-width: 768px) {
    .gd_pipeline_summary_grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .gd_section {
        padding: 16px;
    }
    .gd_page_header h1 {
        font-size: 20px;
    }
    .gd_section_header_row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .gd_nav_pill_row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    .gd_pipeline_grid {
        grid-template-columns: 1fr;
    }
    .gd_pipeline_card {
        padding: 14px 16px;
    }
    .gd_pipeline_card_header {
        flex-direction: column;
        gap: 6px;
    }
    .gd_form_grid {
        grid-template-columns: 1fr;
    }
}

/* ── SQL Console ─────────────────────────────────────────────────────────── */

.gd_sql_console {
    /* Wider working area than the default tab page */
    padding-bottom: 60px;
}

/* Production warning: red border on the page edge so it's impossible to miss
   when the operator is about to run a query against live data. */
.gd_sql_console_prod {
    border-left: 4px solid var(--error);
    border-right: 4px solid var(--error);
}
.gd_sql_console_prod_banner {
    margin: 0 0 14px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid var(--error);
    border-radius: 8px;
    color: var(--error);
    font-size: 13px;
    line-height: 1.5;
}
.gd_sql_profile_row {
    margin-top: 0;
}

.gd_sql_layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.gd_sql_sidebar {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    max-height: 580px;
    overflow-y: auto;
}
.gd_sql_sidebar_tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.gd_sql_sidebar_tab {
    flex: 1;
    padding: 8px 10px;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.gd_sql_sidebar_tab:hover {
    color: var(--text-primary);
}
.gd_sql_sidebar_tab_active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.gd_sql_saved_list,
.gd_sql_schema {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.gd_sql_saved_group_title {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.gd_sql_saved_items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.gd_sql_saved_item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.gd_sql_saved_item:hover {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}
.gd_sql_saved_item_name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
.gd_sql_saved_item_desc {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.35;
}
.gd_sql_columns_list .gd_sql_saved_item_name {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

/* Editor pane */

.gd_sql_editor_pane {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
}
.gd_sql_editor {
    width: 100%;
    min-height: 180px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary);
    resize: vertical;
}
.gd_sql_editor:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: -1px;
    border-color: var(--accent-primary);
}

.gd_sql_run_grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}
.gd_sql_run_actions {
    display: flex;
    gap: 8px;
}
.gd_sql_error {
    margin: 0;
    padding: 10px 12px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid var(--error);
    border-radius: 6px;
    font-size: 13px;
    color: var(--error);
    white-space: pre-wrap;
}

/* Result pane */

.gd_sql_result_pane .gd_section_subtitle_inline {
    font-style: normal;
    font-weight: 600;
}
.gd_sql_result_scroll {
    overflow-x: auto;
    max-height: 480px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.gd_sql_result_table thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-elevated);
}
.gd_sql_result_table thead th {
    padding: 8px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}
.gd_sql_result_table tbody td {
    padding: 6px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Recent queries strip */

.gd_sql_audit_list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.gd_sql_audit_btn {
    display: grid;
    grid-template-columns: 140px 160px 220px 1fr auto;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    font-size: 12px;
    align-items: center;
}
.gd_sql_audit_btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.gd_sql_audit_actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.gd_sql_audit_action {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gd_sql_audit_action:hover {
    background: var(--bg-elevated);
    border-color: var(--border-color);
}
.gd_sql_audit_rerun:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}
.gd_sql_audit_delete:hover {
    color: var(--error);
    border-color: var(--error);
}

/* Protected (system-written) audit rows: visually distinct, no destructive
   affordances. Hovering the lock shows a tooltip explaining why. */
.gd_sql_audit_row_protected {
    background: rgba(79, 70, 229, 0.04);
}
.gd_sql_audit_protected_tag {
    margin-left: 8px;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-primary);
    background: rgba(79, 70, 229, 0.12);
    border-radius: 999px;
    vertical-align: middle;
}
.gd_sql_audit_protected_lock {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
    cursor: help;
}
.gd_sql_audit_when {
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.gd_sql_audit_who {
    color: var(--text-secondary);
}
.gd_sql_audit_summary {
    font-weight: 600;
    color: var(--text-primary);
}
.gd_sql_audit_query {
    color: var(--text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gd_sql_audit_row_error .gd_sql_audit_summary {
    color: var(--error);
}

/* Mobile */

@media (max-width: 900px) {
    .gd_sql_layout {
        grid-template-columns: 1fr;
    }
    .gd_sql_sidebar {
        max-height: 280px;
    }
    .gd_sql_run_grid {
        grid-template-columns: 1fr;
    }
    .gd_sql_run_actions {
        justify-content: flex-end;
    }
    .gd_sql_audit_btn {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

@media (max-width: 480px) {
    .gd_sql_console_prod {
        border-left-width: 2px;
        border-right-width: 2px;
    }
    .gd_sql_editor {
        font-size: 12px;
    }
}

/* ── Warehouse split rollout — simulator + result ──────────────────────── */

.gd_warehouse_simulator .gd_subsection_title {
    margin: 18px 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.gd_input_compact {
    padding: 4px 8px;
    font-size: 12px;
}

.gd_warehouse_lines_table {
    table-layout: fixed;
    width: 100%;
}
.gd_warehouse_lines_table th,
.gd_warehouse_lines_table td {
    padding: 6px 10px;
    font-size: 12px;
    vertical-align: middle;
}
/* Column proportions for the 6-col Lines table (Phase 2b):
   Line ID, SKU, Title (flex), Qty (compact), Eligible dropdown, Action. */
.gd_warehouse_lines_table th:nth-child(1),
.gd_warehouse_lines_table td:nth-child(1) { width: 160px; }
.gd_warehouse_lines_table th:nth-child(2),
.gd_warehouse_lines_table td:nth-child(2) { width: 170px; }
.gd_warehouse_lines_table th:nth-child(3),
.gd_warehouse_lines_table td:nth-child(3) { width: auto; }
.gd_warehouse_lines_table th:nth-child(4),
.gd_warehouse_lines_table td:nth-child(4) { width: 70px; }
.gd_warehouse_lines_table th:nth-child(5),
.gd_warehouse_lines_table td:nth-child(5) { width: 190px; }
.gd_warehouse_lines_table th:nth-child(6),
.gd_warehouse_lines_table td:nth-child(6) { width: 100px; text-align: right; }

.gd_warehouse_lines_table input,
.gd_warehouse_lines_table select {
    width: 100%;
}

.gd_pct_value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-primary);
}

.gd_warehouse_sim_result {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}
.gd_warehouse_sim_summary {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.gd_warehouse_pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.gd_warehouse_pill_old {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}
.gd_warehouse_pill_new {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.gd_warehouse_row_old td,
.gd_warehouse_row_new td {
    background: transparent;
}
.gd_warehouse_row_new {
    background: rgba(16, 185, 129, 0.04);
}
.gd_warehouse_row_old {
    background: rgba(245, 158, 11, 0.03);
}

@media (max-width: 768px) {
    .gd_warehouse_lines_table {
        font-size: 11px;
    }
    .gd_warehouse_lines_table input,
    .gd_warehouse_lines_table select {
        max-width: 100%;
    }
}

/* ── Warehouse split simulator — help panel + layout polish ───────────── */

.gd_simulator_help {
    margin: 0 0 16px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
}
.gd_simulator_help summary {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.gd_simulator_help summary::before {
    content: "▸";
    color: var(--accent-primary);
    transition: transform 0.15s;
    display: inline-block;
}
.gd_simulator_help[open] summary::before {
    transform: rotate(90deg);
}
.gd_simulator_help_body {
    padding: 4px 18px 16px 30px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.55;
}
.gd_simulator_help_body h4 {
    margin: 14px 0 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.gd_simulator_help_body h4:first-child {
    margin-top: 4px;
}
.gd_simulator_help_body p,
.gd_simulator_help_body ul,
.gd_simulator_help_body ol {
    margin: 0 0 6px;
}
.gd_simulator_help_body ul,
.gd_simulator_help_body ol {
    padding-left: 20px;
}
.gd_simulator_help_body li + li {
    margin-top: 4px;
}
.gd_simulator_help_body code {
    background: var(--bg-elevated);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

/* Two stacked field blocks — "Order context" (Order ID + % NEW) and
   "Allocation targets" (OLD/NEW location). Each gets a soft background
   so the eye reads them as related-but-distinct. Inside each block,
   the two fields share equal width. */
.gd_simulator_field_block {
    margin-bottom: 14px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}
.gd_simulator_block_label {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.gd_simulator_field_row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: end;
}
.gd_simulator_field_row .gd_form_field {
    margin: 0;
    min-width: 0;
}
.gd_simulator_field_row .gd_form_field .gd_input {
    width: 100%;
}
.gd_input_pct {
    text-align: center;
    font-weight: 600;
}

/* Older single-row class kept for backwards compat in case any markup
   still references it; harmless if unused. */
.gd_simulator_row {
    display: grid;
    grid-template-columns: 130px 90px 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
    align-items: end;
}

/* Action bar: + Add line on the left, Run simulation on the right. */
.gd_simulator_actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.gd_form_label_help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    cursor: help;
    vertical-align: middle;
}

.gd_simulator_locations_warn {
    margin: -8px 0 14px;
    color: var(--warning);
    font-size: 12.5px;
}

@media (max-width: 900px) {
    .gd_simulator_row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 560px) {
    .gd_simulator_row,
    .gd_simulator_field_row {
        grid-template-columns: 1fr;
    }
    .gd_simulator_actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
}

/* ── Warehouse simulator: fetch from Shopify panel ───────────────────── */

.gd_shopify_fetch {
    margin: 0 0 16px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 10px;
}
.gd_shopify_fetch_label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.gd_shopify_fetch_row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.gd_shopify_fetch_input {
    flex: 1;
    min-width: 0;
}
.gd_shopify_fetch_hint {
    margin: 6px 0 0;
}
.gd_shopify_fetch_error {
    margin: 8px 0 0;
}

/* Order context strip — appears once a Shopify order is fetched. */
.gd_order_context {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.gd_order_context_grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px 16px;
}
.gd_order_context_block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.gd_order_context_label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.gd_order_context_value {
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* "Find this order in NAV" SQL block under simulation result. */
.gd_nav_lookup {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}
.gd_nav_lookup_sql {
    margin: 8px 0 0;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.55;
    color: var(--text-primary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.gd_nav_lookup_sql code {
    background: transparent;
    padding: 0;
}

/* Custom select chevron — replaces the OS-default with one that matches
   the rest of the dashboard. Applied to all .gd_input that's a <select>. */
select.gd_input {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 6px;
    padding-right: 28px;
}
[data-theme="dark"] select.gd_input {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23d1d5db' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
select.gd_input:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: -1px;
    border-color: var(--accent-primary);
}

@media (max-width: 560px) {
    .gd_shopify_fetch_row {
        flex-direction: column;
    }
}

/* ── Live flow steps (warehouse simulator) ─────────────────────────────── */

.gd_flow_steps {
    margin: 0 0 16px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
}
.gd_flow_steps summary {
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.gd_flow_steps summary::before {
    content: "▸";
    color: var(--accent-primary);
    transition: transform 0.15s;
}
.gd_flow_steps[open] summary::before {
    transform: rotate(90deg);
}
.gd_flow_steps_list {
    list-style: none;
    margin: 0;
    padding: 4px 0 12px;
    border-top: 1px solid var(--border-color);
    counter-reset: none;
}
.gd_flow_steps_list li {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
}
.gd_flow_steps_list li + li {
    border-top: 1px dashed var(--border-color);
}
.gd_flow_steps_num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gd_flow_steps_body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.gd_flow_steps_title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.gd_flow_steps_desc {
    font-size: 12px;
    color: var(--text-muted);
}
.gd_flow_steps_tag {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
}
.gd_flow_steps_tag_active {
    background: rgba(79, 70, 229, 0.12);
    color: var(--accent-primary);
}
.gd_flow_steps_tag_external {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}
.gd_flow_steps_tag_gated {
    background: rgba(99, 102, 241, 0.10);
    color: var(--accent-primary);
    border: 1px dashed var(--accent-primary);
}

/* ── Inventory check panel (warehouse simulator) ───────────────────────── */

.gd_inventory_panel {
    margin: 16px 0;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}
.gd_inventory_panel .gd_section_header_row {
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}
.gd_inventory_table th,
.gd_inventory_table td {
    padding: 6px 10px;
    font-size: 12px;
    vertical-align: middle;
}
.gd_inventory_pill {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 4px 2px 0;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-muted);
}
.gd_inventory_pill code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-weight: 700;
}
.gd_inventory_pill_ok {
    background: rgba(16, 185, 129, 0.14);
    color: var(--success);
}
.gd_inventory_pill_zero {
    background: rgba(156, 163, 175, 0.14);
    color: var(--text-muted);
}
.gd_inventory_pill_info {
    background: rgba(59, 130, 246, 0.14);
    color: var(--info, #3b82f6);
}
.gd_inventory_pill_old {
    background: rgba(245, 158, 11, 0.14);
    color: var(--warning);
}
.gd_inventory_pill_new {
    background: rgba(99, 102, 241, 0.14);
    color: var(--accent-primary);
}
.gd_inventory_pill_none {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error);
}

/* Inventory pills that match the operator's OLD/NEW selection get a
   thin coloured outline + a small role tag so the comparison pair is
   visually obvious among any other locations NAV has stock at. */
.gd_inventory_pill_role_old {
    outline: 2px solid var(--warning);
    outline-offset: -1px;
}
.gd_inventory_pill_role_new {
    outline: 2px solid var(--accent-primary);
    outline-offset: -1px;
}
.gd_inventory_pill_role_tag {
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.08);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: inherit;
}

/* Tiny badge next to the simulator's % to NEW label, indicating whether
   the typed value matches the currently-active scheduled rollout. Helps
   the operator distinguish "simulating today's live behaviour" from
   "testing a hypothetical pct override". */
.gd_pct_badge {
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    vertical-align: middle;
    cursor: help;
}
.gd_pct_badge_match {
    background: rgba(16, 185, 129, 0.14);
    color: var(--success);
}
.gd_pct_badge_override {
    background: rgba(245, 158, 11, 0.14);
    color: var(--warning);
}
.gd_pct_badge_none {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* ── Warehouse simulator: NAV order-presence panel ─────────────────────── */

.gd_order_presence_section {
    margin-top: 0;
    margin-bottom: 14px;
    padding: 14px 16px;
}
.gd_order_presence_section .gd_section_header_row {
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}
.gd_order_presence_found,
.gd_order_presence_not_found {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.gd_order_presence_list {
    margin: 4px 0 0;
    padding-left: 18px;
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.gd_inline_error {
    background: transparent;
    border: 0;
    padding: 0;
}

/* ── Warehouse Split: Bulk force-replay card ───────────────────────────── */

.gd_bulk_replay .gd_text_muted {
    margin: 0 0 6px;
}

.gd_bulk_replay_form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 12px 0 0;
}
.gd_bulk_replay_form .gd_form_field {
    min-width: 220px;
}

.gd_bulk_replay_actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 14px 0 0;
}

.gd_bulk_replay_pager {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 6px;
    padding: 6px 10px;
    background: var(--surface-subtle, rgba(0, 0, 0, 0.025));
    border-radius: 6px;
}

.gd_bulk_replay .gd_form_error {
    margin: 10px 0 0;
}

.gd_bulk_replay .gd_table {
    margin-top: 0;
}

/* ── Warehouse Split: Happy Exchange card ──────────────────────────────── */

.gd_happy_exchange .gd_text_muted {
    margin: 0 0 6px;
}

.gd_he_grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px 18px;
    margin-top: 12px;
}

.gd_he_audit_row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 18px;
    margin-top: 14px;
}
.gd_he_audit_row .gd_form_field {
    flex: 1 1 220px;
    min-width: 0;
}

.gd_he_toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary, #4b4b4b);
}
.gd_he_toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.gd_happy_exchange .gd_table {
    margin-top: 8px;
}
