/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a2035;
    --bg-hover: #1e2a45;
    --bg-table-header: #0f172a;
    --bg-table-row-alt: #0d1424;

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --text-accent: #38bdf8;

    --border-color: #1e293b;
    --border-light: #334155;

    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-purple: #8b5cf6;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-orange: #f97316;

    --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-header: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --gradient-card: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08));

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 13px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background animated gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(6, 182, 212, 0.04) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 100%;
    padding: 0 16px 40px;
}

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--gradient-header);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 16px;
    /* Sticky header */
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    margin: 0 -16px 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.4));
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.4)); }
    50% { filter: drop-shadow(0 0 24px rgba(59, 130, 246, 0.7)); }
}

.header-info h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.app-version {
    display: inline-block;
    background: rgba(139, 92, 246, 0.25);
    color: var(--accent-purple);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 6px;
    letter-spacing: 0.03em;
    vertical-align: middle;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-panel {
    display: flex;
    gap: 16px;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 90px;
}

.config-input-group {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.config-input {
    width: 50px;
    padding: 3px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
}

.config-input:focus {
    outline: none;
    border-color: var(--accent-purple);
}

.config-save-btn {
    padding: 3px 6px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.7rem;
    transition: all var(--transition-fast);
}

.config-save-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    transform: scale(1.1);
}

.status-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.status-value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-accent);
    margin-top: 2px;
}

.countdown {
    color: var(--accent-amber) !important;
    animation: countdown-pulse 1s ease-in-out infinite;
}

@keyframes countdown-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.countdown-item {
    border-color: rgba(245, 158, 11, 0.3);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.connection-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-amber);
    animation: blink 1.5s ease-in-out infinite;
}

.connection-status.connected .dot {
    background: var(--accent-emerald);
    animation: none;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.connection-status.error .dot {
    background: var(--accent-rose);
    animation: none;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===== Latest Result Banner ===== */
.latest-result {
    margin-bottom: 16px;
    padding: 14px 20px;
    background: var(--gradient-card);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-lg);
    animation: slide-in 0.5s var(--transition-slow);
}

@keyframes slide-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.latest-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.latest-icon { font-size: 1.2rem; }

.latest-title {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.latest-issue {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-accent);
    margin-left: auto;
    background: rgba(59, 130, 246, 0.1);
    padding: 3px 10px;
    border-radius: 20px;
}

.latest-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.latest-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    animation: pop-in 0.3s ease backwards;
}

.latest-num.prize-db { background: linear-gradient(135deg, #dc2626, #ef4444); color: white; }
.latest-num.prize-1 { background: linear-gradient(135deg, #ea580c, #f97316); color: white; }
.latest-num.prize-2 { background: linear-gradient(135deg, #d97706, #f59e0b); color: white; }
.latest-num.prize-3 { background: linear-gradient(135deg, #059669, #10b981); color: white; }
.latest-num.prize-4 { background: linear-gradient(135deg, #0284c7, #38bdf8); color: white; }
.latest-num.prize-5 { background: linear-gradient(135deg, #7c3aed, #8b5cf6); color: white; }
.latest-num.prize-6 { background: linear-gradient(135deg, #6d28d9, #a78bfa); color: white; }
.latest-num.prize-7 { background: linear-gradient(135deg, #475569, #64748b); color: white; }
.latest-num.prize-8 { background: linear-gradient(135deg, #334155, #475569); color: white; }

@keyframes pop-in {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

/* ===== Controls ===== */
.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }
.btn-refresh:hover { border-color: var(--accent-cyan); }
.btn-refresh svg { transition: transform 0.5s ease; }
.btn-refresh:hover svg { transform: rotate(180deg); }
.btn-clear:hover { border-color: var(--accent-rose); }

/* Toggle Switch */
.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    user-select: none;
}

.toggle-label input { display: none; }

.toggle-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--border-light);
    border-radius: 20px;
    transition: var(--transition-normal);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-normal);
}

.toggle-label input:checked + .toggle-slider {
    background: var(--accent-blue);
}

.toggle-label input:checked + .toggle-slider::after {
    transform: translateX(18px);
}

/* ===== Tab Navigation ===== */
.tab-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    flex: 1;
    justify-content: center;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3);
}

.tab-btn svg {
    flex-shrink: 0;
}

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: tab-fade-in 0.3s ease;
}

@keyframes tab-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Table (Shared) ===== */
.table-wrapper {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    background: var(--bg-secondary);
}

.table-container {
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 340px);
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

.table-container::-webkit-scrollbar { width: 8px; height: 8px; }
.table-container::-webkit-scrollbar-track { background: transparent; }
.table-container::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
.table-container::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Frequency Table (Tab 1) ===== */
#statsTable {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
}

#statsTable thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

#statsTable thead th {
    background: var(--bg-table-header);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 8px 4px;
    text-align: center;
    border-bottom: 2px solid var(--accent-blue);
    white-space: nowrap;
    min-width: 28px;
    letter-spacing: 0.02em;
    position: relative;
}

#statsTable thead th:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Sticky first column */
.sticky-col {
    position: sticky !important;
    left: 0;
    z-index: 25 !important;
    background: var(--bg-table-header) !important;
}

.col-issue {
    min-width: 120px !important;
    max-width: 120px;
    text-align: left !important;
    padding-left: 12px !important;
}

tbody .sticky-col {
    background: var(--bg-secondary) !important;
    z-index: 10 !important;
}

tbody tr:nth-child(even) .sticky-col {
    background: var(--bg-table-row-alt) !important;
}

tbody tr:hover .sticky-col {
    background: var(--bg-hover) !important;
}

#statsTable tbody tr {
    transition: background var(--transition-fast);
}

#statsTable tbody tr:nth-child(even) {
    background: var(--bg-table-row-alt);
}

#statsTable tbody tr:hover {
    background: var(--bg-hover);
}

#statsTable tbody td {
    text-align: center;
    padding: 5px 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    border-bottom: 1px solid rgba(30, 41, 59, 0.5);
    color: var(--text-muted);
    min-width: 28px;
    position: relative;
    transition: all var(--transition-fast);
}

#statsTable tbody td.has-value { color: var(--accent-cyan); font-weight: 700; }
#statsTable tbody td.has-value-2 { color: var(--accent-amber); font-weight: 700; }
#statsTable tbody td.has-value-3 { color: var(--accent-rose); font-weight: 800; }

#statsTable tbody td.issue-cell {
    text-align: left;
    padding-left: 12px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

#statsTable tbody td.issue-cell .issue-date {
    color: var(--text-primary);
    font-weight: 600;
    display: block;
}

#statsTable tbody td.issue-cell .issue-id {
    color: var(--text-muted);
    font-size: 0.65rem;
}

#statsTable tbody tr.new-row {
    animation: highlight-row 2s ease-out;
}

@keyframes highlight-row {
    0% { background: rgba(59, 130, 246, 0.2); }
    100% { background: transparent; }
}

#statsTable thead th.decade-start { border-left: 2px solid var(--border-light); }
#statsTable tbody td.decade-start { border-left: 2px solid rgba(30, 41, 59, 0.8); }

#statsTable td.col-highlight { background: rgba(59, 130, 246, 0.06); }

/* ===== Cycle Table (Tab 2) ===== */
/* STT column */
.col-stt {
    min-width: 40px !important;
    max-width: 48px;
    text-align: center !important;
    font-family: var(--font-mono) !important;
    font-size: 0.72rem !important;
    color: var(--text-muted) !important;
    padding: 4px 6px !important;
}

.stt-cell {
    left: 0;
    z-index: 5;
}

.col-issue {
    left: 48px !important;
}

/* Cycle max gap summary */
.cycle-max-gap-summary {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.1), rgba(249, 115, 22, 0.08));
    border: 1px solid rgba(244, 63, 94, 0.25);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    margin-bottom: 10px;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    gap: 8px;
}
.mgap-label { font-size: 0.78rem; color: var(--text-secondary); font-weight: 600; }
.mgap-value { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 900; color: var(--accent-rose); }
.mgap-detail { font-size: 0.75rem; color: var(--text-muted); }

.cycle-table-container {
    max-height: calc(100vh - 340px);
}

.cycle-table {
    border-collapse: collapse;
    width: 100%;
}

.cycle-table thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

.cycle-table thead th {
    background: var(--bg-table-header);
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 5px 8px;
    text-align: center;
    border-bottom: 2px solid var(--accent-purple);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.cycle-table .col-number {
    min-width: 40px !important;
    max-width: 50px;
    text-align: center !important;
    padding: 3px 6px !important;
}

.cycle-table .col-count { min-width: 60px; }
.cycle-table .col-maxgap { min-width: 60px; }
.cycle-table .col-currentgap { min-width: 60px; }
.cycle-table .col-diff { min-width: 60px; }
.cycle-table .col-gaplist {
    min-width: 300px;
    text-align: left !important;
}

.cycle-table tbody tr {
    transition: background var(--transition-fast);
}

.cycle-table tbody tr:nth-child(even) {
    background: var(--bg-table-row-alt);
}

.cycle-table tbody tr:hover {
    background: var(--bg-hover);
}

.cycle-table tbody td {
    padding: 3px 6px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    border-bottom: 1px solid rgba(30, 41, 59, 0.4);
    color: var(--text-secondary);
    text-align: center;
    transition: all var(--transition-fast);
    line-height: 1.2;
}

/* Number column styling */
.cycle-table tbody td.cell-number {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    position: sticky;
    left: 0;
    z-index: 10;
}

.cycle-table tbody tr:nth-child(even) td.cell-number {
    background: var(--bg-table-row-alt);
}

.cycle-table tbody tr:hover td.cell-number {
    background: var(--bg-hover);
}

.cycle-table tbody td.cell-count {
    font-weight: 700;
    color: var(--text-accent);
}

.cycle-table tbody td.cell-maxgap {
    font-weight: 700;
    color: var(--accent-orange);
}

.cycle-table tbody td.cell-currentgap {
    font-weight: 700;
}

.cycle-table tbody td.cell-diff {
    font-weight: 700;
}

/* Highlight overdue numbers (diff <= 0 means current gap >= max gap) */
.cycle-table tbody tr.overdue {
    background: rgba(16, 185, 129, 0.08) !important;
}

.cycle-table tbody tr.overdue td.cell-diff {
    color: var(--accent-emerald);
}

.cycle-table tbody tr.overdue td.cell-currentgap {
    color: var(--accent-rose);
}

/* Warning level: close to max gap */
.cycle-table tbody tr.warning td.cell-diff {
    color: var(--accent-amber);
}

.cycle-table tbody tr.warning td.cell-currentgap {
    color: var(--accent-amber);
}

/* Gap list styling */
.cycle-table tbody td.cell-gaplist {
    text-align: left;
    font-size: 0.72rem;
    color: var(--text-muted);
    max-width: 500px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cycle-table tbody td.cell-gaplist:hover {
    white-space: normal;
    word-break: break-all;
}

.gap-chip {
    display: inline-block;
    padding: 0px 3px;
    margin: 0px 1px;
    border-radius: 2px;
    font-size: 0.62rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    line-height: 1.4;
}

.gap-chip.gap-high {
    background: rgba(249, 115, 22, 0.15);
    color: var(--accent-orange);
}

.gap-chip.gap-max {
    background: rgba(244, 63, 94, 0.2);
    color: var(--accent-rose);
    font-weight: 800;
}

.gap-chip.gap-low {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-emerald);
}

/* ===== Empty State ===== */
.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state.visible {
    display: flex;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header { padding: 12px 16px; }
    .header-right { width: 100%; flex-wrap: wrap; }
    .status-panel { flex-wrap: wrap; width: 100%; }
    .status-item { flex: 1; min-width: 70px; }
    html { font-size: 12px; }
    .col-issue { min-width: 90px !important; }
    .tab-btn { padding: 8px 12px; font-size: 0.8rem; }
    .tab-btn svg { display: none; }
}

/* ===== Utility Animations ===== */
.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== Prediction Tab ===== */
.prediction-current {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(59, 130, 246, 0.08));
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
}

.pred-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.pred-card-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pred-icon { font-size: 1.8rem; }

.pred-card-title h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
}

.pred-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    margin-top: 2px;
}

.pred-method-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.pred-numbers {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.pred-num-card {
    flex: 1;
    min-width: 120px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.pred-num-card:hover {
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.2);
}

.pred-rank {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.pred-num-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 900;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 4px 0;
}

.pred-confidence {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
}

.pred-conf-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.pred-conf-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--gradient-primary);
    transition: width 0.8s ease;
}

.pred-factors {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.pred-factor-mini {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    opacity: 0.3;
}

.pred-factor-mini.active { opacity: 1; }
.f-overdue { background: var(--accent-rose); }
.f-proximity { background: var(--accent-orange); }
.f-deficit { background: var(--accent-amber); }
.f-recent { background: var(--accent-cyan); }
.f-consistency { background: var(--accent-emerald); }

.pred-factors-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.factor-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.factor-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    display: inline-block;
}

/* Accuracy Summary */
.pred-accuracy {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.accuracy-item {
    flex: 1;
    min-width: 100px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    text-align: center;
}

.accuracy-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.accuracy-value {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
}

.accuracy-value.accent-green { color: var(--accent-emerald); }
.accuracy-value.accent-blue { color: var(--accent-cyan); }

/* Prediction History */
.pred-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.pred-history-header h3 {
    font-size: 1rem;
    color: var(--text-primary);
}

.btn-clear-pred {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-clear-pred:hover {
    border-color: var(--accent-rose);
    color: var(--accent-rose);
}

.pred-table-container { max-height: 400px; }

.pred-table {
    border-collapse: collapse;
    width: 100%;
}

.pred-table thead {
    position: sticky;
    top: 0;
    z-index: 20;
}

.pred-table thead th {
    background: var(--bg-table-header);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 10px 12px;
    text-align: center;
    border-bottom: 2px solid var(--accent-purple);
}

.pred-col-stt { min-width: 40px; width: 40px; }
.pred-col-issue { min-width: 120px; text-align: left !important; padding-left: 12px !important; }
.pred-col-num { min-width: 80px; }
.pred-col-result { min-width: 80px; }

.pred-stt-cell {
    font-weight: 700;
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
}

/* Position Stats Summary */
.position-stats-container {
    margin-bottom: 16px;
}

.position-stats-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.position-stats-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.position-stat-card {
    flex: 1;
    min-width: 90px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    text-align: center;
    transition: all var(--transition-fast);
}

.position-stat-card:hover {
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

.position-stat-rank {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--accent-purple);
    margin-bottom: 6px;
}

.position-stat-ratio {
    font-size: 1.1rem;
    font-weight: 800;
    font-family: var(--font-mono);
    margin-bottom: 2px;
}

.position-stat-ratio.good { color: var(--accent-emerald); }
.position-stat-ratio.medium { color: var(--accent-amber); }
.position-stat-ratio.low { color: var(--accent-rose); }

.position-stat-pct {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.position-stat-streak {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-rose);
    opacity: 0.85;
}

/* ===== Prediction Limit Control ===== */
.pred-limit-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.pred-limit-control label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.pred-limit-control input {
    width: 70px;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
}

.pred-limit-control input:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.pred-limit-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Per-position hit rate badges */
.pos-bet-per-position {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    justify-content: center;
}

.pos-bet-per-position.top-stats {
    margin-top: 0;
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(139, 92, 246, 0.04);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.pos-bet-pos-stat {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.pos-bet-pos-stat.good {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
}

.pos-bet-pos-stat.medium {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
}

.pos-bet-pos-stat.low {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
}

.pos-bet-pos-stat.total {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
    font-weight: 800;
}

/* ===== Dual Layout for Prediction Tab ===== */
.pred-dual-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    align-items: start;
}

.pred-dual-left {
    min-width: 0; /* prevent overflow */
}

.pred-dual-right {
    position: sticky;
    top: 10px;
}

@media (max-width: 1100px) {
    .pred-dual-layout {
        grid-template-columns: 1fr 320px;
    }
}

@media (max-width: 900px) {
    .pred-dual-layout {
        grid-template-columns: 1fr;
    }
    .pred-dual-right {
        position: static;
    }
}

/* ===== Position Betting Section ===== */
.pos-betting-section {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
}

.pos-betting-header h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.pos-betting-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0 0 14px 0;
}

.pos-betting-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 16px 0;
}

.pos-bet-cards {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.pos-bet-card {
    flex: 1;
    min-width: 100px;
    border-radius: var(--radius-md);
    padding: 14px 12px;
    text-align: center;
    transition: all var(--transition-fast);
}

.pos-bet-card.active {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.pos-bet-card.active:hover {
    border-color: var(--accent-emerald);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.2);
}

.pos-bet-card.cooling {
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.2);
    opacity: 0.8;
}

.pos-bet-position {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--accent-purple);
    margin-bottom: 6px;
}

.pos-bet-number {
    font-size: 1.5rem;
    font-weight: 900;
    font-family: var(--font-mono);
    color: var(--accent-emerald);
    margin-bottom: 4px;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.pos-bet-status {
    font-size: 0.72rem;
    color: var(--accent-purple);
    font-weight: 600;
}

.pos-bet-progress {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    margin-bottom: 4px;
}

.pos-bet-bar {
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    margin-bottom: 6px;
    overflow: hidden;
}

.pos-bet-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-emerald), var(--accent-amber));
    border-radius: 2px;
    transition: width 0.5s ease;
}

.pos-bet-detail {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Betting History */
.pos-betting-history-wrapper {
    margin-top: 16px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 14px;
}

.pos-betting-hist-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 10px 0;
}

.pos-bet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.pos-bet-table th {
    background: var(--bg-table-header);
    color: var(--text-secondary);
    padding: 8px 10px;
    font-weight: 700;
    text-align: center;
    border-bottom: 2px solid var(--accent-purple);
    font-size: 0.72rem;
}

.pos-bet-table td {
    padding: 7px 10px;
    text-align: center;
    border-bottom: 1px solid rgba(30, 41, 59, 0.4);
    font-family: var(--font-mono);
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.pos-bet-table tr.bet-hit { background: rgba(16, 185, 129, 0.05); }
.pos-bet-table tr.bet-expired { background: rgba(244, 63, 94, 0.03); }
.pos-bet-table tr:hover { background: var(--bg-hover); }

.pos-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
    font-weight: 700;
    font-size: 0.72rem;
}

.bet-result-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
}

.bet-result-badge.bet-hit {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
}

.bet-result-badge.bet-expired {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
}

.pos-bet-summary {
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.06);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: center;
}

.pred-table tbody tr {
    transition: background var(--transition-fast);
}

.pred-table tbody tr:nth-child(even) { background: var(--bg-table-row-alt); }
.pred-table tbody tr:hover { background: var(--bg-hover); }

.pred-table tbody td {
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    border-bottom: 1px solid rgba(30, 41, 59, 0.5);
    text-align: center;
    color: var(--text-secondary);
}

.pred-table tbody td.pred-issue-cell {
    text-align: left;
    padding-left: 12px;
    font-size: 0.72rem;
}

/* Hit/Miss number styling */
.pred-num-hit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 30px;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 0.85rem;
}

.pred-num-hit.hit {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-emerald);
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.pred-num-hit.miss {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.2);
    opacity: 0.7;
}

.pred-num-hit.pending {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-purple);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.pred-result-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.pred-result-badge.result-hit {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
}

.pred-result-badge.result-miss {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
    opacity: 0.6;
}

.pred-result-badge.result-pending {
    background: rgba(139, 92, 246, 0.1);
    color: var(--accent-purple);
}

/* ===== Suggestion Tab (Tab 4) ===== */
.sugg-active-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}
.sugg-header h2 { font-size: 1.1rem; margin: 0 0 4px; color: var(--text-primary); }
.sugg-desc { font-size: 0.75rem; color: var(--text-muted); margin: 0 0 16px; }
.sugg-empty { color: var(--text-muted); font-size: 0.8rem; text-align: center; padding: 20px; }

.sugg-cards { display: flex; gap: 12px; flex-wrap: wrap; }

.sugg-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.06));
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-md);
    padding: 14px;
    min-width: 120px;
    text-align: center;
    transition: all 0.3s ease;
}
.sugg-card.warm {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.1), rgba(245, 158, 11, 0.06));
    border-color: rgba(249, 115, 22, 0.3);
}
.sugg-card.urgent {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.12), rgba(239, 68, 68, 0.06));
    border-color: rgba(244, 63, 94, 0.35);
    animation: urgentPulse 2s ease-in-out infinite;
}
@keyframes urgentPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
    50% { box-shadow: 0 0 12px 2px rgba(244, 63, 94, 0.15); }
}

.sugg-card-number {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--accent-blue);
    margin-bottom: 6px;
}
.sugg-card.warm .sugg-card-number { color: var(--accent-orange); }
.sugg-card.urgent .sugg-card-number { color: var(--accent-rose); }

.sugg-card-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sugg-label { font-size: 0.65rem; color: var(--text-muted); }
.sugg-draws { font-family: var(--font-mono); font-size: 0.85rem; font-weight: 700; color: var(--text-primary); }

.sugg-progress { height: 3px; background: rgba(255,255,255,0.05); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.sugg-progress-fill { height: 100%; background: var(--accent-blue); border-radius: 2px; transition: width 0.5s ease; }
.sugg-card.warm .sugg-progress-fill { background: var(--accent-orange); }
.sugg-card.urgent .sugg-progress-fill { background: var(--accent-rose); }

.sugg-card-meta { font-size: 0.6rem; color: var(--text-muted); }

.sugg-watching {
    width: 100%;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.sugg-watch-label { font-size: 0.72rem; color: var(--text-muted); }
.sugg-watch-chip {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.sugg-watch-chip small { color: var(--text-muted); font-size: 0.6rem; }

.sugg-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.sugg-stat-item {
    flex: 1;
    min-width: 80px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px;
    text-align: center;
}
.sugg-stat-item.hit { border-color: rgba(16, 185, 129, 0.3); }
.sugg-stat-item.miss { border-color: rgba(244, 63, 94, 0.3); }
.sugg-stat-label { display: block; font-size: 0.65rem; color: var(--text-muted); margin-bottom: 4px; }
.sugg-stat-val { font-family: var(--font-mono); font-size: 1.1rem; font-weight: 800; color: var(--text-primary); }
.sugg-stat-item.hit .sugg-stat-val { color: var(--accent-emerald); }
.sugg-stat-item.miss .sugg-stat-val { color: var(--accent-rose); }

.sugg-history-section { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 16px; }
.sugg-history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sugg-history-header h3 { margin: 0; font-size: 0.95rem; color: var(--text-primary); }

.sugg-table { width: 100%; border-collapse: collapse; }
.sugg-table thead th { background: var(--bg-table-header); padding: 6px 10px; font-size: 0.72rem; font-weight: 700; color: var(--text-secondary); text-align: center; border-bottom: 2px solid var(--accent-purple); }
.sugg-table tbody td { padding: 5px 10px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-secondary); text-align: center; border-bottom: 1px solid rgba(30,41,59,0.4); }
.sugg-hist-num { font-weight: 800; font-size: 0.85rem !important; color: var(--text-primary) !important; }
.sugg-result { padding: 2px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; }
.sugg-hit { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.sugg-miss { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }

/* ===== Lock Overlay — shown when countdown ≤ 3s ===== */
.lockable-area {
    position: relative;
    transition: filter 0.3s ease;
}

.lock-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.lock-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.lock-overlay .lock-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
    animation: lock-pulse 1.2s ease-in-out infinite;
}

.lock-overlay .lock-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f59e0b;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.lock-overlay .lock-sub {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

@keyframes lock-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.7; }
}
