:root {
    --md-font-family: 'Roboto', sans-serif;
    --md-on-surface: #1f1f1f;
    --md-surface: #f5f7fb;
    --md-surface-variant: #ffffff;
    --md-primary: #2962ff;
    --md-primary-dark: #0039cb;
    --md-secondary: #00bfa5;
    --md-outline: #d5d7df;
    --md-outline-variant: #c3c6d1;
    --md-elevation-1: 0 2px 8px rgba(14, 30, 37, 0.12);
    --md-elevation-2: 0 10px 30px rgba(27, 39, 49, 0.18);
    --md-error: #d32f2f;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--md-font-family);
    color: var(--md-on-surface);
    background: var(--md-surface);
    margin: 0;
}

.md-surface {
    background: radial-gradient(circle at top, #f0f4ff, #edf1ff 45%, #e4ecff 65%, #e0e7ff);
    min-height: 100vh;
}

.app-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 20px 32px;
    background: linear-gradient(120deg, #1e3c72, #2a5298);
    color: #fff;
}

.app-bar__content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.app-bar__title {
    display: flex;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 500;
    gap: 12px;
    letter-spacing: 0.3px;
}

.app-bar__title .material-icons {
    font-size: 32px;
}

.app-bar__subtitle {
    opacity: 0.86;
    font-size: 0.95rem;
    font-weight: 300;
}

.app-bar__actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.28);
    font-weight: 500;
}

.user-chip .material-icons {
    font-size: 20px;
}

.content {
    padding: 32px clamp(16px, 5vw, 48px);
    display: grid;
    gap: 28px;
}

.layout-grid {
    display: grid;
    gap: 28px;
}

.layout-grid--split {
    display: grid;
    gap: 28px;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.tab-bar {
    display: flex;
    gap: 12px;
    align-items: center;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--md-outline);
    background: #f5f7ff;
    color: var(--md-on-surface);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.tab-btn .material-icons {
    font-size: 20px;
}

.tab-btn:hover {
    border-color: var(--md-primary);
    box-shadow: 0 8px 18px rgba(41, 98, 255, 0.18);
}

.tab-btn.active {
    background: var(--md-primary);
    color: #fff;
    border-color: var(--md-primary);
}

.tab-view {
    display: none;
}

.tab-view.active {
    display: grid;
    gap: 28px;
}

.card {
    background: var(--md-surface-variant);
    border-radius: 18px;
    padding: clamp(20px, 4vw, 32px);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card.elevation-2 {
    box-shadow: var(--md-elevation-2);
}

.card.elevation-1 {
    box-shadow: var(--md-elevation-1);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 35px rgba(27, 39, 49, 0.18);
}

.card__header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.card__header--dense {
    margin-bottom: 12px;
}

.card__header--with-actions {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.card__header h1,
.card__header h2,
.card__header h3 {
    margin: 0;
    font-weight: 500;
    color: var(--md-on-surface);
}

.card__supporting-text {
    margin: 0;
    color: rgba(31, 31, 31, 0.7);
    font-size: 0.95rem;
}

.form-grid {
    display: grid;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.md-checkbox-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    cursor: pointer;
}

.md-checkbox-chip input {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.md-checkbox-chip span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--md-outline);
    background: #f5f7ff;
    font-size: 0.9rem;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.md-checkbox-chip:hover span {
    border-color: var(--md-primary);
    box-shadow: 0 4px 12px rgba(41, 98, 255, 0.15);
}

.md-checkbox-chip input:checked + span {
    background: var(--md-primary);
    border-color: var(--md-primary);
    color: #fff;
    box-shadow: 0 6px 18px rgba(41, 98, 255, 0.25);
}

.md-label {
    font-size: 0.9rem;
    letter-spacing: 0.4px;
    font-weight: 500;
    color: rgba(31, 31, 31, 0.78);
}

.md-field {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f7f8fc;
    border: 1px solid var(--md-outline);
    border-radius: 12px;
    padding: 12px 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.md-field:focus-within {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.12);
}

.md-field__icon {
    color: rgba(31, 31, 31, 0.6);
}

.md-field--range {
    gap: 8px;
    padding-right: 12px;
}

.md-field__separator {
    color: rgba(31, 31, 31, 0.4);
    font-weight: 600;
}

.md-input--inline {
    width: 100px;
}

.md-input,
.md-select {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    font-family: var(--md-font-family);
    font-size: 0.95rem;
    color: var(--md-on-surface);
}

.md-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
}

.select2-container--default .select2-selection--single {
    height: 42px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 6px 8px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 42px;
    top: 0;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
}

.pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    min-height: 36px;
}

.pill-btn {
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    color: #111827;
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pill-btn:hover {
    background: #e6f2ff;
    border-color: #3b82f6;
    color: #0f172a;
}

.pill-btn--ghost {
    background: #fff;
    cursor: default;
}

.status-inline {
    margin-top: 8px;
    font-size: 0.9rem;
}

.log-wrapper {
    margin-top: 12px;
}

.log-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.log-viewer {
    background: #0b132b;
    color: #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    min-height: 160px;
    max-height: 360px;
    overflow: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85rem;
}

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

.xs-btn {
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    color: #0f172a;
}

.xs-btn:hover {
    border-color: #3b82f6;
    color: #0f172a;
    background: #e6f2ff;
}

.md-select--dense {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--md-outline-variant);
    background: #fff;
}

.brand-chip-set,
.supplier-chip-set {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#brand-container input[type="checkbox"],
#supplier-container input[type="checkbox"] {
    display: none;
}

#brand-container div,
#supplier-container div {
    width: auto;
}

#brand-container input[type="checkbox"] + label,
#supplier-container input[type="checkbox"] + label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.85rem;
    background: #f3f5fb;
    border: 1px solid transparent;
    color: rgba(31, 31, 31, 0.78);
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border 0.2s ease, transform 0.2s ease;
}

#brand-container input[type="checkbox"] + label:hover,
#supplier-container input[type="checkbox"] + label:hover {
    transform: translateY(-1px);
    border-color: rgba(41, 98, 255, 0.35);
}

#brand-container input[type="checkbox"]:checked + label,
#supplier-container input[type="checkbox"]:checked + label {
    background: rgba(41, 98, 255, 0.12);
    color: var(--md-primary-dark);
    border-color: rgba(41, 98, 255, 0.45);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: flex-start;
}

.md-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--md-font-family);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
    letter-spacing: 0.3px;
    color: var(--md-on-surface);
    background: rgba(31, 31, 31, 0.08);
}

.md-btn__icon {
    font-size: 20px !important;
}

.md-btn--primary {
    background: var(--md-primary);
    color: #fff;
    box-shadow: 0 8px 16px rgba(41, 98, 255, 0.24);
}

.md-btn--primary:hover {
    background: var(--md-primary-dark);
    box-shadow: 0 10px 24px rgba(41, 98, 255, 0.32);
}

.md-btn--secondary {
    background: var(--md-secondary);
    color: #fff;
    box-shadow: 0 6px 14px rgba(0, 191, 165, 0.28);
}

.md-btn--secondary:hover {
    background: #009e8b;
}

.md-btn--outlined {
    background: transparent;
    border: 1.5px solid rgba(41, 98, 255, 0.5);
    color: var(--md-primary-dark);
}

.md-btn--outlined:hover {
    background: rgba(41, 98, 255, 0.08);
}

.md-btn--text {
    background: transparent;
    color: var(--md-primary-dark);
    padding: 8px 12px;
}

.md-btn:active {
    transform: translateY(1px);
}

.ripple::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
}

.ripple:focus-visible::after,
.ripple:active::after {
    width: 200%;
    height: 200%;
    opacity: 0.18;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 14px;
    background: #fff;
}

.md-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.md-table thead {
    background: linear-gradient(120deg, rgba(41, 98, 255, 0.08), rgba(41, 98, 255, 0.18));
}

.md-table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: rgba(0, 0, 0, 0.68);
    text-transform: uppercase;
}

.md-table td {
    padding: 14px 16px;
    border-top: 1px solid rgba(214, 218, 230, 0.8);
    font-size: 0.93rem;
    color: rgba(31, 31, 31, 0.82);
}

.md-table tbody tr:hover {
    background: rgba(41, 98, 255, 0.06);
}

.md-table tbody tr td:last-child,
.md-table tbody tr td.actions-cell {
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    padding: 24px;
    font-size: 0.95rem;
    color: rgba(31, 31, 31, 0.6);
}

.checkbox-cell {
    width: 48px;
    text-align: center;
}

.md-checkbox {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.md-checkbox input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.md-checkbox span {
    width: 18px;
    height: 18px;
    border: 2px solid var(--md-outline-variant);
    border-radius: 6px;
    display: inline-block;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.md-checkbox input:checked + span {
    background: var(--md-primary);
    border-color: var(--md-primary);
    position: relative;
}

.md-checkbox input:checked + span::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

.md-checkbox--header span {
    border-radius: 4px;
}

.panel-batch-actions {
    margin-top: 20px;
    padding: 18px 20px;
    border-radius: 16px;
    background: #f5f7ff;
    border: 1px solid rgba(41, 98, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.panel-batch-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: rgba(31, 31, 31, 0.8);
}

.panel-batch-info .material-icons {
    color: var(--md-primary);
}

.panel-batch-buttons {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    align-items: stretch;
}

.panel-batch-buttons .md-btn {
    width: 100%;
    justify-content: center;
    min-width: 0;
    white-space: nowrap;
}

.md-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.md-list li {
    padding: 12px 16px;
    background: #f5f7ff;
    border-radius: 12px;
    border: 1px solid rgba(41, 98, 255, 0.1);
    font-size: 0.92rem;
    color: rgba(31, 31, 31, 0.75);
}

.status {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #1f2970;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.status--success {
    background: #e0f7ef;
    color: #006b3a;
}

.status--failed,
.status--error {
    background: #fdecea;
    color: #c62828;
}

.status--running {
    background: #fff4e5;
    color: #b26a00;
}

.status--canary_failed {
    background: #fff0f0;
    color: #b3261e;
}

.auth-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, rgba(41, 98, 255, 0.12), transparent 30%), radial-gradient(circle at 90% 10%, rgba(0, 191, 165, 0.18), transparent 30%), linear-gradient(135deg, #eef2ff, #e6ecff 55%, #f2f5ff);
    padding: clamp(16px, 4vw, 32px);
    z-index: 400;
}

.auth-card {
    width: min(440px, 92vw);
    background: #fff;
    border-radius: 18px;
    padding: clamp(22px, 4vw, 28px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--md-elevation-2);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-brand .material-icons {
    font-size: 32px;
    color: var(--md-primary);
}

.auth-brand h1 {
    margin: 2px 0 0 0;
}

.auth-kicker {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 0.82rem;
    color: rgba(31, 31, 31, 0.7);
}

.auth-lede {
    margin: 0 0 4px 0;
    color: rgba(31, 31, 31, 0.7);
    line-height: 1.5;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-submit {
    width: 100%;
    justify-content: center;
}

.auth-error {
    background: #fdecea;
    color: #b3261e;
    border: 1px solid #f7c5c0;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.9rem;
}

.auth-hint {
    margin: 2px 0 0 0;
    color: rgba(31, 31, 31, 0.6);
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

.mapping-list {
    margin-top: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.mapping-header,
.mapping-row {
    display: grid;
    grid-template-columns: 1.2fr 2.2fr 1fr 0.8fr;
    gap: 12px;
    align-items: center;
    padding: 12px 16px;
}

.mapping-header {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
}

.mapping-row:nth-child(even) {
    background: #fafafa;
}

.mapping-shop {
    font-weight: 600;
    color: #111827;
}

.mapping-actions {
    text-align: right;
}

.enrichment-card {
    position: fixed;
    right: 32px;
    bottom: 32px;
    width: min(420px, 92vw);
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    background: var(--md-surface-variant);
    border-radius: 18px;
    padding: 24px;
    box-shadow: var(--md-elevation-2);
    z-index: 200;
}

.enrichment-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.enrichment-header h2 {
    margin: 0;
}

.enrichment-header p {
    margin: 4px 0 0;
    color: rgba(31, 31, 31, 0.65);
    font-size: 0.9rem;
}

.enrichment-content {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-top: 18px;
}

.enrichment-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-top: 8px;
}

.enrichment-column h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    font-weight: 600;
    color: rgba(31, 31, 31, 0.85);
}

.spec-list {
    margin: 0;
    display: grid;
    gap: 10px;
}

.spec-list dt {
    font-weight: 600;
    color: rgba(31, 31, 31, 0.82);
}

.spec-list dd {
    margin: 0;
    color: rgba(31, 31, 31, 0.68);
    font-size: 0.9rem;
}

.spec-meta {
    font-size: 0.75rem;
    color: rgba(31, 31, 31, 0.5);
    margin-top: 2px;
}

.seo-list {
    display: grid;
    gap: 12px;
}

.seo-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(41, 98, 255, 0.1);
    border-radius: 10px;
    background: #f7f9ff;
}

.seo-row span:first-child {
    font-weight: 600;
    color: rgba(31, 31, 31, 0.82);
}

.seo-row span:last-child {
    flex: 1;
    text-align: right;
    color: rgba(31, 31, 31, 0.7);
    font-size: 0.9rem;
}

.seo-issues {
    margin: 0;
    padding-left: 18px;
    color: rgba(197, 79, 79, 0.85);
    font-size: 0.9rem;
}

.muted-text {
    color: rgba(31, 31, 31, 0.55);
    font-size: 0.85rem;
}


.job-details-preview {
    margin-top: 6px;
    font-size: 0.8rem;
    color: rgba(31, 31, 31, 0.6);
}

.md-btn--disabled {
    opacity: 0.5;
    pointer-events: none;
}

.panel-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.inset-card {
    border-radius: 16px;
    border: 1px solid rgba(231, 233, 244, 0.9);
    background: #fafbff;
    padding: 18px;
    margin-top: 24px;
}

.log-viewer {
    margin: 0;
    background: #0f172a;
    color: #e2e8f0;
    font-family: "Roboto Mono", Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    max-height: 380px;
    overflow-y: auto;
    border-radius: 12px;
    padding: 16px;
}

.log-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.settings-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-bottom: 12px;
}

.settings-status {
    margin-top: 12px;
    color: rgba(31, 31, 31, 0.7);
    font-size: 0.92rem;
}

.download-btn {
    background: var(--md-secondary);
    color: #fff;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    border: none;
    cursor: pointer;
    transition: box-shadow 0.2s ease;
}

.download-btn:hover {
    box-shadow: 0 6px 14px rgba(0, 191, 165, 0.25);
}

@media (max-width: 960px) {
    .app-bar {
        padding: 18px;
    }

    .content {
        padding: 24px 16px;
    }

    .card {
        padding: 20px;
    }

    .card__header--with-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .panel-batch-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-batch-buttons {
        width: 100%;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .panel-batch-buttons .md-btn {
        width: 100%;
    }

    .form-actions {
        width: 100%;
    }

    .form-actions .md-btn {
        flex: 1;
        justify-content: center;
    }

    .enrichment-card {
        left: 16px;
        right: 16px;
        bottom: 16px;
        width: auto;
        max-height: calc(100vh - 32px);
    }
}

@media (max-width: 640px) {
    .app-bar__title {
        font-size: 1.3rem;
    }

    .app-bar__subtitle {
        font-size: 0.85rem;
    }

    .table-wrapper {
        border-radius: 10px;
    }

    .md-table {
        min-width: 640px;
    }

    .log-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .log-controls .md-btn {
        justify-content: center;
    }
}
