:root {
    --brand: #0d6efd;
    --brand-dark: #0846a5;
    --bg-soft: #f4f6fb;
    --border: #e3e7ef;
}

/* ===== Ticker bar — luôn nổi trên cùng ===== */
.ticker-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1040;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    overflow: hidden;
    white-space: nowrap;
    padding: 7px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.ticker-bar a { color: #fff; text-decoration: none; display: block; text-shadow: 0 1px 2px rgba(0,0,0,.2); }
.ticker-text {
    display: inline-block;
    padding-left: 100%;
    animation: ticker 30s linear infinite;
    font-weight: 700;
    font-size: .88rem;
    letter-spacing: .02em;
}
.ticker-bar:hover .ticker-text { animation-play-state: paused; }
@keyframes ticker { 0% { transform: translateX(0); } 100% { transform: translateX(-100%); } }
@media (max-width: 767px) {
    .ticker-text { animation-duration: 14s; font-size: .82rem; }
}

/* ===== Body offset for fixed ticker ===== */
html { font-size: 16px; }
body {
    background: var(--bg-soft);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: 36px;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ===== Navbar ===== */
#mainNav { position: sticky; top: 36px; z-index: 1030; }

.container-app { padding-left: 12px; padding-right: 12px; max-width: 1280px; margin: 0 auto; }

h1 { font-size: clamp(1.25rem, 4vw, 1.6rem); font-weight: 700; }
h2 { font-size: clamp(1.05rem, 3.4vw, 1.25rem); font-weight: 600; }

.form-control, .form-select { min-height: 44px; font-size: 16px; }
.btn { min-height: 44px; font-size: 1rem; }

/* ===== Type selector ===== */
.type-selector {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px 12px;
    margin: 0 -4px;
}
.type-selector::-webkit-scrollbar { display: none; }

.type-card {
    flex: 0 0 auto;
    scroll-snap-align: start;
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    min-width: 96px;
    text-align: center;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #333;
    text-decoration: none;
}
.type-card i { font-size: 1.6rem; color: var(--brand); }
.type-card span { font-size: .82rem; font-weight: 500; line-height: 1.2; }
.type-card.active {
    border-color: var(--brand);
    background: #eaf2ff;
    box-shadow: 0 4px 12px rgba(13,110,253,.12);
}
.type-card:hover { border-color: var(--brand); }

/* ===== Panels ===== */
.panel {
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 16px;
    margin-bottom: 14px;
}
.panel-title {
    font-size: .95rem;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}

/* ===== Preview ===== */
.preview-box {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
}
.preview-img {
    max-width: min(80vw, 320px);
    width: 100%;
    height: auto;
    image-rendering: pixelated;
    background: #fafafa;
    border-radius: 8px;
}
.payload-text {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: .8rem;
    word-break: break-all;
    color: #555;
    max-height: 80px;
    overflow-y: auto;
}

/* ===== Action bar ===== */
.action-bar {
    position: sticky;
    bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,0.97);
    border-top: 1px solid var(--border);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    display: flex;
    gap: 8px;
    z-index: 10;
    margin: 0 -12px -16px;
    backdrop-filter: blur(8px);
}
.action-bar .btn { flex: 1; }

@media (min-width: 768px) {
    .action-bar {
        position: static;
        background: transparent;
        border-top: 0;
        padding: 0;
        margin: 0;
        backdrop-filter: none;
    }
    .action-bar .btn { flex: 0 1 auto; min-width: 160px; }
    .type-card { min-width: 112px; }
    .type-card i { font-size: 1.9rem; }
}

@media (min-width: 1200px) {
    .type-selector { flex-wrap: wrap; overflow-x: visible; }
}

/* ===== Drop zone ===== */
.drop-zone {
    border: 2px dashed #c4cde0;
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    color: #777;
    cursor: pointer;
    background: #fafbff;
    transition: all .15s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--brand); background: #eaf2ff; color: var(--brand); }
.drop-zone i { font-size: 2rem; display: block; margin-bottom: 4px; color: var(--brand); }

/* ===== TNUT Banner (pro) ===== */
.tnut-banner {
    background: linear-gradient(135deg, #0a3d8f 0%, #1565c0 50%, #1976d2 100%);
    color: #fff;
    padding: 28px 16px;
    margin-top: auto;
    border-top: 3px solid rgba(255,255,255,.15);
}
.tnut-banner h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 2px;
    letter-spacing: .01em;
}
.tnut-banner p { margin-bottom: 2px; }
.tnut-banner a { color: #90caf9; text-decoration: none; transition: color .15s; }
.tnut-banner a:hover { color: #fff; text-decoration: underline; }

.tnut-logo-img {
    width: 56px; height: 56px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 6px;
}

.tnut-info-grid {
    display: flex; flex-wrap: wrap; gap: 4px 16px;
    font-size: .82rem; opacity: .9; margin-top: 6px;
}
.tnut-info-grid i { width: 14px; text-align: center; margin-right: 3px; font-size: .75rem; }

.tnut-links-card {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 12px;
    padding: 14px 16px;
    backdrop-filter: blur(4px);
}
.tnut-links-card p { font-size: .9rem; }

.tnut-link-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 8px;
    padding: 6px 14px;
    color: #fff !important;
    font-size: .82rem;
    font-weight: 500;
    text-decoration: none !important;
    transition: all .15s;
}
.tnut-link-btn:hover {
    background: rgba(255,255,255,.28);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,.15);
}
.tnut-link-btn i { font-size: .9rem; }

/* ===== Mobile table ===== */
@media (max-width: 575px) {
    .stack-table thead { display: none; }
    .stack-table tbody tr { display: block; border: 1px solid var(--border); border-radius: 10px; padding: 8px; margin-bottom: 8px; background: #fff; }
    .stack-table tbody td { display: flex; justify-content: space-between; padding: 4px 0; border: 0; font-size: .9rem; }
    .stack-table tbody td::before { content: attr(data-label); font-weight: 600; color: #666; margin-right: 8px; }
}
