:root {
    --board-bg: #f4f5f7;
    --board-bg-2: #ffffff;
    --board-accent: #b8860b;
    --board-accent-dim: #8a6608;
    --board-text: #1c1c1c;
    --board-muted: rgba(0, 0, 0, 0.55);
    --board-border: rgba(184, 134, 11, 0.30);
    --board-border-soft: rgba(0, 0, 0, 0.08);
    /* Alış (sıcak amber) / Satış (soğuk bronz) — iki ayrı gold tonu ile görsel ayrım. */
    --board-buy: #6b4f08;
    --board-sell: #4a3e22;
    --board-buy-bg: linear-gradient(90deg, #fdf0ce 0%, #f7e1a0 100%);
    --board-buy-bg-alt: linear-gradient(90deg, #f9e7b6 0%, #f0d585 100%);
    --board-sell-bg: linear-gradient(90deg, #f1ebda 0%, #ddd2b0 100%);
    --board-sell-bg-alt: linear-gradient(90deg, #e8dfc6 0%, #d0c294 100%);
    --board-buy-head: linear-gradient(180deg, #d4a444 0%, #b8860b 100%);
    --board-sell-head: linear-gradient(180deg, #b0926a 0%, #8a7350 100%);
    --board-head-bg: #fafbfc;
    --board-yeni-head: #fff3cd;
    --board-yeni-text: #856404;
    --board-eski-head: #e2e6ea;
    --board-eski-text: #495057;
    --board-logo-dark: #1c1c1c;
}

.board-body {
    margin: 0;
    background: var(--board-bg);
    color: var(--board-text);
    font-family: 'Montserrat', sans-serif;
}

.board-wrap {
    background: var(--board-bg);
    color: var(--board-text);
    min-height: calc(100vh - 56px);
    padding: 1.25rem;
}

/* ---------- TV mode: fit viewport, no scroll ---------- */
.board-wrap.tv {
    min-height: 100vh;
    height: 100vh;
    padding: 0.5rem 0.9rem 0.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.board-wrap.tv .board-header {
    margin-bottom: 0.4rem;
    padding-bottom: 0.35rem;
    flex-direction: column;
    text-align: center;
    justify-content: center;
    gap: 0.1rem;
}

.board-wrap.tv .board-title-wrap { text-align: center; }

.board-wrap.tv .board-title {
    font-size: clamp(1.4rem, 2.2vw, 2.2rem);
    line-height: 1.05;
}

.board-wrap.tv .board-subtitle {
    font-size: clamp(0.8rem, 0.95vw, 1rem);
    margin-top: 0;
}

.board-wrap.tv .board-clock {
    text-align: center;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.7rem;
}

.board-wrap.tv .board-clock .time {
    font-size: clamp(1.3rem, 1.8vw, 1.9rem);
}

.board-wrap.tv .board-clock .date {
    font-size: clamp(0.85rem, 1vw, 1.05rem);
}

.board-wrap.tv .has-strip {
    padding: 0.55rem 0.75rem;
    margin-top: 0.55rem;
    margin-bottom: 0;
    gap: 0.75rem;
    flex: 0 0 auto;
}

.board-wrap.tv .has-strip .label { font-size: 0.75rem; }

.board-wrap.tv .has-strip .value {
    font-size: clamp(1.15rem, 1.55vw, 1.7rem);
}

.board-wrap.tv .has-source-label { font-size: 0.7rem; }
.board-wrap.tv .has-source-name {
    font-size: clamp(1.2rem, 1.9vw, 2rem);
}
.board-wrap.tv .has-source { padding-right: 0.9rem; }

.board-wrap.tv .board-grid {
    flex: 1 1 auto;
    min-height: 0;
    gap: 0.6rem;
    display: flex;
    flex-direction: column;
}

.board-wrap.tv .bilezik-row {
    flex: 0 0 auto;
    align-items: stretch;
    /* TV modunda logo kolonu daha da daraltılsın (altın kurları sayfası gibi kompakt). */
    grid-template-columns: minmax(0, 1fr) minmax(100px, 0.22fr);
}

.board-wrap.tv .ziynet-card {
    flex: 1 1 auto;
    min-height: 0;
}

/* TV: ziynet tablosu kart yüksekliğini doldursun → tablo altındaki beyaz boşluk kalkar.
   table'a height:100% verince satırlar tbody içinde proportional dağılır. */
.board-wrap.tv .ziynet-card .board-table-wrap {
    height: 100%;
    min-height: 0;
}
.board-wrap.tv .ziynet-card table.board-dual {
    height: 100%;
}

.board-wrap.tv .board-card { min-height: 0; }

/* TV: bilezik-card içerik kadar büyüsün → altındaki beyaz boşluk kalkar. */
.board-wrap.tv .bilezik-card {
    height: auto;
    align-self: stretch;
}
.board-wrap.tv .bilezik-card .board-table-wrap { flex: 0 1 auto; overflow: visible; }

/* TV: logo kartı bilezik-card yüksekliğine stretch (ana kural zaten yapıyor, sadece
   padding'i daha sıkı yap). aspect-ratio:1/1 ve width:100% kuralları LOGO'YU kareye
   zorlayıp bilezik tablosundan büyük yapıyordu — kaldırıldı. */
.board-wrap.tv .board-logo-big {
    padding: 0.4rem;
}

.board-wrap.tv .board-table-wrap { overflow: hidden; }

.board-wrap.tv .board-card h3 {
    padding: 0.45rem 0.75rem;
    font-size: clamp(1.1rem, 1.6vw, 1.7rem);
}

.board-wrap.tv table.board-table thead th {
    font-size: clamp(0.8rem, 1vw, 1.1rem);
    padding: 0.45rem 0.65rem;
}

.board-wrap.tv table.board-table tbody td {
    font-size: clamp(1.05rem, 1.5vw, 1.75rem);
    padding: 0.4rem 0.75rem;
}

.board-wrap.tv table.board-table tbody td:first-child {
    font-size: clamp(0.95rem, 1.25vw, 1.4rem);
}

.board-wrap.tv table.board-dual tbody td {
    font-size: clamp(1.05rem, 1.5vw, 1.75rem);
}

.board-wrap.tv .board-footer {
    margin-top: 0.35rem;
    font-size: 0.78rem;
}

/* ---------- Header ---------- */
.board-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 2px solid var(--board-accent);
    padding-bottom: 0.6rem;
    margin-bottom: 0.9rem;
}

.board-title-wrap { flex: 1 1 auto; }

.board-title {
    font-size: clamp(1.3rem, 2vw, 2.1rem);
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--board-accent);
    line-height: 1.1;
}

.board-subtitle {
    font-size: 0.9rem;
    color: var(--board-muted);
    margin-top: 0.15rem;
    font-weight: 500;
}

.board-clock {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.board-clock .date {
    font-size: 0.95rem;
    color: var(--board-muted);
    font-weight: 600;
}

.board-clock .time {
    font-size: clamp(1.4rem, 2.2vw, 2.4rem);
    font-weight: 800;
    color: var(--board-accent);
    line-height: 1.1;
}

/* ---------- Has strip (HAS + ONS) — board-grid'in ALTINDA ---------- */
.has-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 1rem;
    align-items: stretch;
    padding: 0.75rem 1rem;
    border: 1px solid var(--board-logo-dark);
    border-radius: 10px;
    margin-top: 0.9rem;
    margin-bottom: 0;
    background: var(--board-logo-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.has-source {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 1.1rem;
    border-right: 1px solid rgba(199, 171, 105, 0.35);
    flex: 0 0 auto;
    max-width: 35%;
}

.has-source-label {
    font-size: 0.7rem;
    color: rgba(199, 171, 105, 0.75);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 0.1rem;
}

.has-source-name {
    font-size: clamp(1.15rem, 1.9vw, 2rem);
    font-weight: 800;
    color: var(--board-accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.has-items {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: space-around;
    gap: 1rem;
    min-width: 0;
}

.has-strip .has-item {
    text-align: center;
    min-width: 0;
}

.has-strip .label {
    font-size: 0.78rem;
    color: rgba(199, 171, 105, 0.75);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
}

.has-strip .value {
    font-size: clamp(1.15rem, 1.55vw, 1.8rem);
    font-weight: 800;
    color: var(--board-accent);
    font-variant-numeric: tabular-nums;
    margin-top: 0.15rem;
}

.has-strip .sep {
    width: 1px;
    background: rgba(199, 171, 105, 0.25);
    align-self: stretch;
}

/* ---------- Grid ---------- */
.board-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: 1fr;
}

.bilezik-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(150px, 0.35fr);
    gap: 0.9rem;
    align-items: stretch;
}

.board-logo-big {
    background: var(--board-logo-dark);
    border: 1px solid var(--board-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    /* Grid item: bilezik-card ile aynı yüksekliğe stretch. KENDİ yüksekliğini
       img'in doğal boyutundan asla dictate etmesin. Aksi halde büyük logo PNG
       bilezik tablosunun altına dev beyaz boşluk açıyor. */
    align-self: stretch;
    min-height: 0;
    /* img'i absolute pozisyonlamak için referans frame. */
    position: relative;
}

.board-logo-big img {
    /* Img tamamen layout dışı — grid row hesabını ETKİLEMEZ.
       Container yüksekliği bilezik-card içeriğinden gelir; img bu kutuya sığar. */
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    right: 0.6rem;
    bottom: 0.6rem;
    width: auto;
    height: auto;
    max-width: calc(100% - 1.2rem);
    max-height: calc(100% - 1.2rem);
    object-fit: contain;
    margin: auto;
    display: block;
}

.board-card {
    background: var(--board-bg-2);
    border: 1px solid var(--board-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.board-card h3 {
    font-size: clamp(1.15rem, 1.5vw, 1.7rem);
    color: var(--board-accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    padding: 0.6rem 0.9rem;
    margin: 0;
    border-bottom: 1px solid var(--board-border);
    background: var(--board-head-bg);
    font-weight: 800;
    text-align: center;
}

.board-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
}

table.board-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

table.board-dual {
    min-width: 520px;
}

table.board-table th,
table.board-table td {
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid var(--board-border-soft);
    font-variant-numeric: tabular-nums;
}

table.board-table thead th {
    color: var(--board-accent);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: var(--board-head-bg);
    border-bottom: 1px solid var(--board-border);
    text-align: right;
    font-weight: 800;
}

table.board-table thead th:first-child {
    text-align: left;
}

/* Buy/Sell column header backgrounds — strong contrast so text pops */
table.board-table thead th.col-buy,
table.board-dual thead th.sub.col-buy {
    background: var(--board-buy-head);
    color: #ffffff;
    text-align: right;
}
table.board-table thead th.col-sell,
table.board-dual thead th.sub.col-sell {
    background: var(--board-sell-head);
    color: #ffffff;
    text-align: right;
}

table.board-table tbody td {
    font-size: clamp(1.1rem, 1.45vw, 1.6rem);
    font-weight: 700;
    text-align: right;
    color: var(--board-text);
}

table.board-table tbody td:first-child {
    text-align: left;
    color: var(--board-text);
    font-weight: 700;
    letter-spacing: 0.02em;
    font-size: clamp(1.05rem, 1.4vw, 1.5rem);
}

table.board-table tbody tr:nth-child(even) td {
    background: rgba(0,0,0,0.015);
}

table.board-table tbody tr:last-child td {
    border-bottom: none;
}

/* Buy (sıcak amber gradient) vs Sell (soğuk bronz gradient) — iki ayrı gold tonu ile kolon ayrımı. */
table.board-table tbody td.buy {
    background: var(--board-buy-bg);
    color: var(--board-buy);
    font-weight: 800;
}
table.board-table tbody td.sell {
    background: var(--board-sell-bg);
    color: var(--board-sell);
    font-weight: 800;
}
table.board-table tbody tr:nth-child(even) td.buy {
    background: var(--board-buy-bg-alt);
}
table.board-table tbody tr:nth-child(even) td.sell {
    background: var(--board-sell-bg-alt);
}

table.board-dual thead th.group {
    text-align: center;
    border-left: 1px solid var(--board-border);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    font-weight: 800;
}

/* YENI: yellow tint; ESKI: gray tint — two distinct group colors. */
table.board-dual thead th.group:nth-of-type(2) {
    background: var(--board-yeni-head);
    color: var(--board-yeni-text);
}
table.board-dual thead th.group:nth-of-type(3) {
    background: var(--board-eski-head);
    color: var(--board-eski-text);
}

table.board-dual thead th.group:first-child {
    border-left: none;
}

table.board-dual thead th.sub {
    font-size: 0.78rem;
    padding: 0.3rem 0.5rem;
    font-weight: 800;
    text-align: right;
}

table.board-dual tbody td.divider {
    border-left: 1px solid var(--board-border);
}

/* Ziynet numbers match Bilezik numbers in size. */
table.board-dual tbody td {
    font-size: clamp(1.1rem, 1.45vw, 1.6rem);
    font-weight: 700;
}

/* Header logo: hidden by default (desktop/TV uses the big side logo instead). */
.board-header-logo { display: none; }
.board-header-logo img {
    display: block;
    height: 56px;
    width: auto;
    border-radius: 8px;
}

.board-footer {
    margin-top: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--board-muted);
    font-size: 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.board-footer .refresh-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--board-accent);
    box-shadow: 0 0 6px rgba(184, 134, 11, 0.5);
    margin-right: 0.4rem;
    vertical-align: middle;
}

.board-footer.blink .refresh-indicator {
    animation: board-blink 0.6s ease-in-out;
}

.board-footer .board-footer-sep {
    margin: 0 0.4rem;
    opacity: 0.5;
}

@keyframes board-blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.2;
        transform: scale(0.7);
    }
}

.board-fullscreen-btn {
    background: transparent;
    color: var(--board-accent);
    border: 1px solid var(--board-border);
    border-radius: 4px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
    font-weight: 700;
}

.board-fullscreen-btn:hover {
    background: var(--board-accent);
    color: #ffffff;
}

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .bilezik-row {
        grid-template-columns: 1fr;
    }
    /* Tablet'te logo alta düşer; absolute kaldırılır, fixed clamp ile boylanır. */
    .board-logo-big {
        position: static;
        min-height: 160px;
        max-height: 220px;
        aspect-ratio: auto;
    }
    .board-logo-big img {
        position: static;
        top: auto; left: auto; right: auto; bottom: auto;
        width: auto;
        height: 100%;
        max-width: 100%;
        max-height: 200px;
        object-fit: contain;
        margin: 0;
    }
}

@media (max-width: 767px) {
    .board-wrap {
        padding: 0.75rem;
    }
    /* Mobile: küçük logo üstte, başlık altında. Büyük yan logo kartı gizli. */
    .board-header {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 0.3rem;
    }
    .board-header-logo {
        display: block;
        order: -1;
    }
    .board-header-logo img {
        height: 48px;
    }
    .board-title-wrap { text-align: center; order: 0; }
    .board-clock {
        text-align: center;
        display: flex;
        gap: 0.6rem;
        align-items: baseline;
        justify-content: center;
        order: 1;
    }
    .board-logo-big { display: none; }

    .board-card h3 {
        font-size: 1.05rem;
        padding: 0.5rem 0.7rem;
        letter-spacing: 0.08em;
    }

    /* Tables: ilk kolondaki uzun isim kırılabilsin, satır yüksekliği büyüsün. */
    table.board-table {
        table-layout: auto;
    }
    table.board-table th,
    table.board-table td {
        padding: 0.45rem 0.5rem;
    }
    table.board-table thead th {
        font-size: 0.75rem;
        letter-spacing: 0.04em;
    }
    table.board-table tbody td {
        font-size: 1rem;
        white-space: normal;
        word-break: break-word;
    }
    table.board-table tbody td:first-child {
        font-size: 0.95rem;
        font-weight: 800;
        white-space: normal;
        word-break: break-word;
        line-height: 1.2;
    }
    table.board-dual { min-width: 0; }
    table.board-dual thead th.group {
        font-size: 0.8rem;
    }
    table.board-dual thead th.sub {
        font-size: 0.7rem;
        padding: 0.3rem 0.35rem;
    }
    table.board-dual tbody td {
        font-size: 0.95rem;
        white-space: normal;
    }

    .has-strip {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
        padding: 0.6rem 0.7rem;
    }
    .has-source {
        max-width: 100%;
        padding: 0 0 0.45rem 0;
        border-right: none;
        border-bottom: 1px solid rgba(199, 171, 105, 0.35);
        text-align: center;
        align-items: center;
    }
    .has-source-name {
        font-size: 1.2rem;
        white-space: normal;
    }
    .has-items {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.55rem;
        width: 100%;
    }
    .has-strip .sep { display: none; }
    .has-strip .has-item {
        padding: 0.4rem 0.35rem;
        background: rgba(199, 171, 105, 0.08);
        border: 1px solid rgba(199, 171, 105, 0.25);
        border-radius: 6px;
        min-width: 0;
    }
    .has-strip .value {
        font-size: 1.05rem;
        word-break: break-word;
    }
}

@media (max-width: 575px) {
    .board-wrap {
        padding: 0.5rem;
    }
    .board-header-logo img { height: 42px; }
    .has-strip {
        gap: 0.4rem;
        padding: 0.55rem 0.55rem;
    }
    .has-items {
        grid-template-columns: 1fr 1fr;
        gap: 0.4rem;
    }
    .has-source-name { font-size: 1.05rem; }
    .has-source-label { font-size: 0.6rem; }
    .has-strip .label { font-size: 0.65rem; }
    .has-strip .value { font-size: 0.95rem; }
    table.board-table tbody td {
        font-size: 0.95rem;
    }
    table.board-table tbody td:first-child {
        font-size: 0.85rem;
    }
    table.board-dual tbody td {
        font-size: 0.9rem;
    }
}

/* Stale-data uyarı banner'ı: canlı kaynak çöktüğünde / veri eskidiğinde gösterilir.
   Sıfır gösterip sessizce başarısız olmaktansa fail-loud uyarı çıkar. */
.board-stale-banner {
    background: linear-gradient(90deg, #c0392b 0%, #e74c3c 100%);
    color: #fff;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-bottom: 2px solid #8b1a0e;
    letter-spacing: 0.2px;
}
.board-stale-banner i { font-size: 1.05rem; }
.board-wrap.tv .board-stale-banner { font-size: 1.1rem; padding: 0.7rem 1rem; }
.board-stale-banner.d-none { display: none !important; }
