/* Autofill 1.6.2 - storefront, reports and settings. */

.autofill-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.autofill-loading {
    position: absolute;
    z-index: 10002;
    width: 18px;
    height: 18px;
    pointer-events: none;
    border: 2px solid rgba(71, 85, 105, .22);
    border-top-color: #4f7f43;
    border-radius: 50%;
    box-sizing: border-box;
    animation: autofill-spin .7s linear infinite;
}

@keyframes autofill-spin {
    to { transform: rotate(360deg); }
}

.autofill-result {
    --autofill-surface: #fff;
    --autofill-text: #172033;
    --autofill-muted: #667085;
    --autofill-border: #d9e0e7;
    --autofill-selected: #f1f5ef;
    --autofill-accent: #47743d;
    --autofill-highlight: #fff0a8;
    --autofill-show-all-align: left;
    position: absolute;
    z-index: 10001;
    max-width: calc(100vw - 24px);
    max-height: min(68vh, 620px);
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
    color: var(--autofill-text);
    background: var(--autofill-surface);
    border: 1px solid var(--autofill-border);
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, .16), 0 2px 8px rgba(15, 23, 42, .08);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.autofill-result[hidden] {
    display: none !important;
}

.autofill-result .autofill-list {
    display: block;
    margin: 0;
    padding: 5px;
    list-style: none;
}

.autofill-correction {
    padding: 10px 14px;
    color: var(--autofill-muted);
    background: #fffdf3;
    border-bottom: 1px solid var(--autofill-border);
    font-size: 13px;
    line-height: 1.35;
}

.autofill-correction strong {
    color: var(--autofill-text);
    font-weight: 750;
}

.autofill-result .item-autofill {
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color .14s ease;
}

.autofill-result .item-autofill + .item-autofill {
    border-top: 1px solid rgba(148, 163, 184, .2);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.autofill-result .item-autofill.selected,
.autofill-result .item-autofill:hover {
    background: var(--autofill-selected);
}

.autofill-result .item-autofill > a {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    min-height: 58px;
    padding: 8px 11px;
    box-sizing: border-box;
    color: var(--autofill-text);
    text-align: left;
    text-decoration: none;
    outline: 0;
}

.autofill-result .item-autofill > a:focus-visible {
    box-shadow: inset 0 0 0 2px var(--autofill-accent);
    border-radius: 8px;
}

.autofill-result .img-autofill {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin: 0;
    overflow: hidden;
    background: #f6f7f8;
    border-radius: 8px;
}

.autofill-result .img-autofill img {
    display: block;
    width: 48px !important;
    height: 48px !important;
    max-width: 100%;
    object-fit: contain;
}

.autofill-product-body {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.autofill-result .text-autofill {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--autofill-text);
    font-size: 14px;
    font-weight: 650;
    line-height: 1.32;
    text-overflow: ellipsis;
}

.autofill-result .highlight {
    padding: 0 .08em;
    color: inherit;
    background: var(--autofill-highlight);
    border-radius: 2px;
    font-size: inherit;
    font-weight: 800;
}

.autofill-result .price-autofill {
    display: block;
    color: var(--autofill-accent);
    font-size: 14px;
    font-weight: 750;
    line-height: 1.25;
}

.autofill-result .item-autofill--show-all {
    margin-top: 3px;
    border-top: 1px solid var(--autofill-border);
}

.autofill-result .item-autofill--show-all > a {
    display: block;
    min-height: 0;
    padding: 12px;
    color: var(--autofill-accent);
    font-weight: 700;
    text-align: var(--autofill-show-all-align);
}

.autofill-message {
    padding: 17px 18px;
    color: var(--autofill-muted);
    font-size: 14px;
    line-height: 1.4;
    text-align: left;
}

.autofill-message--error {
    color: #9b3a35;
    background: #fff8f6;
}

@media (max-width: 640px) {
    .autofill-result {
        max-width: calc(100vw - 16px);
        max-height: min(64vh, 520px);
        border-radius: 10px;
    }
    .autofill-result .autofill-list { padding: 4px; }
    .autofill-result .item-autofill > a { min-height: 55px; padding: 7px 9px; gap: 9px; }
    .autofill-result .img-autofill,
    .autofill-result .img-autofill img { width: 44px !important; height: 44px !important; }
    .autofill-result .text-autofill,
    .autofill-result .price-autofill { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
    .autofill-result .item-autofill { transition: none; }
    .autofill-loading { animation-duration: 1.4s; }
}

/* Admin reports */
.autofill-admin {
    --af-green: #47743d;
    --af-green-soft: #edf5ea;
    --af-yellow: #fff3b0;
    --af-red: #a7463f;
    --af-red-soft: #fff2f0;
    --af-ink: #1f2937;
    --af-muted: #6b7280;
    --af-line: #e4e7eb;
    --af-surface: #fff;
    max-width: 1440px;
    padding: 24px 24px 56px;
    color: var(--af-ink);
    box-sizing: border-box;
}

.autofill-admin * { box-sizing: border-box; }

.autofill-admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
}

.autofill-admin-kicker {
    margin-bottom: 5px;
    color: var(--af-green);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.autofill-admin h1,
.autofill-admin h2,
.autofill-admin p { margin-top: 0; }
.autofill-admin h1 { margin-bottom: 6px; font-size: 28px; line-height: 1.2; }
.autofill-admin h2 { margin-bottom: 4px; font-size: 18px; line-height: 1.3; }
.autofill-admin-subtitle,
.autofill-panel-subtitle { margin-bottom: 0; color: var(--af-muted); line-height: 1.45; }

.autofill-admin-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.autofill-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 13px;
    color: #fff !important;
    background: var(--af-green);
    border: 1px solid var(--af-green);
    border-radius: 8px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none !important;
}

.autofill-action--secondary { color: var(--af-ink) !important; background: #fff; border-color: var(--af-line); }
.autofill-action:hover { filter: brightness(.96); }

.autofill-metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.autofill-metric,
.autofill-panel {
    background: var(--af-surface);
    border: 1px solid var(--af-line);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .035);
}

.autofill-metric { min-height: 98px; padding: 16px 18px; }
.autofill-metric-label { display: block; margin-bottom: 7px; color: var(--af-muted); font-size: 13px; font-weight: 650; }
.autofill-metric-value { display: block; color: var(--af-ink); font-size: 28px; font-weight: 800; line-height: 1; }
.autofill-metric--warning { background: #fffdf3; border-color: #f2df87; }
.autofill-metric--warning .autofill-metric-value { color: #7c5a00; }

.autofill-panel { padding: 18px; margin-bottom: 16px; }
.autofill-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.autofill-period { flex: none; color: var(--af-muted); font-size: 13px; }

.autofill-chart {
    position: relative;
    min-height: 250px;
    overflow: hidden;
    background: linear-gradient(180deg, #fbfcfb 0%, #fff 100%);
    border-radius: 9px;
}
.autofill-chart svg { display: block; width: 100%; min-width: 420px; height: 250px; }
.autofill-chart-grid { stroke: #e9edf0; stroke-width: 1; }
.autofill-chart-area { fill: rgba(71, 116, 61, .12); }
.autofill-chart-line { fill: none; stroke: var(--af-green); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.autofill-chart-dot { fill: #fff; stroke: var(--af-green); stroke-width: 2; }
.autofill-chart-label { fill: var(--af-muted); font-size: 11px; font-family: Arial, sans-serif; }
.autofill-chart-empty { display: grid; place-items: center; min-height: 250px; color: var(--af-muted); }

.autofill-report-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, .9fr); gap: 16px; align-items: start; }
.autofill-table-wrap { overflow-x: auto; }
.autofill-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.autofill-table th { padding: 9px 10px; color: var(--af-muted); border-bottom: 1px solid var(--af-line); font-size: 12px; font-weight: 750; text-align: left; }
.autofill-table td { position: relative; padding: 11px 10px; border-bottom: 1px solid var(--af-line); vertical-align: middle; }
.autofill-table tr:last-child td { border-bottom: 0; }
.autofill-table th:nth-child(n+2), .autofill-table td:nth-child(n+2) { width: 88px; text-align: right; }
.autofill-table th:last-child, .autofill-table td:last-child { width: 112px; }
.autofill-query-cell { min-width: 180px; }
.autofill-query-cell a { position: relative; z-index: 1; color: #285e8e; font-weight: 650; text-decoration: none; }
.autofill-query-cell a:hover { text-decoration: underline; }
.autofill-row-bar { position: absolute; z-index: 0; left: 0; bottom: 3px; width: var(--af-bar, 0%); height: 3px; background: #a9c8a2; border-radius: 0 2px 2px 0; }
.autofill-table--empty .autofill-row-bar { background: #e3a09a; }
.autofill-empty-state { padding: 24px 10px; color: var(--af-muted); text-align: center; }

.autofill-maintenance { margin-top: 20px; color: var(--af-muted); }
.autofill-maintenance summary { cursor: pointer; font-weight: 700; }
.autofill-danger-content { display: flex; align-items: center; gap: 14px; margin-top: 12px; padding: 14px; background: var(--af-red-soft); border: 1px solid #efc4c0; border-radius: 10px; }
.autofill-danger-content p { margin: 0; flex: 1; }
.autofill-danger-button { padding: 7px 12px; color: #fff; background: var(--af-red); border: 0; border-radius: 7px; cursor: pointer; font-weight: 700; }

/* Admin settings */
.autofill-settings-modern {
    --af-green: #47743d;
    --af-ink: #1f2937;
    --af-muted: #6b7280;
    --af-line: #e1e5e9;
    max-width: 1120px;
    padding: 22px 24px 60px;
    color: var(--af-ink);
    box-sizing: border-box;
}
.autofill-settings-modern * { box-sizing: border-box; }
.autofill-settings-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.autofill-settings-header h1 { margin: 0 0 5px; font-size: 28px; }
.autofill-settings-header p { margin: 0; color: var(--af-muted); }
.autofill-version { flex: none; padding: 5px 9px; color: var(--af-green); background: #edf5ea; border-radius: 999px; font-size: 12px; font-weight: 800; }
.autofill-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.autofill-settings-card { padding: 18px; background: #fff; border: 1px solid var(--af-line); border-radius: 12px; }
.autofill-settings-card--wide { grid-column: 1 / -1; }
.autofill-settings-card h2 { margin: 0 0 16px; font-size: 18px; }
.autofill-field { display: grid; grid-template-columns: minmax(180px, .85fr) minmax(220px, 1.15fr); gap: 15px; align-items: start; padding: 11px 0; border-top: 1px solid #edf0f2; }
.autofill-field:first-of-type { padding-top: 0; border-top: 0; }
.autofill-field-label { padding-top: 8px; font-weight: 650; line-height: 1.35; }
.autofill-control input[type="text"],
.autofill-control input[type="number"],
.autofill-control select,
.autofill-control textarea { width: 100%; min-width: 0; max-width: none; padding: 8px 10px; color: var(--af-ink); background: #fff; border: 1px solid #bdc5cd; border-radius: 7px; font: inherit; }
.autofill-control input[type="number"] { max-width: 130px; }
.autofill-control textarea { min-height: 104px; resize: vertical; }
.autofill-control input:focus,
.autofill-control select:focus,
.autofill-control textarea:focus { border-color: var(--af-green); outline: 3px solid rgba(71, 116, 61, .14); }
.autofill-help { display: block; margin-top: 6px; color: var(--af-muted); font-size: 12px; line-height: 1.4; }
.autofill-toggle { position: relative; display: inline-flex; align-items: center; gap: 9px; min-height: 34px; cursor: pointer; user-select: none; }
.autofill-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.autofill-toggle-track { position: relative; width: 42px; height: 24px; background: #aeb6be; border-radius: 999px; transition: background .16s ease; }
.autofill-toggle-track:after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.24); transition: transform .16s ease; }
.autofill-toggle input:checked + .autofill-toggle-track { background: var(--af-green); }
.autofill-toggle input:checked + .autofill-toggle-track:after { transform: translateX(18px); }
.autofill-toggle input:focus-visible + .autofill-toggle-track { outline: 3px solid rgba(71, 116, 61, .2); }
.autofill-color-control { display: flex; align-items: center; gap: 8px; }
.autofill-color-control input[type="text"] { flex: 1; }
.autofill-color-swatch { width: 34px; height: 34px; flex: none; background: var(--af-color, linear-gradient(135deg, #fff 45%, #c7cdd3 46%, #c7cdd3 54%, #fff 55%)); border: 1px solid #bdc5cd; border-radius: 7px; }
.autofill-expert { margin-top: 14px; background: #fff; border: 1px solid var(--af-line); border-radius: 12px; }
.autofill-expert summary { padding: 15px 18px; cursor: pointer; font-size: 16px; font-weight: 750; }
.autofill-expert-body { padding: 0 18px 18px; }
.autofill-expert textarea { width: 100%; min-height: 180px; padding: 10px; font-family: Consolas, monospace; border: 1px solid #bdc5cd; border-radius: 8px; resize: vertical; }
.autofill-settings-submit { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 13px 18px; background: #fff; border: 1px solid var(--af-line); border-radius: 12px; }
.autofill-save-button { min-height: 38px; padding: 8px 18px; color: #fff; background: var(--af-green); border: 0; border-radius: 8px; font-weight: 750; cursor: pointer; }
.autofill-save-status { color: var(--af-green); font-weight: 700; }

@media (max-width: 980px) {
    .autofill-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .autofill-metric:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .autofill-report-grid { grid-template-columns: 1fr; }
    .autofill-settings-grid { grid-template-columns: 1fr; }
    .autofill-settings-card--wide { grid-column: auto; }
}

@media (max-width: 680px) {
    .autofill-admin,
    .autofill-settings-modern { padding: 16px 12px 44px; }
    .autofill-admin-header,
    .autofill-settings-header { display: block; }
    .autofill-admin-actions { justify-content: flex-start; margin-top: 14px; }
    .autofill-metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
    .autofill-metric { min-height: 84px; padding: 13px; }
    .autofill-metric-value { font-size: 23px; }
    .autofill-panel { padding: 14px; }
    .autofill-panel-header { display: block; }
    .autofill-period { display: block; margin-top: 6px; }
    .autofill-field { grid-template-columns: 1fr; gap: 6px; }
    .autofill-field-label { padding-top: 0; }
    .autofill-danger-content { display: block; }
    .autofill-danger-button { margin-top: 10px; }
}
