/* --- General Styles --- */
:root {
    --bg-0: #070707;
    --bg-1: #121212;
    --bg-2: #1a1a1a;
    --text-main: #ececec;
    --text-muted: #9a9a9a;
    --line: #2c2c2c;
    --accent: #d6d6d6;
    --accent-2: #b8b8b8;
    --danger: #ff6b6b;
    /* Кнопки: длительность и «вжатие» — настраивается здесь */
    --btn-transition-duration: 0.22s;
    --btn-transition-press: 0.09s;
    --btn-press-scale: 0.97;
    --btn-hover-lift: -2px;
}

html {
    /* Предотвращает изменение размера текста при повороте в iOS */
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", "Roboto", sans-serif;
    background: radial-gradient(900px 500px at 80% -5%, #1b1b1b 0%, transparent 55%), var(--bg-0);
    color: var(--text-main);
}

body.mx-spa-body {
    min-height: 100vh;
}

.mx-app-root {
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    backdrop-filter: blur(8px);
    /* Выше таблицы; ниже модалок (1000). Меню профиля — portal z-index 1100. */
    position: relative;
    z-index: 950;
    overflow: visible;
}

.header-row h1 {
    min-width: 0;
    flex: 1 1 auto;
    margin: 0 12px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-sync-indicator {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    white-space: nowrap;
    user-select: none;
}

.live-sync-indicator--live {
    color: #7dffc8;
    border-color: rgba(0, 255, 156, 0.35);
    background: rgba(0, 255, 156, 0.08);
}

.live-sync-indicator--syncing {
    color: #c8d4ff;
    border-color: rgba(120, 180, 255, 0.35);
    background: rgba(120, 180, 255, 0.08);
    animation: live-sync-pulse 1.4s ease-in-out infinite;
}

.live-sync-indicator--offline {
    color: #999;
    border-color: #444;
    background: rgba(255, 255, 255, 0.04);
}

@keyframes live-sync-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.55;
    }
}

@keyframes highlight-yellow {
    0% { background-color: rgba(255, 255, 0, 0.7); }
    100% { background-color: transparent; }
}

.row-updated {
    animation: highlight-yellow 1s ease-out;
}

h1 {
    text-align: center;
    margin: 0;
    font-size: 18px;
    letter-spacing: 0.08em;
    color: #e4e4e4;
}

/* --- Main Timing Table --- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(15, 15, 15, 0.9);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}

thead {
    background: linear-gradient(180deg, #1f1f1f 0%, #171717 100%);
}

th {
    padding: 10px;
    text-align: left;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--line);
}

td {
    padding: 12px 10px;
    border-bottom: 1px solid #222;
    font-size: 16px;
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    background: rgba(255, 255, 255, 0.04);
}

.driver {
    font-weight: 700;
    letter-spacing: 0.04em;
}

.best {
    color: var(--accent);
    font-weight: 700;
}

/* --- Status Indicators --- */
.status {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.online {
    background-color: #00ff9c;
    box-shadow: 0 0 0 4px rgba(0, 255, 156, 0.16);
}

.offline {
    background-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(255, 92, 124, 0.14);
}

/* --- Buttons --- */
.header-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.btn-demo {
    background: linear-gradient(180deg, #2a2a2a 0%, #1f1f1f 100%);
    color: white;
    border: 1px solid #3c3c3c;
    padding: 9px 16px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition:
        transform var(--btn-transition-duration) cubic-bezier(0.33, 1, 0.68, 1),
        box-shadow var(--btn-transition-duration) ease,
        background var(--btn-transition-duration) ease,
        border-color var(--btn-transition-duration) ease,
        filter var(--btn-transition-duration) ease;
}

.btn-demo:hover {
    transform: translateY(var(--btn-hover-lift));
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.48);
    border-color: #8f8f8f;
    filter: brightness(1.1);
}

.btn-demo:active {
    transform: translateY(0) scale(var(--btn-press-scale));
    box-shadow:
        inset 0 5px 16px rgba(0, 0, 0, 0.55),
        0 2px 8px rgba(0, 0, 0, 0.3);
    border-color: #2a2a2a;
    filter: brightness(0.9);
    transition-duration: var(--btn-transition-press);
}

/* Синяя кнопка настроек */
.btn-settings {
    background: linear-gradient(180deg, #3a3a3a 0%, #2b2b2b 100%);
    border-color: #4c4c4c;
}

.btn-settings:hover {
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.52);
    border-color: #9a9a9a;
    filter: brightness(1.12);
}

.btn-settings:active {
    filter: brightness(0.88);
}

/* Профиль: аватар + выпадающее меню */
.header-profile-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    z-index: 2;
    overflow: visible;
}

.btn-profile-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 40px;
    padding: 0;
}

.btn-profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(145deg, #3d5a5a 0%, #1e3030 100%);
    color: #e8fff4;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.header-profile-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 180px;
    padding: 6px;
    border-radius: 12px;
    background: #161616;
    border: 1px solid #3a3a3a;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
    z-index: 1100;
}

/* page1: меню в document.body — поверх шторки секундомера и таблицы */
.header-profile-dropdown--portal {
    position: fixed;
    z-index: 1100;
}

.timing-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.header-profile-dd-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #e0e0e0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.header-profile-dd-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.header-profile-dd-item.danger {
    color: #ff8a9a;
}

.header-profile-dd-item.danger:hover {
    background: rgba(255, 90, 110, 0.12);
}


.btn-save {
    background: linear-gradient(180deg, #3a3a3a 0%, #2b2b2b 100%);
    color: white;
    border: 1px solid #4c4c4c;
    padding: 8px 15px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-family: "Inter", "Segoe UI", sans-serif;
    transition:
        transform var(--btn-transition-duration) cubic-bezier(0.33, 1, 0.68, 1),
        box-shadow var(--btn-transition-duration) ease,
        border-color var(--btn-transition-duration) ease,
        filter var(--btn-transition-duration) ease;
}

.btn-save:hover {
    transform: translateY(var(--btn-hover-lift));
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
    border-color: #9a9a9a;
    filter: brightness(1.1);
}

.btn-save:active {
    transform: translateY(0) scale(var(--btn-press-scale));
    box-shadow:
        inset 0 5px 16px rgba(0, 0, 0, 0.55),
        0 2px 8px rgba(0, 0, 0, 0.28);
    border-color: #353535;
    filter: brightness(0.9);
    transition-duration: var(--btn-transition-press);
}

.admin-input {
    /* width: 100% !important; */
    box-sizing: border-box !important; /* Гарантирует одинаковую ширину */
    background: #111;
    border: 1px solid #303030;
    color: #ececec;
    padding: 10px 12px;
    border-radius: 10px;
    font-family: "Inter", "Segoe UI", sans-serif;
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s ease;
    display: block;
}

.admin-input:focus {
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* Автозаполнение Chrome */
input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #1a1a1a inset !important;
    -webkit-text-fill-color: #00ff9c !important;
    font-family: monospace !important;
}