/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f0f2f5;
    color: #1e293b;
    min-height: 100vh;
}

/* ── Header ── */
.header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    padding: 24px 32px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.header-icon {
    width: 42px; height: 42px;
    background: rgba(255,255,255,.15);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: .5px; }
.header p  { font-size: .85rem; color: #94a3b8; margin-top: 2px; }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 20px; }

/* ── Filter Bar ── */
.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: #fff;
    border-radius: 12px;
    padding: 16px 22px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    border: 1px solid #e2e8f0;
}
.filter-label {
    font-size: .85rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
.filter-selects {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-selects select {
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: .9rem;
    color: #334155;
    background: #f8fafc;
    cursor: pointer;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.filter-selects select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
#sel-year  { min-width: 90px; }
#sel-month { min-width: 130px; }
#sel-day   { min-width: 72px; }

.filter-btn {
    padding: 8px 22px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, transform .1s;
}
.filter-btn:hover  { background: #2563eb; }
.filter-btn:active { transform: scale(.97); }

.filter-active-date {
    font-size: .82rem;
    color: #64748b;
    margin-left: auto;
    white-space: nowrap;
}
.filter-active-date strong { color: #1e293b; }

/* ── Tabs Wrapper ── */
.tabs-wrapper {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
    overflow: hidden;
}

/* ── Tabs Nav ── */
.tabs-nav {
    display: flex;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
    flex-shrink: 0;
    padding: 16px 28px;
    border: none;
    background: transparent;
    font-size: .93rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: color .2s;
    border-bottom: 3px solid transparent;
    text-transform: capitalize;
    letter-spacing: .3px;
    position: relative;
    top: 2px;
}
.tab-btn:hover { color: #3b82f6; }
.tab-btn.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
    background: #fff;
}

/* portal colour accents */
.tab-btn[data-portal="yawyaw"].active  { color: #8b5cf6; border-bottom-color: #8b5cf6; }
.tab-btn[data-portal="safragat"].active { color: #f59e0b; border-bottom-color: #f59e0b; }
.tab-btn[data-portal="sudaplay"].active { color: #10b981; border-bottom-color: #10b981; }
.tab-btn[data-portal="almees"].active   { color: #ef4444; border-bottom-color: #ef4444; }
.tab-btn[data-portal="shileel"].active  { color: #06b6d4; border-bottom-color: #06b6d4; }

/* ── Tab Panels ── */
.tab-panel { display: none; padding: 28px 28px 32px; }
.tab-panel.active { display: block; }

/* ── Section Title ── */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .8px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title::before {
    content: '';
    display: inline-block;
    width: 4px; height: 18px;
    border-radius: 2px;
    background: currentColor;
}

/* ── Stat Cards ── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    border-radius: 12px;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-card.subscribers   { background: #eff6ff; border: 1px solid #bfdbfe; }
.stat-card.unsubscribers { background: #fff7ed; border: 1px solid #fed7aa; }
.stat-card.today-subs    { background: #f0fdf4; border: 1px solid #bbf7d0; }
.stat-card.today-unsubs  { background: #fef2f2; border: 1px solid #fecaca; }

.stat-label {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #64748b;
}
.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}
.stat-card.subscribers   .stat-value { color: #2563eb; }
.stat-card.unsubscribers .stat-value { color: #ea580c; }
.stat-card.today-subs    .stat-value { color: #16a34a; }
.stat-card.today-unsubs  .stat-value { color: #dc2626; }

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    width: fit-content;
    margin-top: 4px;
}
.badge-up   { background: #dcfce7; color: #15803d; }
.badge-down { background: #fee2e2; color: #b91c1c; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid #e2e8f0; margin: 24px 0; }

/* ── Table ── */
.table-wrapper {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.stats-table thead tr { background: #f1f5f9; }
.stats-table th {
    padding: 12px 18px;
    text-align: left;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #475569;
}
.stats-table td {
    padding: 12px 18px;
    border-top: 1px solid #f1f5f9;
    color: #334155;
}
.stats-table tbody tr:hover { background: #f8fafc; }
.stats-table tbody tr:nth-child(even) { background: #fafafa; }
.stats-table tbody tr:nth-child(even):hover { background: #f1f5f9; }

.row-num  { color: #94a3b8; font-size: .8rem; }
.row-date { font-weight: 600; }

.badge-subs   { background: #dbeafe; color: #1d4ed8; padding: 2px 10px; border-radius: 12px; font-weight: 700; font-size: .82rem; }
.badge-unsubs { background: #ffedd5; color: #c2410c; padding: 2px 10px; border-radius: 12px; font-weight: 700; font-size: .82rem; }

/* ── Responsive ── */
@media (max-width: 640px) {
    .header { padding: 18px 16px; }
    .tab-btn { padding: 14px 18px; font-size: .85rem; }
    .tab-panel { padding: 20px 16px 24px; }
    .stat-value { font-size: 1.6rem; }
    .filter-bar { gap: 8px; }
    .filter-active-date { margin-left: 0; }
}
