:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #f97316;
    --bg-dark: #0f172a;
    --bg-light: #f8fafc;
    --text-color: #0f172a;
    --muted-color: #64748b;
    --card-bg: #ffffff;
    --shadow-soft: 0 20px 45px rgba(15, 23, 42, 0.08);
    --border-radius-lg: 18px;
    --border-radius-md: 12px;
    --transition-base: all .25s ease;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08) 0%, rgba(15, 23, 42, 0.08) 100%);
    color: var(--text-color);
}

main.page-wrapper {
    min-height: calc(100vh - 72px);
    padding: 48px 0;
}

.card {
    border: none;
    border-radius: var(--border-radius-lg);
    background: var(--card-bg);
    box-shadow: var(--shadow-soft);
    transition: var(--transition-base);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 26px 60px rgba(79, 70, 229, 0.12);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    box-shadow: 0 12px 25px rgba(79, 70, 229, 0.25);
    transition: var(--transition-base);
}

.btn-primary:hover {
    box-shadow: 0 16px 35px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.btn-outline-secondary {
    border: 1px solid rgba(15, 23, 42, 0.12);
    color: var(--text-color);
    transition: var(--transition-base);
}

.btn-outline-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: rgba(79, 70, 229, 0.05);
}

.navbar-modern {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    box-shadow: 0 26px 60px rgba(15, 23, 42, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.navbar-modern .navbar-brand {
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #fff !important;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-modern .navbar-brand span.mark {
    display: inline-flex;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(79, 70, 229, 1), rgba(249, 115, 22, 1));
    font-weight: 700;
    font-size: 18px;
}

.navbar-modern .nav-link {
    color: rgba(255,255,255,0.8) !important;
    font-weight: 500;
    margin-right: 6px;
    border-radius: 8px;
    padding: 8px 14px !important;
    transition: var(--transition-base);
}

.navbar-modern .nav-link:hover,
.navbar-modern .nav-link.active {
    color: #fff !important;
    background: rgba(79,70,229,0.2);
}

.navbar-modern .dropdown-menu {
    border-radius: 16px;
    border: none;
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.18);
    padding: 12px 0;
}

.navbar-modern .dropdown-menu.show {
    display: block;
}

.avatar-thumb {
    display: inline-flex;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.35);
    background: rgba(15, 23, 42, 0.4);
    align-items: center;
    justify-content: center;
}

.avatar-thumb.avatar-xl {
    width: 120px;
    height: 120px;
    border-width: 0;
    background: rgba(79, 70, 229, 0.1);
}

.avatar-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initial {
    font-weight: 600;
    color: #fff;
    font-size: 0.95rem;
}

.avatar-thumb.avatar-xl .avatar-initial {
    font-size: 2.2rem;
    color: var(--primary-dark);
}

.hero-card {
    padding: 48px;
    border-radius: 26px;
    background: linear-gradient(140deg, rgba(79, 70, 229, 0.95) 0%, rgba(15, 23, 42, 0.95) 65%);
    color: #fff;
}

.hero-card h1 {
    font-weight: 700;
    font-size: 2.5rem;
}

.hero-card p {
    color: rgba(255,255,255,0.8);
    max-width: 560px;
}

.table-modern thead {
    border-bottom: none;
}

.table-modern thead tr th {
    border: none;
    background: rgba(79, 70, 229, 0.08);
    color: var(--text-color);
    font-weight: 600;
}

/* --- История интервалов: единый стиль шапки --- */
.history-table thead {
    border: none;
}

.history-table thead tr {
    background: linear-gradient(135deg, rgba(79,70,229,0.12), rgba(15,23,42,0.08));
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.history-table thead th {
    background: transparent !important; /* убрать предыдущее фоновое значение */
    font-weight: 600;
    color: var(--text-color);
    padding: 14px 18px;
    border: none;
    letter-spacing: 0.02em;
}

.history-table thead th:first-child {
    border-top-left-radius: var(--border-radius-md);
    border-bottom-left-radius: var(--border-radius-md);
}
.history-table thead th:last-child {
    border-top-right-radius: var(--border-radius-md);
    border-bottom-right-radius: var(--border-radius-md);
}

@media (prefers-color-scheme: dark) {
    .history-table thead tr {
        background: linear-gradient(135deg, rgba(79,70,229,0.22), rgba(15,23,42,0.35));
        box-shadow: 0 10px 24px rgba(0,0,0,0.35);
    }
    .history-table thead th {
        color: #f1f5f9;
    }
}

.table-modern tbody tr {
    border: none;
    background: #fff;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.05);
}

.badge-tag {
    border-radius: 50px;
    padding: 0.35rem 0.85rem;
    font-weight: 600;
    transition: transform .2s ease, box-shadow .2s ease;
}

.dropdown-toggle.no-caret::after {
    display: none;
}

.text-muted-soft {
    color: var(--muted-color) !important;
}

.counter-card {
    border: none;
    border-radius: 20px;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease;
}

.counter-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 24px 40px rgba(15, 23, 42, 0.12);
}

.counter-card-active {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(79, 70, 229, 0.04));
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(79, 70, 229, 0.12);
}

.status-pill.pause {
    background: rgba(249, 115, 22, 0.12);
}

.pause-icon {
    position: relative;
    width: 12px;
    height: 14px;
    display: inline-block;
}

.pause-icon::before,
.pause-icon::after {
    content: '';
    position: absolute;
    top: 0;
    width: 4px;
    height: 100%;
    background: var(--secondary-color);
    border-radius: 2px;
}

.pause-icon::after {
    right: 0;
}

.pause-icon::before {
    left: 0;
}

.timer-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-left: auto;
    text-align: right;
}

.timer-main {
    font-size: 1.5rem;
    font-weight: 600;
    font-feature-settings: 'tnum';
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.015em;
    color: var(--text-color);
}

.timer-wrap-active .timer-main {
    color: var(--primary-dark);
    text-shadow: 0 8px 20px rgba(79, 70, 229, 0.2);
}

.timer-link {
    text-decoration: none;
    color: inherit;
}

.counter-heading {
    flex: 1;
    min-width: 0;
}

.counter-heading-title {
    word-break: break-word;
}

.counter-heading-title a {
    display: inline-block;
    max-width: 100%;
    word-break: break-word;
    white-space: normal;
}

.timer-link:hover .timer-main {
    color: var(--primary-color);
}

.timer-sub {
    font-size: 0.85rem;
    color: var(--muted-color);
}

.timer-display {
    font-feature-settings: 'tnum';
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.timer-display-large {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.btn-start.is-loading,
.btn-stop.is-loading {
    position: relative;
    pointer-events: none;
    color: transparent !important;
}

.btn-start.is-loading::after,
.btn-stop.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    border-radius: 50%;
    border: 2px solid rgba(15, 23, 42, 0.15);
    border-top-color: currentColor;
    animation: spin 0.8s linear infinite;
}

.badge-highlight {
    animation: pulse 1.6s ease-out;
}

@keyframes tickPulse {
    0% {
        transform: scale(0.98);
        text-shadow: none;
    }
    40% {
        transform: scale(1.02);
        text-shadow: 0 8px 18px rgba(79, 70, 229, 0.15);
    }
    100% {
        transform: scale(1);
        text-shadow: none;
    }
}

.tick-animate {
    animation: tickPulse 0.9s ease-out;
}

/* Более выразительная анимация для итогового дневного таймера */
@keyframes totalPulse {
    0% { transform: scale(0.96); text-shadow: 0 0 0 rgba(79,70,229,0); }
    35% { transform: scale(1.05); text-shadow: 0 6px 22px rgba(79,70,229,0.35); }
    70% { transform: scale(1.015); text-shadow: 0 3px 10px rgba(79,70,229,0.15); }
    100% { transform: scale(1); text-shadow: 0 0 0 rgba(79,70,229,0); }
}

.total-animate {
    animation: totalPulse 1.1s ease-out;
}

/* Анимация контейнера итогового блока при загрузке/обновлении */
@keyframes totalBlockAppear {
    0% { opacity: 0; transform: translateY(6px) scale(.97); }
    50% { opacity: 1; transform: translateY(-2px) scale(1.01); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.total-block-animate {
    animation: totalBlockAppear .9s cubic-bezier(.16,.8,.34,1);
}

/* (removed historyTotalPulse; unified with total-animate for summary) */

@keyframes pulse {
    0% {
        transform: scale(0.9);
        box-shadow: 0 0 0 rgba(79, 70, 229, 0);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 10px 25px rgba(79, 70, 229, 0.25);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(79, 70, 229, 0);
    }
}

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

.progress {
    height: 12px;
    background-color: rgba(15, 23, 42, 0.08);
    border-radius: 50px;
    overflow: hidden;
    display: flex;
}

.progress-fill {
    height: 100%;
    width: 0;
    transition: width 1.6s ease-out;
}

.progress-fill:first-child {
    border-top-left-radius: 50px;
    border-bottom-left-radius: 50px;
}

.progress-fill:last-child {
    border-top-right-radius: 50px;
    border-bottom-right-radius: 50px;
}

.history-table {
    border-collapse: separate;
    border-spacing: 0 12px;
}

.history-table tbody tr {
    background: #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
    transition: transform .2s ease, box-shadow .2s ease;
    border-radius: var(--border-radius-md); /* for browsers that honor radius on tr with separated borders */
    overflow: hidden;
}

.history-table tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.12);
}

.history-table tbody tr td {
    border: none;
    padding: 14px 18px;
    vertical-align: middle;
}

.history-table tbody tr.table-warning {
    background: linear-gradient(135deg, rgba(254, 243, 199, 0.92), rgba(253, 230, 138, 0.92));
    box-shadow: 0 12px 28px rgba(250, 204, 21, 0.25);
    border-radius: var(--border-radius-md);
}

/* Реальные скругления ячеек (кроссбраузерно) */
.history-table tbody tr td:first-child {
    border-top-left-radius: var(--border-radius-md);
    border-bottom-left-radius: var(--border-radius-md);
}

.history-table tbody tr td:last-child {
    border-top-right-radius: var(--border-radius-md);
    border-bottom-right-radius: var(--border-radius-md);
}

/* Акцент при редактировании */
.history-table tbody tr.table-warning td:first-child {
    border-top-left-radius: var(--border-radius-md);
    border-bottom-left-radius: var(--border-radius-md);
}
.history-table tbody tr.table-warning td:last-child {
    border-top-right-radius: var(--border-radius-md);
    border-bottom-right-radius: var(--border-radius-md);
}

.history-table .btn-outline-secondary,
.history-table .btn-outline-danger,
.history-table .btn-primary {
    border-radius: 10px;
}

/* Унифицированные икон-кнопки для действий (редактировать / удалить) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    color: var(--text-color);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
    transition: var(--transition-base);
}

.btn-icon svg { width: 18px; height: 18px; stroke-width: 1.8; }

.btn-icon:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.25);
    transform: translateY(-2px);
}

.btn-icon:focus-visible { outline: 3px solid rgba(79,70,229,0.35); outline-offset: 2px; }

.btn-icon.btn-icon-edit:hover svg { stroke: var(--primary-color); }

.btn-icon.btn-icon-danger {
    border-color: rgba(220, 38, 38, 0.25);
    color: #dc2626;
}

.btn-icon.btn-icon-danger:hover {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border-color: #dc2626;
    color: #b91c1c;
    box-shadow: 0 6px 18px rgba(220,38,38,0.35);
}

.btn-icon.btn-icon-danger:hover svg { stroke: #b91c1c; }

.btn-icon:active { transform: translateY(0); }

.history-table tbody tr.table-warning .btn-icon { background: #fff8e1; }

input.form-control, select.form-select, textarea.form-control {
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    padding: 12px 16px;
    transition: var(--transition-base);
}

input.form-control:focus, select.form-select:focus, textarea.form-control:focus {
    box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.25);
    border-color: var(--primary-color);
}

.alert {
    border-radius: 14px;
    border: none;
    box-shadow: var(--shadow-soft);
}

footer.site-footer {
    padding: 30px 0;
    text-align: center;
    color: rgba(15, 23, 42, 0.6);
    font-size: 0.95rem;
}

@media (max-width: 767px) {
    .hero-card {
        padding: 32px;
    }
    main.page-wrapper {
        padding: 32px 0;
    }
}

/* ===== АДАПТИВНЫЕ УРОВНИ КОМПАКТНОСТИ (auto_adapt.js) ===== */
body.auto-compact .navbar-modern .nav-link { padding: 6px 12px !important; }
body.auto-compact-md .navbar-modern .nav-link { font-size: 0.92rem; }
body.auto-compact-sm .navbar-modern .brand-text { display: none !important; }
body.auto-compact-xs .nav-profile .user-name { display: none !important; }
body.auto-compact-xxs .btn.btn-primary { padding: 4px 10px; font-size: 0.75rem; }
body.auto-compact-xxs .navbar-modern .nav-link { padding: 5px 10px !important; font-size: 0.82rem; }

/* Профильное меню: адаптация на очень узких экранах (фиксируем к правому краю) */
@media (max-width: 520px) {
    .nav-profile .dropdown-menu {
        left: auto !important;        /* игнорируем левый край */
        right: 6px !important;        /* прижимаем к правому краю с небольшим полем */
        width: auto !important;       /* естественная ширина */
        min-width: 210px !important;  /* базовая читаемая ширина */
        max-width: calc(100vw - 12px);/* страховка, если экран совсем узкий */
        transform: none !important;   /* убрать translate от popper при ограничении */
        overflow-x: hidden;
        overflow-y: auto;
        max-height: 70vh;             /* чтобы не вылезало ниже экрана */
    }
}

