/*
 * Price Monitor UI 2026
 * Semantic tokens are intentionally isolated here so a future brandbook can
 * replace the visual identity without rewriting layouts or page templates.
 */
:root {
    --surface-canvas: #f6f7f8;
    --surface-sidebar: #f1f2f4;
    --surface-primary: #ffffff;
    --surface-secondary: #f8f9fa;
    --surface-tertiary: #f2f4f7;
    --surface-hover: #f4f6f8;
    --surface-active: #edf2ff;
    --surface-inverse: #17191d;

    --text-primary: #17191d;
    --text-secondary: #545a64;
    --text-muted: #858b95;
    --text-inverse: #ffffff;

    --border-subtle: #eceef1;
    --border-default: #dde1e6;
    --border-strong: #c7ccd4;

    --accent: #3867e8;
    --accent-hover: #2f5edc;
    --accent-soft: #edf2ff;
    --accent-border: #cad7ff;

    --success: #16865c;
    --success-soft: #ecf8f2;
    --success-border: #bee5d2;
    --warning: #a96917;
    --warning-soft: #fff8e8;
    --warning-border: #f1d9a7;
    --danger: #c73e49;
    --danger-soft: #fff0f1;
    --danger-border: #f3c6ca;
    --info: #3267b1;
    --info-soft: #eef5ff;
    --info-border: #cbdcf5;

    --shadow-xs: 0 1px 2px rgba(18, 24, 40, .035);
    --shadow-sm: 0 5px 18px rgba(18, 24, 40, .055);
    --shadow-md: 0 14px 40px rgba(18, 24, 40, .09);
    --shadow-lg: 0 28px 80px rgba(18, 24, 40, .16);

    --radius-xs: 7px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --sidebar-width: 252px;
    --sidebar-collapsed-width: 76px;
    --workspace-bar-height: 62px;
    --content-max-width: 1660px;

    --ease-standard: cubic-bezier(.2, .75, .25, 1);
    --transition-fast: 140ms var(--ease-standard);
    --transition-base: 190ms var(--ease-standard);
}

html { background: var(--surface-canvas); }
body.app-body,
body.auth-body {
    background: var(--surface-canvas);
    color: var(--text-primary);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.app-body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }

/* App shell */
.app-shell { min-height: 100vh; }
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1000;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--surface-sidebar);
    border-right: 1px solid var(--border-subtle);
    transition: width var(--transition-base), transform var(--transition-base);
    overflow: hidden;
}
.sidebar-head {
    height: var(--workspace-bar-height);
    padding: 10px 12px 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}
.app-brand {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px;
    border-radius: var(--radius-sm);
    text-decoration: none;
}
.app-brand-mark {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    color: var(--text-inverse);
    background: var(--surface-inverse);
    border-radius: 10px;
    box-shadow: var(--shadow-xs);
}
.app-brand-mark svg,
.nav-icon svg,
.icon-btn svg,
.system-status-link svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.app-brand-mark svg { width: 20px; height: 20px; stroke-width: 2; }
.app-brand-copy { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.app-brand-copy strong { font-size: 14px; letter-spacing: -.01em; white-space: nowrap; }
.app-brand-copy small { margin-top: 3px; font-size: 10.5px; color: var(--text-muted); white-space: nowrap; }

.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), color var(--transition-fast);
}
.icon-btn:hover {
    color: var(--text-primary);
    background: var(--surface-primary);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.icon-btn:active { transform: translateY(0); box-shadow: var(--shadow-xs); }

.sidebar-nav {
    flex: 1 1 auto;
    padding: 10px 10px 18px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-default) transparent;
}
.nav-section { margin-bottom: 18px; }
.nav-section-admin { padding-top: 14px; border-top: 1px solid var(--border-subtle); }
.nav-caption {
    margin: 0 9px 7px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    transition: opacity var(--transition-fast);
}
.nav-item,
.nav-subitem {
    position: relative;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.nav-item {
    min-height: 42px;
    gap: 10px;
    margin: 2px 0;
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 13.5px;
    font-weight: 590;
}
.nav-item:hover,
.nav-subitem:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,.72);
}
.nav-item.is-active {
    color: var(--text-primary);
    background: var(--surface-primary);
    box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border-subtle);
}
.nav-icon {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    display: grid;
    place-items: center;
    color: var(--text-muted);
}
.nav-item.is-active .nav-icon { color: var(--accent); }
.nav-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-subitem {
    min-height: 30px;
    margin: 1px 0 1px 42px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 12.5px;
}
.nav-subitem.is-active { color: var(--accent); font-weight: 620; background: rgba(255,255,255,.55); }

.sidebar-foot {
    flex: 0 0 auto;
    padding: 10px;
    border-top: 1px solid var(--border-subtle);
}
.system-status-link {
    height: 34px;
    margin-bottom: 8px;
    padding: 0 9px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-muted);
    border-radius: 9px;
    text-decoration: none;
    font-size: 11.5px;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.system-status-link:hover { color: var(--text-primary); background: rgba(255,255,255,.7); }
.status-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
}
.user-chip {
    min-height: 50px;
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 9px;
    background: rgba(255,255,255,.62);
    border: 1px solid var(--border-subtle);
    border-radius: 13px;
}
.user-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--surface-inverse);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}
.user-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--text-muted); font-size: 10px; margin-top: 3px; }
.user-logout { width: 30px; height: 30px; border-radius: 8px; }
.user-logout svg { width: 16px; height: 16px; }

.app-workspace {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-base);
}
.workspace-bar {
    position: sticky;
    top: 0;
    z-index: 800;
    height: var(--workspace-bar-height);
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: color-mix(in srgb, var(--surface-canvas) 91%, transparent);
    border-bottom: 1px solid rgba(221,225,230,.72);
    backdrop-filter: blur(16px) saturate(150%);
}
.workspace-context {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 12.5px;
}
.workspace-product { color: var(--text-secondary); font-weight: 620; }
.workspace-separator { color: var(--border-strong); }
.workspace-section { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.workspace-user-short { color: var(--text-muted); font-size: 12px; }
.mobile-menu-btn { display: none; }

.app-content {
    width: min(100%, var(--content-max-width));
    margin: 0 auto;
    padding: 30px 34px 54px;
}

/* Collapsed sidebar */
.app-shell.is-sidebar-collapsed .app-sidebar { width: var(--sidebar-collapsed-width); }
.app-shell.is-sidebar-collapsed .app-workspace { margin-left: var(--sidebar-collapsed-width); }
.app-shell.is-sidebar-collapsed .app-brand-copy,
.app-shell.is-sidebar-collapsed .nav-label,
.app-shell.is-sidebar-collapsed .nav-caption,
.app-shell.is-sidebar-collapsed .nav-subitem,
.app-shell.is-sidebar-collapsed .user-meta,
.app-shell.is-sidebar-collapsed .user-chip form { display: none; }
.app-shell.is-sidebar-collapsed .sidebar-head { padding-left: 16px; flex-direction: column; height: auto; gap: 5px; }
.app-shell.is-sidebar-collapsed .app-brand { flex: 0 0 auto; }
.app-shell.is-sidebar-collapsed .sidebar-collapse-btn { transform: rotate(180deg); width: 32px; height: 32px; }
.app-shell.is-sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.app-shell.is-sidebar-collapsed .nav-icon { flex-basis: 24px; }
.app-shell.is-sidebar-collapsed .system-status-link { justify-content: center; padding-inline: 0; }
.app-shell.is-sidebar-collapsed .user-chip { justify-content: center; padding: 6px; }
.app-shell.is-sidebar-collapsed .user-avatar { margin: 0; }

/* Typography and page rhythm */
.app-content h1 {
    margin: 0 0 22px;
    color: var(--text-primary);
    font-size: clamp(26px, 2.2vw, 36px);
    line-height: 1.12;
    letter-spacing: -.035em;
    font-weight: 720;
}
.app-content h2 {
    margin: 0 0 8px;
    font-size: 19px;
    line-height: 1.25;
    letter-spacing: -.02em;
    font-weight: 690;
}
.app-content h3 {
    margin: 0 0 8px;
    font-size: 14.5px;
    line-height: 1.3;
    font-weight: 660;
}
.muted { color: var(--text-muted) !important; }
.small-note { color: var(--text-muted); font-size: 12px; line-height: 1.45; }

/* Surface primitives */
.panel,
.card,
.login-card,
.settings-subpanel,
.selected-product-card,
.manual-filter-form {
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.panel { margin-bottom: 18px; padding: 20px; }
.card { padding: 18px; }
.panel:hover { border-color: color-mix(in srgb, var(--border-default) 72%, var(--border-subtle)); }
.cards { gap: 12px; }
.card .label { color: var(--text-muted); font-size: 11.5px; font-weight: 580; }
.card .value { margin-top: 7px; color: var(--text-primary); font-size: 25px; line-height: 1.1; letter-spacing: -.03em; font-weight: 710; }

/* Buttons */
.btn {
    min-height: 38px;
    padding: 8px 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--text-primary);
    background: var(--surface-primary);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    box-shadow: var(--shadow-xs);
    font-size: 12.5px;
    font-weight: 620;
    line-height: 1.1;
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), opacity var(--transition-fast);
}
.btn:hover {
    color: var(--text-primary);
    background: #fff;
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.btn:active { transform: translateY(0); box-shadow: var(--shadow-xs); }
.btn-primary {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 3px 10px rgba(56,103,232,.18);
}
.btn-primary:hover {
    color: #fff;
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 7px 18px rgba(56,103,232,.2);
}
.btn-light { color: var(--text-secondary); background: var(--surface-secondary); border-color: var(--border-subtle); }
.btn-light:hover { color: var(--text-primary); background: var(--surface-primary); }
.btn-danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); box-shadow: none; }
.btn-danger:hover { color: #a62e38; background: #ffe9eb; border-color: #ecaeb4; box-shadow: 0 6px 18px rgba(199,62,73,.08); }
.btn-sm { min-height: 32px; padding: 6px 10px; border-radius: 9px; font-size: 11.5px; }
button:disabled, .btn:disabled, input:disabled, select:disabled, textarea:disabled { opacity: .48; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* Forms */
label { color: var(--text-secondary); font-size: 12px; font-weight: 570; }
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    min-height: 40px;
    padding: 9px 11px;
    color: var(--text-primary);
    background: var(--surface-primary);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    outline: none;
    box-shadow: 0 0 0 0 rgba(56,103,232,0);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
textarea { min-height: 94px; resize: vertical; }
input:not([type="checkbox"]):not([type="radio"]):hover,
select:hover,
textarea:hover { border-color: var(--border-strong); }
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    border-color: color-mix(in srgb, var(--accent) 62%, var(--border-default));
    box-shadow: 0 0 0 3px rgba(56,103,232,.1);
}
input::placeholder, textarea::placeholder { color: #a2a7b0; }
select {
    appearance: none;
    padding-right: 36px;
    background-image: linear-gradient(45deg, transparent 50%, #7c828c 50%), linear-gradient(135deg, #7c828c 50%, transparent 50%);
    background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.checkbox-card {
    border: 1px solid var(--border-subtle) !important;
    border-radius: 10px !important;
    background: var(--surface-secondary) !important;
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.checkbox-card:hover { background: var(--surface-primary) !important; border-color: var(--border-default) !important; box-shadow: var(--shadow-xs); }

.settings-field > label,
.settings-field label,
.filters-form > div > label { margin-top: 0; }
.settings-fields-grid { gap: 14px !important; }
.settings-form-actions,
.filter-actions,
.run-panel-actions { gap: 8px !important; }

/* Tables */
.table-scroll {
    overflow: auto;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--surface-primary);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { border-bottom: 1px solid var(--border-subtle); padding: 11px 12px; }
thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: var(--text-muted);
    background: #fafbfc;
    font-size: 10.5px;
    font-weight: 690;
    letter-spacing: .025em;
    text-transform: uppercase;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: #fafbfc; }
.clickable-table .clickable-row { transition: background var(--transition-fast), box-shadow var(--transition-fast) !important; }
.clickable-table .clickable-row:hover {
    background: #f8faff !important;
    box-shadow: inset 2px 0 0 var(--accent) !important;
    transform: none !important;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    color: var(--text-secondary);
    background: var(--surface-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 620;
    line-height: 1;
}
.badge-success, .badge-ok, .badge-confirmed_manual, .badge-matched { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.badge-running, .badge-queued { color: var(--info); background: var(--info-soft); border-color: var(--info-border); }
.badge-warning, .badge-partial, .badge-needs_review { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.badge-failed, .badge-cancelled, .badge-error, .badge-rejected { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }

/* Flash messages */
.messages { position: relative; margin: 0 0 18px; display: grid; gap: 8px; }
.alert {
    min-height: 42px;
    margin: 0;
    padding: 10px 13px;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text-secondary);
    background: var(--info-soft);
    border: 1px solid var(--info-border);
    border-radius: 11px;
    font-size: 12px;
    box-shadow: var(--shadow-xs);
}
.alert-mark { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--info); }
.alert-danger { color: #84313a; background: var(--danger-soft); border-color: var(--danger-border); }
.alert-danger .alert-mark { background: var(--danger); }
.alert-warning { color: #79511e; background: var(--warning-soft); border-color: var(--warning-border); }
.alert-warning .alert-mark { background: var(--warning); }
.alert-success { color: #176a4e; background: var(--success-soft); border-color: var(--success-border); }
.alert-success .alert-mark { background: var(--success); }

/* Modals / drawers */
body.modal-open { overflow: hidden; }
.modal-backdrop[hidden] { display: none !important; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1400;
    padding: 30px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    background: rgba(21, 25, 32, .38);
    backdrop-filter: blur(6px);
    animation: pm-fade-in 170ms var(--ease-standard);
}
.product-modal,
.pm-modal {
    position: relative;
    width: min(1040px, 100%);
    padding: 24px;
    color: var(--text-primary);
    background: var(--surface-primary);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: pm-modal-in 190ms var(--ease-standard);
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    background: var(--surface-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 11px;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.modal-close:hover { background: #fff; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.modal-section { border-top-color: var(--border-subtle) !important; }

/* Existing page normalization */
.parser-run-launch-panel,
.parser-run-history-panel,
.products-filter-panel,
.products-table-panel,
.settings-section,
.report-filters-panel { border-radius: var(--radius-lg) !important; }
.parser-run-launch-form { gap: 12px !important; }
.parser-run-card { border-color: var(--border-subtle) !important; border-radius: var(--radius-md) !important; background: var(--surface-primary) !important; }
.parser-run-card-summary { transition: background var(--transition-fast); }
.parser-run-card-summary:hover { background: var(--surface-secondary); }
.parser-run-card-body { border-top-color: var(--border-subtle) !important; }
.parser-run-live-indicator { color: var(--text-muted) !important; }
.run-log, .log-box {
    color: #dfe5ed !important;
    background: #17191d !important;
    border: 1px solid #2a2e35;
    border-radius: 12px !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
}
.run-error { color: #933944 !important; background: var(--danger-soft) !important; border: 1px solid var(--danger-border); border-radius: 11px !important; }

.settings-collapse-panel { overflow: clip; }
.settings-collapse-summary {
    padding: 2px 0;
    list-style: none;
    cursor: pointer;
}
.settings-collapse-summary::-webkit-details-marker { display: none; }
.settings-collapse-body { padding-top: 18px; border-top: 1px solid var(--border-subtle); margin-top: 14px; }
.settings-subpanel { background: var(--surface-secondary); box-shadow: none; }
.settings-summary-card { border-color: var(--border-subtle); }
.settings-store-api-note { border-radius: 11px !important; }

.pagination-bar { margin-top: 15px !important; }
.pagination-actions { gap: 7px !important; }

/* Authentication */
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background:
        radial-gradient(circle at 15% 15%, rgba(56,103,232,.08), transparent 32%),
        radial-gradient(circle at 85% 80%, rgba(22,134,92,.06), transparent 30%),
        var(--surface-canvas);
}
.login-card {
    width: min(420px, 100%);
    margin: 0 !important;
    padding: 28px !important;
    border-radius: 22px !important;
    box-shadow: var(--shadow-md) !important;
}
.login-card h1 { font-size: 28px; letter-spacing: -.035em; }
.auth-messages { width: min(420px, 100%); position: fixed; top: 24px; left: 50%; transform: translateX(-50%); }

/* Monitoring 2026 */
.pm-page-head {
    margin-bottom: 22px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}
.pm-page-head-copy { min-width: 0; }
.pm-page-head h1 { margin-bottom: 7px; }
.pm-page-head p { max-width: 720px; margin: 0; color: var(--text-muted); font-size: 13px; line-height: 1.55; }
.pm-page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pm-toolbar {
    margin-bottom: 16px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    box-shadow: var(--shadow-xs);
}
.pm-toolbar .settings-field { min-width: 180px; margin: 0; }
.pm-toolbar .settings-field label { display: none; }
.pm-toolbar select { min-height: 36px; background-color: var(--surface-secondary); border-color: transparent; }
.pm-toolbar-spacer { flex: 1; }

.pm-metrics {
    margin-bottom: 18px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}
.pm-metric {
    min-height: 86px;
    padding: 15px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}
.pm-metric-label { color: var(--text-muted); font-size: 10.5px; font-weight: 630; text-transform: uppercase; letter-spacing: .04em; }
.pm-metric-value { margin-top: 5px; font-size: 23px; font-weight: 720; letter-spacing: -.035em; }
.pm-metric-note { margin-top: 3px; color: var(--text-muted); font-size: 10.5px; }

.source-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.source-card {
    position: relative;
    min-height: 210px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    box-shadow: var(--shadow-xs);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.source-card:hover { transform: translateY(-1px); border-color: var(--border-default); box-shadow: var(--shadow-sm); }
.source-card.is-disconnected { background: #fafbfc; box-shadow: none; }
.source-card-head { display: flex; align-items: center; gap: 11px; }
.source-logo {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--surface-inverse);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 760;
    letter-spacing: -.02em;
}
.source-title { min-width: 0; flex: 1; }
.source-title strong { display: block; font-size: 14.5px; font-weight: 700; }
.source-title span { display: block; margin-top: 3px; color: var(--text-muted); font-size: 11px; }
.source-state {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 999px;
    color: var(--success);
    background: var(--success-soft);
    border: 1px solid var(--success-border);
    font-size: 10.5px;
    font-weight: 640;
}
.source-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.source-state.state-running { color: var(--info); background: var(--info-soft); border-color: var(--info-border); }
.source-state.state-warning { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.source-state.state-error { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.source-state.state-off { color: var(--text-muted); background: var(--surface-tertiary); border-color: var(--border-default); }
.source-stats { margin: 20px 0 16px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.source-stat { min-width: 0; }
.source-stat b { display: block; font-size: 15px; letter-spacing: -.02em; }
.source-stat small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 9.5px; }
.source-card-foot { margin-top: auto; padding-top: 13px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border-subtle); }
.source-card-foot .source-last-run { min-width: 0; flex: 1; color: var(--text-muted); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.source-empty {
    min-height: 150px;
    padding: 24px;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--text-muted);
    background: var(--surface-secondary);
    border: 1px dashed var(--border-default);
    border-radius: var(--radius-lg);
}

/* Onboarding wizard */
.source-wizard { width: min(760px, 100%); }
.source-wizard-head { padding-right: 50px; margin-bottom: 20px; }
.source-wizard-kicker { color: var(--accent); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.source-wizard-head h2 { margin: 5px 0 5px; font-size: 24px; letter-spacing: -.035em; }
.source-wizard-head p { margin: 0; color: var(--text-muted); font-size: 12.5px; line-height: 1.5; }
.source-wizard-step[hidden] { display: none !important; }
.retailer-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.retailer-choice {
    min-height: 90px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    color: var(--text-primary);
    background: var(--surface-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.retailer-choice:hover { transform: translateY(-1px); background: #fff; border-color: var(--border-default); box-shadow: var(--shadow-sm); }
.retailer-choice.is-selected { background: var(--accent-soft); border-color: var(--accent-border); box-shadow: 0 0 0 2px rgba(56,103,232,.06); }
.retailer-choice-mark { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; color: #fff; background: var(--surface-inverse); border-radius: 12px; font-weight: 760; }
.retailer-choice-copy strong { display: block; font-size: 13px; }
.retailer-choice-copy small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 10.5px; line-height: 1.35; }
.wizard-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.wizard-field { margin-bottom: 12px; }
.wizard-field label { display: block; margin: 0 0 6px; }
.wizard-help { margin: 8px 0 0; color: var(--text-muted); font-size: 10.5px; line-height: 1.45; }
.wizard-summary {
    margin: 14px 0;
    padding: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}
.wizard-summary-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--surface-inverse); font-size: 11px; font-weight: 760; }
.wizard-summary-copy strong { display: block; font-size: 12px; }
.wizard-summary-copy small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10.5px; }
.wizard-actions { margin-top: 18px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.wizard-status { margin-top: 12px; }
.wizard-status:empty { display: none; }
.source-connect-progress { display: grid; gap: 8px; }
.source-progress-row { padding: 9px 10px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border-subtle); border-radius: 10px; font-size: 11px; color: var(--text-secondary); }
.source-progress-row.is-done { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }

/* Generic dropdown menu */
.pm-menu { position: relative; }
.pm-menu > summary { list-style: none; cursor: pointer; }
.pm-menu > summary::-webkit-details-marker { display: none; }
.pm-menu-popover {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    min-width: 190px;
    padding: 6px;
    background: var(--surface-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}
.pm-menu-popover a,
.pm-menu-popover button {
    width: 100%;
    min-height: 34px;
    padding: 7px 9px;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 11.5px;
    text-align: left;
    cursor: pointer;
}
.pm-menu-popover a:hover,
.pm-menu-popover button:hover { color: var(--text-primary); background: var(--surface-secondary); }
.pm-menu-popover .danger { color: var(--danger); }

/* Empty / loading states */
.pm-empty-state { padding: 38px 20px; text-align: center; color: var(--text-muted); }
.pm-empty-state strong { display: block; margin-bottom: 5px; color: var(--text-primary); font-size: 14px; }
.pm-skeleton { position: relative; overflow: hidden; background: var(--surface-tertiary); border-radius: 8px; }
.pm-skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: pm-shimmer 1.3s infinite; }

/* Responsive */
.sidebar-scrim { display: none; }
@media (max-width: 1120px) {
    .app-content { padding-inline: 24px; }
    .source-grid { grid-template-columns: 1fr; }
    .pm-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
    :root { --workspace-bar-height: 56px; }
    .app-sidebar { width: min(290px, 88vw); transform: translateX(-105%); box-shadow: var(--shadow-lg); }
    .app-workspace,
    .app-shell.is-sidebar-collapsed .app-workspace { margin-left: 0; }
    .app-shell.is-mobile-sidebar-open .app-sidebar { transform: translateX(0); }
    .sidebar-scrim {
        position: fixed;
        inset: 0;
        z-index: 990;
        display: block;
        pointer-events: none;
        opacity: 0;
        background: rgba(21,25,32,.34);
        backdrop-filter: blur(3px);
        transition: opacity var(--transition-base);
    }
    .app-shell.is-mobile-sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
    .sidebar-collapse-btn { display: none; }
    .mobile-menu-btn { display: inline-grid; }
    .workspace-bar { padding: 0 16px; }
    .workspace-product, .workspace-separator, .workspace-user-short { display: none; }
    .app-content { padding: 22px 16px 40px; }
    .pm-page-head { align-items: flex-start; flex-direction: column; }
    .pm-page-head-actions { width: 100%; }
    .pm-page-head-actions .btn { flex: 1; }
    .pm-toolbar { align-items: stretch; flex-direction: column; }
    .pm-toolbar .settings-field { width: 100%; }
    .retailer-choice-grid, .wizard-form-grid { grid-template-columns: 1fr; }
    .modal-backdrop { padding: 12px; align-items: center; }
    .product-modal, .pm-modal { padding: 19px; border-radius: 20px; }
    .inline-form, .parser-run-launch-form { flex-direction: column !important; align-items: stretch !important; }
    .inline-form input, .inline-form select { width: 100% !important; min-width: 0 !important; }
}
@media (max-width: 560px) {
    .pm-metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
    .pm-metric { min-height: 74px; padding: 12px; }
    .pm-metric-value { font-size: 20px; }
    .source-stats { grid-template-columns: 1fr 1fr; }
    .source-stat:last-child { grid-column: 1 / -1; }
    .source-card-head { align-items: flex-start; flex-wrap: wrap; }
    .source-state { margin-left: 53px; }
    .workspace-section { max-width: 65vw; }
}

@keyframes pm-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pm-modal-in { from { opacity: 0; transform: translateY(8px) scale(.992); } to { opacity: 1; transform: none; } }
@keyframes pm-shimmer { 100% { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
