:root {
    --agm-card-bg: #ffffff;
    --agm-shell-bg: #f8fafc;
    --agm-head-bg: #f1f5f9;

    --agm-text: #0f172a;
    --agm-muted: rgba(15, 23, 42, 0.62);

    --agm-border: rgba(15, 23, 42, 0.10);
    --agm-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);

    --agm-row: #ffffff;
    --agm-row-alt: rgba(15, 23, 42, 0.02);
    --agm-row-hover: rgba(37, 99, 235, 0.05);

    --agm-active-bg: rgba(34, 197, 94, 0.12);
    --agm-active-border: rgba(34, 197, 94, 0.35);

    --agm-badge-bg: linear-gradient(135deg, #2563eb, #60a5fa);

    --agm-radius: 12px;
    --agm-pad: 12px;
    --agm-shell-pad: 8px;

    --agm-th-font: 11px;
    --agm-td-font: 13px;
    --agm-th-pad-y: 9px;
    --agm-td-pad-y: 9px;
    --agm-pad-x: 10px;
}

/* Forced DARK (settings) */
.agm-discount-card[data-agm-theme="dark"] {
    --agm-card-bg: linear-gradient(180deg, #111827, #0f172a);
    --agm-shell-bg: rgba(255, 255, 255, .04);
    --agm-head-bg: rgba(255, 255, 255, .06);

    --agm-text: #f9fafb;
    --agm-muted: rgba(226, 232, 240, .78);

    --agm-border: rgba(255, 255, 255, .10);
    --agm-shadow: 0 18px 40px rgba(0, 0, 0, .35);

    --agm-row: rgba(255, 255, 255, .06);
    --agm-row-alt: rgba(255, 255, 255, .04);
    --agm-row-hover: rgba(255, 255, 255, .06);

    --agm-active-bg: rgba(34, 197, 94, 0.18);
    --agm-active-border: rgba(34, 197, 94, 0.40);

    --agm-badge-bg: linear-gradient(135deg, #f59e0b, #fbbf24);
}

/* AUTO theme (OS driven) */
@media (prefers-color-scheme: dark) {
    .agm-discount-card[data-agm-theme="auto"] {
        --agm-card-bg: linear-gradient(180deg, #111827, #0f172a);
        --agm-shell-bg: rgba(255, 255, 255, .04);
        --agm-head-bg: rgba(255, 255, 255, .06);

        --agm-text: #f9fafb;
        --agm-muted: rgba(226, 232, 240, .78);

        --agm-border: rgba(255, 255, 255, .10);
        --agm-shadow: 0 18px 40px rgba(0, 0, 0, .35);

        --agm-row: rgba(255, 255, 255, .06);
        --agm-row-alt: rgba(255, 255, 255, .04);
        --agm-row-hover: rgba(255, 255, 255, .06);

        --agm-active-bg: rgba(34, 197, 94, 0.18);
        --agm-active-border: rgba(34, 197, 94, 0.40);

        --agm-badge-bg: linear-gradient(135deg, #f59e0b, #fbbf24);
    }
}

.agm-discount-card {
    width: 100%;
    margin: 10px 0 16px;
    padding: var(--agm-pad);
    border-radius: var(--agm-radius);
    background: var(--agm-card-bg);
    border: 1px solid var(--agm-border);
    box-shadow: var(--agm-shadow);
    color: var(--agm-text);
    position: relative;
}

.agm-discount-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.agm-discount-card__title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--agm-text);
}

.agm-discount-card__badge {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: .10em;
    color: #fff;
    background: var(--agm-badge-bg);
    border: 1px solid rgba(0, 0, 0, .10);
    white-space: nowrap;
}

.agm-discount-card[data-agm-theme="dark"] .agm-discount-card__badge {
    color: #111827;
    border-color: rgba(255, 255, 255, .06);
}

.agm-discount-card__hint {
    margin: 2px 0 0;
    font-size: 12px;
    line-height: 1.35;
    max-width: 520px;
}

.agm-discount-table-shell {
    border-radius: calc(var(--agm-radius) - 2px);
    padding: var(--agm-shell-pad);
    background: var(--agm-shell-bg);
    border: 1px solid var(--agm-border);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

#agm-discount-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    display: table !important;
    margin-bottom: 10px;
}

#agm-discount-table thead {
    display: table-header-group !important;
}

#agm-discount-table tbody {
    display: table-row-group !important;
}

#agm-discount-table tr {
    display: table-row !important;
}

#agm-discount-table th,
#agm-discount-table td {
    display: table-cell !important;
}

/* Header */
#agm-discount-table thead th {
    font-size: var(--agm-th-font);
    letter-spacing: .10em;
    text-transform: uppercase;
    padding: var(--agm-th-pad-y) var(--agm-pad-x);
    background: var(--agm-head-bg);
    border-bottom: 1px solid var(--agm-border);
    white-space: nowrap;
    box-sizing: border-box;

    /* ✅ Center all headers */
    text-align: center !important;
}

/* Rows */
#agm-discount-table tbody tr {
    background: var(--agm-row);
    transition: background-color .15s ease;
    isolation: isolate;
}

#agm-discount-table tbody tr:nth-child(even) {
    background: var(--agm-row-alt);
}

#agm-discount-table tbody tr:hover {
    background: var(--agm-row-hover);
}

/* Cells */
#agm-discount-table tbody td {
    padding: var(--agm-td-pad-y) var(--agm-pad-x);
    font-size: var(--agm-td-font);
    color: var(--agm-text);
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    vertical-align: middle;
    position: relative;
    z-index: 1;

    /* ✅ Center all cell contents */
    text-align: center !important;
}

.agm-discount-card[data-agm-theme="dark"] #agm-discount-table tbody td {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* numeric stability */
#agm-discount-table tbody td:nth-child(2),
#agm-discount-table tbody td:nth-child(3) {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#agm-discount-table tbody td:nth-child(2) {
    font-weight: 900;
}

/* Active row supports both class names */
#agm-discount-table tbody tr.agm-discount-row.highlighted,
#agm-discount-table tbody tr.agm-discount-row.agm-active-tier {
    background: var(--agm-active-bg) !important;
}

/* disable old tr accent strip */
#agm-discount-table tbody tr.agm-discount-row.highlighted::before,
#agm-discount-table tbody tr.agm-discount-row.agm-active-tier::before {
    content: none !important;
}

/* active cell outline (no layout shift) */
#agm-discount-table tbody tr.agm-discount-row.highlighted td,
#agm-discount-table tbody tr.agm-discount-row.agm-active-tier td {
    background-image: none !important;
    border: 0 !important;
    box-shadow:
        inset 0 1px 0 var(--agm-active-border),
        inset 0 -1px 0 var(--agm-active-border) !important;
}

/* left & right outline */
#agm-discount-table tbody tr.agm-discount-row.highlighted td:first-child,
#agm-discount-table tbody tr.agm-discount-row.agm-active-tier td:first-child {
    box-shadow:
        inset 1px 0 0 var(--agm-active-border),
        inset 0 1px 0 var(--agm-active-border),
        inset 0 -1px 0 var(--agm-active-border) !important;
}

#agm-discount-table tbody tr.agm-discount-row.highlighted td:last-child,
#agm-discount-table tbody tr.agm-discount-row.agm-active-tier td:last-child {
    box-shadow:
        inset -1px 0 0 var(--agm-active-border),
        inset 0 1px 0 var(--agm-active-border),
        inset 0 -1px 0 var(--agm-active-border) !important;
}

/* left green strip now on first td only */
#agm-discount-table tbody tr.agm-discount-row.highlighted td:first-child::before,
#agm-discount-table tbody tr.agm-discount-row.agm-active-tier td:first-child::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, rgba(34, 197, 94, 1), rgba(34, 197, 94, .55));
    z-index: 0;
    pointer-events: none;
}

/* Tick icon */
:root {
    --agm-check-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18'%3E%3Ccircle cx='9' cy='9' r='9' fill='%2322c55e'/%3E%3Cpath d='M5.2 9.3 7.7 11.8 12.9 6.6' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ✅ Remove tick from 2nd column by default (we will re-add per cols below) */
#agm-discount-table tbody tr.agm-discount-row.highlighted td:nth-child(2),
#agm-discount-table tbody tr.agm-discount-row.agm-active-tier td:nth-child(2) {
    background-image: none !important;
    padding-right: var(--agm-pad-x) !important;
}

/* ✅ If 2 columns: rightmost is 2nd column => tick in 2nd column */
.agm-discount-card[data-agm-cols="2"] #agm-discount-table tbody tr.agm-discount-row.highlighted td:nth-child(2),
.agm-discount-card[data-agm-cols="2"] #agm-discount-table tbody tr.agm-discount-row.agm-active-tier td:nth-child(2) {
    background-image: var(--agm-check-icon) !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 18px 18px !important;
}

/* ✅ If 3 columns: rightmost is 3rd column => tick in 3rd column */
.agm-discount-card[data-agm-cols="3"] #agm-discount-table tbody tr.agm-discount-row.highlighted td:nth-child(3),
.agm-discount-card[data-agm-cols="3"] #agm-discount-table tbody tr.agm-discount-row.agm-active-tier td:nth-child(3) {
    background-image: var(--agm-check-icon) !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 18px 18px !important;
}

/* ----------------- MOBILE ----------------- */
@media (max-width: 640px) {
    .agm-discount-card {
        margin: 8px 0 14px;
        padding: 10px 10px 9px;
    }

    .agm-discount-card__header {
        gap: 6px;
        margin-bottom: 6px;
        align-items: flex-start;
    }

    .agm-discount-card__hint {
        font-size: 11.5px;
    }

    /* Mobilde colgroup bazı cihazlarda yanlış kolon davranışı yaratıyor */
    #agm-discount-table colgroup {
        display: none !important;
    }

    /* Mobilde daha stabil: auto layout */
    #agm-discount-table {
        table-layout: auto !important;
    }

    #agm-discount-table thead th {
        padding: 8px 8px;
        white-space: normal;
        line-height: 1.1;
        text-align: center !important;
    }

    #agm-discount-table tbody td {
        padding: 10px 8px;
        font-size: 13px;
        text-align: center !important;
    }

    /* 2 kolonlu tabloda (Per kapalı) 3. sütunu gizle */
    .agm-discount-card[data-agm-cols="2"] #agm-discount-table thead th:nth-child(3),
    .agm-discount-card[data-agm-cols="2"] #agm-discount-table tbody td:nth-child(3) {
        display: none !important;
    }

    /* 2 kolonlu tabloda oranlar */
    .agm-discount-card[data-agm-cols="2"] #agm-discount-table thead th:nth-child(2),
    .agm-discount-card[data-agm-cols="2"] #agm-discount-table tbody td:nth-child(2) {
        width: 40% !important;
    }

    /* 3 kolonlu tabloda oranlar */
    .agm-discount-card[data-agm-cols="3"] #agm-discount-table thead th:nth-child(1),
    .agm-discount-card[data-agm-cols="3"] #agm-discount-table tbody td:nth-child(1) {
        width: 46% !important;
    }

    .agm-discount-card[data-agm-cols="3"] #agm-discount-table thead th:nth-child(2),
    .agm-discount-card[data-agm-cols="3"] #agm-discount-table tbody td:nth-child(2) {
        width: 27% !important;
    }

    .agm-discount-card[data-agm-cols="3"] #agm-discount-table thead th:nth-child(3),
    .agm-discount-card[data-agm-cols="3"] #agm-discount-table tbody td:nth-child(3) {
        width: 27% !important;
        display: table-cell !important;
    }

    /* Tick: mobilde daha kompakt (2 kolon) */
    .agm-discount-card[data-agm-cols="2"] #agm-discount-table tbody tr.agm-discount-row.highlighted td:nth-child(2),
    .agm-discount-card[data-agm-cols="2"] #agm-discount-table tbody tr.agm-discount-row.agm-active-tier td:nth-child(2) {
        background-position: right 8px center !important;
        background-size: 16px 16px !important;
    }

    /* Tick: mobilde daha kompakt (3 kolon => 3. hücre) */
    .agm-discount-card[data-agm-cols="3"] #agm-discount-table tbody tr.agm-discount-row.highlighted td:nth-child(3),
    .agm-discount-card[data-agm-cols="3"] #agm-discount-table tbody tr.agm-discount-row.agm-active-tier td:nth-child(3) {
        background-position: right 8px center !important;
        background-size: 16px 16px !important;
    }
}