:root {
    --bg: var(--tg-theme-bg-color, #0e0e10);
    --secondary-bg: var(--tg-theme-secondary-bg-color, #1c1c1e);
    --text: var(--tg-theme-text-color, #ffffff);
    --hint: var(--tg-theme-hint-color, #8e8e93);
    --link: var(--tg-theme-link-color, #0a84ff);
    --button: var(--tg-theme-button-color, #0a84ff);
    --button-text: var(--tg-theme-button-text-color, #ffffff);
    --accent: #0a84ff;
    --accent-2: #5e5ce6;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --yellow: #ffd60a;
    --purple: #bf5af2;
    --pink: #ff375f;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 20px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 80px;
    overscroll-behavior: none;
}

/* ============ HEADER ============ */
.header {
    padding: 16px 20px 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* ============ CONTENT ============ */
.content {
    padding: 0 16px 16px;
}

.loader {
    text-align: center;
    padding: 60px 20px;
    color: var(--hint);
    font-size: 15px;
}

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--hint);
    font-size: 15px;
    line-height: 1.5;
}

/* ============ TABBAR (скроллируемый) ============ */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--secondary-bg);
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.tabbar::-webkit-scrollbar { display: none; }

.tab {
    flex: 0 0 auto;
    min-width: 64px;
    background: none;
    border: none;
    color: var(--hint);
    font-size: 20px;
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    transition: color .2s, transform .15s;
    font-family: inherit;
    scroll-snap-align: start;
}

.tab span {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.tab:active { transform: scale(0.9); }

.tab.active {
    color: var(--accent);
}

/* ============ БЕНТО-СЕТКА (ГЛАВНАЯ) ============ */

.greeting {
    padding: 0 4px 16px;
}

.greeting-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.greeting-sub {
    color: var(--hint);
    font-size: 14px;
}

.bento {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.bento-card {
    background: var(--secondary-bg);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    transition: transform .15s, background .2s;
    position: relative;
    overflow: hidden;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.bento-card:active { transform: scale(0.97); }

.bento-card.wide { grid-column: span 2; }

.bento-card.accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
}

.bento-card.accent .bento-hint { color: rgba(255,255,255,0.75); }

.bento-card.green {
    background: linear-gradient(135deg, #30d158, #26a848);
    color: #fff;
}

.bento-card.green .bento-hint { color: rgba(255,255,255,0.8); }

.bento-card.orange {
    background: linear-gradient(135deg, #ff9f0a, #ff6a00);
    color: #fff;
}

.bento-card.orange .bento-hint { color: rgba(255,255,255,0.8); }

.bento-card.purple {
    background: linear-gradient(135deg, #bf5af2, #8e2de2);
    color: #fff;
}

.bento-card.purple .bento-hint { color: rgba(255,255,255,0.8); }

.bento-card.pink {
    background: linear-gradient(135deg, #ff375f, #d70040);
    color: #fff;
}

.bento-card.pink .bento-hint { color: rgba(255,255,255,0.8); }

.bento-icon {
    font-size: 24px;
    margin-bottom: 6px;
}

.bento-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    margin-bottom: 2px;
}

.bento-value {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.bento-hint {
    font-size: 12px;
    color: var(--hint);
    margin-top: 4px;
}

.bento-hint strong {
    color: var(--text);
    font-weight: 600;
}

/* ============ БЫСТРЫЕ ДЕЙСТВИЯ ============ */

.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.quick-btn {
    background: var(--secondary-bg);
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 4px;
    color: var(--text);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: transform .15s, background .2s;
}

.quick-btn:active { transform: scale(0.95); }

.quick-btn .icon {
    font-size: 22px;
}

/* ============ КАРТОЧКИ ============ */

.card {
    background: var(--secondary-bg);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: -0.2px;
}

.card-sub {
    color: var(--hint);
    font-size: 13px;
    margin-bottom: 4px;
    line-height: 1.4;
}

.pair-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.pair-number {
    font-weight: 700;
    color: var(--accent);
    font-size: 15px;
}

.pair-time {
    color: var(--hint);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.badge {
    display: inline-block;
    background: rgba(10,132,255,0.15);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}

.badge.sg1 { background: rgba(255,159,10,0.18); color: var(--orange); }
.badge.sg2 { background: rgba(48,209,88,0.18); color: var(--green); }

/* ============ КНОПКИ ============ */

.btn {
    background: var(--button);
    color: var(--button-text);
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 8px;
    font-family: inherit;
    transition: transform .15s, opacity .15s;
}

.btn:active { transform: scale(0.97); opacity: 0.9; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

.btn-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.btn-row .btn { margin-top: 0; }

/* ============ СТАТУСЫ ЯВКИ ============ */

.status-row {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.status-btn {
    flex: 1;
    background: var(--bg);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 10px 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s;
}

.status-btn:active { transform: scale(0.95); }

.status-btn.active-will { background: var(--green); border-color: var(--green); color: #000; font-weight: 700; }
.status-btn.active-absent { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.status-btn.active-sick { background: var(--orange); border-color: var(--orange); color: #000; font-weight: 700; }
.status-btn.active-late { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

/* ============ XP БАР ============ */

.xp-bar {
    background: var(--bg);
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
    margin: 8px 0;
}

.xp-fill {
    background: linear-gradient(90deg, var(--accent), var(--green));
    height: 100%;
    transition: width .4s;
    border-radius: 6px;
}

/* ============ РЕЙТИНГ ============ */

.rating-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    gap: 12px;
}

.rating-item:last-child { border-bottom: none; }

.rating-rank {
    font-weight: 700;
    color: var(--hint);
    font-size: 15px;
    min-width: 32px;
    text-align: center;
}

.rating-name { flex: 1; font-size: 15px; }
.rating-xp { color: var(--accent); font-weight: 700; font-size: 14px; }

/* ============ СЕЛЕКТОР ДНЯ ============ */

.day-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.day-tabs::-webkit-scrollbar { display: none; }

.day-tab {
    background: var(--secondary-bg);
    border: none;
    color: var(--hint);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
    transition: all .2s;
}

.day-tab.active {
    background: var(--accent);
    color: #fff;
}

/* ============ МОДАЛЬНОЕ ОКНО ============ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.hidden { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    background: var(--secondary-bg);
    border-radius: 20px 20px 0 0;
    padding: 20px;
    overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.4);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.modal-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-right: 40px;
    letter-spacing: -0.3px;
}

.modal-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 14px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    margin-bottom: 12px;
    outline: none;
    transition: border-color .2s;
}

.modal-input:focus { border-color: var(--accent); }

.modal-textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 14px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    margin-bottom: 12px;
    outline: none;
    min-height: 100px;
    resize: vertical;
    transition: border-color .2s;
}

.modal-textarea:focus { border-color: var(--accent); }

.modal-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-list-item {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: background .15s;
}

.modal-list-item:active { background: rgba(255,255,255,0.05); }

.modal-list-item-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.modal-list-item-sub {
    color: var(--hint);
    font-size: 13px;
    line-height: 1.4;
}

/* ============ АНИМАЦИИ ============ */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.bento-card, .card, .quick-btn {
    animation: fadeInUp 0.3s ease backwards;
}

.bento-card:nth-child(1) { animation-delay: 0.02s; }
.bento-card:nth-child(2) { animation-delay: 0.04s; }
.bento-card:nth-child(3) { animation-delay: 0.06s; }
.bento-card:nth-child(4) { animation-delay: 0.08s; }
.bento-card:nth-child(5) { animation-delay: 0.1s; }
.bento-card:nth-child(6) { animation-delay: 0.12s; }