:root {
    --tg-theme-bg-color: var(--tg-theme-bg-color, #ffffff);
    --tg-theme-text-color: var(--tg-theme-text-color, #000000);
    --tg-theme-hint-color: var(--tg-theme-hint-color, #999999);
    --tg-theme-link-color: var(--tg-theme-link-color, #2481cc);
    --tg-theme-button-color: var(--tg-theme-button-color, #2481cc);
    --tg-theme-button-text-color: var(--tg-theme-button-text-color, #ffffff);
    --tg-theme-secondary-bg-color: var(--tg-theme-secondary-bg-color, #f0f2f5);
    --tg-theme-header-bg-color: var(--tg-theme-header-bg-color, #ffffff);
    --tg-theme-section-bg-color: var(--tg-theme-section-bg-color, #ffffff);
    
    /* Safe Area Variables */
    --tg-safe-area-inset-top: env(safe-area-inset-top, 0px);
    --tg-safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --tg-content-safe-area-inset-top: env(content-safe-area-inset-top, 0px);
    --tg-content-safe-area-inset-bottom: env(content-safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove highlight on tap */
}

body {
    font-family: 'Playfair Display', serif;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    line-height: 1.5;
    padding: 16px;
    padding-top: calc(16px + var(--tg-safe-area-inset-top));
    padding-bottom: calc(16px + var(--tg-safe-area-inset-bottom));
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Scrollbar styling for desktop/web */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--tg-theme-hint-color);
    border-radius: 3px;
}

.container {
    max-width: 600px; /* Slightly wider for tablets */
    margin: 0 auto;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 24px;
    padding-top: 8px;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--tg-theme-hint-color);
    font-size: 14px;
}

.card {
    background: var(--tg-theme-secondary-bg-color); /* Use secondary bg color */
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.dark .card {
    background: rgba(255, 255, 255, 0.05); /* Fallback for dark mode if secondary bg fails */
    box-shadow: none;
}

h2 {
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 600;
}

h3 {
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 500;
    margin-top: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stats-grid > :nth-child(odd):last-child {
    grid-column: 1 / -1;
}

.stat-card {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column-reverse;
    justify-content: center;
    align-items: center;
}

.stat-number {
    font-size: 24px;
    font-weight: bold;
    display: block;
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
    margin-top: 4px;
    font-weight: normal;
}

.check-item {
    display: flex;
    align-items: center;
    padding: 12px 8px;
    margin: 0 -8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease, border-radius 0.2s ease;
}

@media (hover: hover) {
    .check-item:hover {
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 8px;
    }
}

.check-item:active {
    transform: scale(0.98);
    background-color: rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}

.check-item:focus-visible {
    outline: 2px solid var(--tg-theme-button-color);
    outline-offset: 2px;
    border-radius: 8px;
}

.check-item:last-child {
    border-bottom: none;
}

.dark .check-item {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.check-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 20px;
    flex-shrink: 0;
}

.check-icon.image {
    background: rgba(36, 129, 204, 0.1);
    color: var(--tg-theme-button-color);
}

.check-icon.link {
    background: rgba(156, 39, 176, 0.1);
    color: #9c27b0;
}

.check-details {
    flex: 1;
    min-width: 0; /* Fix flex overflow */
}

.check-type {
    font-weight: 500;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.check-date {
    font-size: 12px;
    color: var(--tg-theme-hint-color);
    margin-top: 2px;
}

.check-result {
    text-align: right;
    margin-left: 8px;
    flex-shrink: 0;
}

.risk-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.risk-high {
    background: rgba(244, 67, 54, 0.1);
    color: #d32f2f;
}

.dark .risk-high {
    color: #f44336;
}

.risk-medium {
    background: rgba(255, 152, 0, 0.1);
    color: #f57c00;
}

.dark .risk-medium {
    color: #ff9800;
}

.risk-low {
    background: rgba(76, 175, 80, 0.1);
    color: #388e3c;
}

.dark .risk-low {
    color: #4caf50;
}

.button {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    border: none;
    border-radius: 10px;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-bottom: 12px;
    transition: opacity 0.2s ease, transform 0.1s ease, filter 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (hover: hover) {
    .button:not(:disabled):hover {
        filter: brightness(0.9);
    }
}

.button:not(:disabled):active {
    transform: scale(0.98);
    opacity: 0.9;
}

.button:focus-visible {
    outline: 2px solid var(--tg-theme-button-color);
    outline-offset: 2px;
}

.button-secondary {
    background: transparent;
    color: var(--tg-theme-button-color); /* Use button color for text instead of link color */
    border: 2px solid var(--tg-theme-button-color); /* Thicker border */
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--tg-theme-hint-color);
    font-size: 15px;
}

.error {
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid rgba(244, 67, 54, 0.2);
}

.hidden {
    display: none !important;
}

/* User Info Styles */
#user-info p {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 15px;
}

#user-info strong {
    color: var(--tg-theme-hint-color);
    font-weight: normal;
}

#user-info span {
    font-weight: 500;
}

/* Login Widget Container */
#login-widget {
    text-align: center;
    margin: 40px 0;
    padding: 20px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 16px;
}
