:root {
    --bg: #0f0f12;
    --sidebar: #1a1a1f;
    --card: #1f1f24;
    --text: #e0e0e0;
    --accent: #00ccff;
    --border: #333;
    --stats-bg: #2a2a2f;
    --stats-border: #3a3a42;
    --stats-text: #e0e0e0;
    --stats-bar-bg: #1f1f24;
    --stats-bar: #00cc88;
}

.light {
    --bg: #e8e8e8;
    --sidebar: #e9ecef;
    --card: #f0f0f0;
    --text: #212529;
    --accent: #007bff;
    --border: #dee2e6;
    --stats-bg: #f3f3f3;
    --stats-border: #dee2e6;
    --stats-text: #212529;
    --stats-bar-bg: #e9ecef;
    --stats-bar: #28a745;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Пока права не применены — меню не мигает */
body.menu-pending .menu-item {
    visibility: hidden;
}

h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.5px; }
h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
h3 { font-size: 18px; font-weight: 600; }

.menu-item, button, input, select, textarea {
    font-family: 'SF Pro Display', inherit;
}

th, td, small {
    font-size: 14.5px;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--sidebar);
    border-right: 1px solid #2a2a2f;
    display: flex;
    flex-direction: column;
}

.logo {
    padding: 20px;
    font-size: 26px;
    font-weight: bold;
    color: #fff;
}

.light .logo { color: #212529; }

.logo-text {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.6px;
    color: #ffffff;
    line-height: 1;
    font-family: 'Inter', 'SF Pro Display', -apple-system, sans-serif;
}

.light .logo-text { color: #111111 !important; }

.search {
    margin: 0 20px 20px;
    padding: 10px 14px;
    background: #25252b;
    border: 1px solid #3a3a42;
    border-radius: 8px;
    color: #fff;
}

.light .search {
    background: #fff;
    border-color: #ced4da;
    color: #212529;
}

.menu-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #b0b0b0;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin: 2px 8px;
}

.light .menu-item { color: #495057; }

.menu-item:hover {
    background: #25252b;
    color: #fff;
    transform: translateX(4px);
}

.light .menu-item:hover {
    background: #e9ecef;
    color: #212529;
}

.menu-item.active {
    background: #00ccff;
    color: black;
    font-weight: 600;
}

.light .menu-item.active {
    background: #007bff;
    color: white;
}

/* ===== Main ===== */
.main {
    flex: 1;
    min-width: 0;
    padding: 24px 20px;
    overflow: auto;
}

.card {
    background: var(--card);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    overflow-x: auto;
    max-width: 100%;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

select,
input[type="date"],
input {
    background: #25252b;
    color: #fff;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 6px;
}

/* ===== Modal — текст слева ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1f1f24;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 920px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    text-align: left !important;
}

.light .modal-content {
    background: #fff;
    color: #212529;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #444;
    text-align: left !important;
}

.light .modal-header { border-color: #ddd; }

.modal-header h2 {
    text-align: left !important;
    margin: 0;
    flex: 1;
    padding-right: 36px;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
    text-align: left !important;
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-body h2,
.modal-body h3,
.modal-body p,
.modal-body div,
.modal-body span,
.modal-body label,
.modal-body pre,
.modal-body li {
    text-align: left !important;
}

.modal-footer {
    padding: 20px 0 0;
    border-top: 1px solid #444;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: transparent;
    text-align: right !important;
}

.light .modal-footer { border-color: #ddd; }

.close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 32px;
    cursor: pointer;
    color: #888;
    line-height: 1;
    z-index: 2;
}

.light .close-btn { color: #666; }
.close-btn:hover { color: #ff3b5c; }

/* Theme toggle */
.theme-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 26px;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #333;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background: #00ccff; }
input:checked + .slider:before { transform: translateX(26px); }

/* Action row */
.action-row {
    display: grid;
    grid-template-columns: 70px 1fr 80px;
    gap: 12px;
    align-items: center;
    background: #25252b;
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.light .action-row { background: #f8f9fa; }

.light .action-row input {
    background: #f0f0f0 !important;
    color: #222 !important;
    border: 1px solid #ccc !important;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Tables */
table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    background: #1f1f24;
    border-radius: 8px;
    overflow: hidden;
    table-layout: auto;
}

.light table { background: #fff; }

th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #2a2a2f;
    vertical-align: top;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.light th, .light td { border-color: #dee2e6; }

th {
    background: #25252b;
    font-weight: 600;
}

.light th {
    background: #e9ecef;
    color: #212529;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Stats cards */
.light .stat-card {
    background: #f0f0f0 !important;
    color: #222 !important;
}

.light #statsCard {
    background: #f8f8f8 !important;
    color: #222 !important;
}

.light #totalPoints,
.light #workDays,
.light #avgPerDay,
.light #earnedMoney,
.light .stat-card h3 {
    color: #111 !important;
}

.light .stat-card small { color: #555 !important; }

.light #employeesList strong[style*="#00ff9d"],
.light #employeesList strong[style*="#00ccff"],
.light #employeesList strong[style*="#ffcc00"] {
    color: #111 !important;
}

/* Manual modal date selects */
.light select#manualDay,
.light select#manualMonth,
.light select#manualYear {
    background: #f8f8f8 !important;
    color: #222 !important;
    border: 1px solid #bbb !important;
}

.light [style*="position:sticky;bottom:0"] {
    background: #f0f0f0 !important;
    border-top: 1px solid #ddd !important;
    color: #222 !important;
}

.light [style*="position:sticky;bottom:0"] label {
    color: #333 !important;
}

.light #periodCard {
    background: #f8f8f8 !important;
    color: #222 !important;
}

.light #periodCard select {
    background: #f0f0f0 !important;
    color: #222 !important;
    border: 1px solid #bbb !important;
}

/* Login / register */
.login-logo-text {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.8px;
    color: #f2f2f2;
    line-height: 1;
}

.light .login-logo-text { color: #111111 !important; }

.login-slogan {
    font-size: 13px;
    color: #888;
    letter-spacing: 0.02em;
    margin-bottom: 14px;
}

.light .login-slogan { color: #666; }

.light input[type="text"],
.light input[type="email"],
.light input[type="password"],
.light select {
    background: #f3f3f3 !important;
    color: #111111 !important;
    border: 1px solid #ccc !important;
}

.light input[type="text"]::placeholder,
.light input[type="email"]::placeholder,
.light input[type="password"]::placeholder {
    color: #888 !important;
}

.light select option {
    background: #fff;
    color: #111;
}

#manualComment {
    width: 100%;
    height: 80px;
    background: #25252b !important;
    color: #e0e0e0 !important;
    border: 1px solid #555 !important;
    border-radius: 8px;
    padding: 10px;
    resize: vertical;
    font-family: inherit;
}

.light #manualComment {
    background: #f3f3f3 !important;
    color: #212529 !important;
    border: 1px solid #ccc !important;
}

/* Tasks */
.task-type {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.task-type.оценка { background: #3b82f6; color: white; }
.task-type.переоценка { background: #8b5cf6; color: white; }
.task-type.приоритетная-задача { background: #ef4444; color: white; }
.task-type.индивидуальная-задача { background: #eab308; color: black; }

.status {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    display: inline-block;
    min-width: auto;
    white-space: nowrap;
}

.status.готово { background: #22c55e; color: white; }
.status.в-работе { background: #eab308; color: black; }
.status.отмена { background: #ef4444; color: white; }

@keyframes notificationPulse {
    0%   { transform: scale(1); background: #ef4444; }
    50%  { transform: scale(1.3); background: #ff0000; }
    100% { transform: scale(1); background: #ef4444; }
}

.notification-flash {
    animation: notificationPulse 1.2s ease-in-out 3;
}

/* Date input */
input[type="date"] {
    color-scheme: dark;
    background: #333 !important;
    color: #fff !important;
    border: 1px solid #555 !important;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.2);
    cursor: pointer;
    opacity: 1;
}

.light input[type="date"] {
    color-scheme: light;
    background: #f3f3f3 !important;
    color: #111 !important;
    border: 1px solid #ccc !important;
}

.light input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

/* Assessment brands */
.brand-toggle-btn {
    background: #2a2a32;
    border: 1px solid #444;
    color: #ddd;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    max-width: min(280px, 100%);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-panel {
    display: none;
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    z-index: 200;
    min-width: 260px;
    max-width: min(420px, 90vw);
    max-height: 280px;
    overflow-y: auto;
    padding: 12px;
    background: #1f1f24;
    border: 1px solid #444;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.brand-panel.open-up {
    top: auto;
    bottom: calc(100% + 6px);
}

.brand-panel-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.brand-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #2a2a32;
    border: 1px solid #3a3a45;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 14px;
    line-height: 1.2;
}

.brand-chip-name {
    color: #e0e0e0;
    font-weight: 600;
    font-size: 14px;
}

.brand-chip-count {
    background: #00ff9d22;
    color: #00ff9d;
    font-weight: 700;
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 13px;
    min-width: 32px;
    text-align: center;
}

.light .brand-toggle-btn {
    background: #e8e8ec !important;
    border-color: #c8c8d0 !important;
    color: #111 !important;
}

.light .brand-panel {
    background: #f0f0f3 !important;
    border-color: #c8c8d0 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
}

.light .brand-chip {
    background: #e8e8ec !important;
    border-color: #c8c8d0 !important;
}

.light .brand-chip-name {
    color: #111 !important;
    font-weight: 600;
}

.light .brand-chip-count {
    background: #d4efdf !important;
    color: #0a6b42 !important;
}

/* Assessment sidebar widget */
.assess-side-card {
    background: #25252b;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.35;
}

.light .assess-side-card {
    background: #f0f0f3;
    border-color: #d0d0d8;
    color: #111;
}

.assess-side-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
    margin-bottom: 6px;
    font-weight: 600;
}

.light .assess-side-title { color: #666; }

.assess-side-total {
    font-size: 24px;
    font-weight: 700;
    color: #00ff9d;
    margin-bottom: 8px;
}

.light .assess-side-total { color: #0a6b42; }

.assess-side-brands {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
}

.assess-side-chip {
    background: #2a2a32;
    border: 1px solid #3a3a45;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 13px;
    color: #e8e8e8;
    white-space: nowrap;
    font-weight: 500;
}

.light .assess-side-chip {
    background: #e8e8ec;
    border-color: #c8c8d0;
    color: #111;
}

.assess-side-chip b {
    color: #00ff9d;
    margin-left: 5px;
    font-size: 14px;
    font-weight: 700;
}

.light .assess-side-chip b { color: #0a6b42; }

/* Stats tiles / Board */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.stats-tile {
    position: relative;
    min-height: 160px;
    padding: 22px 20px;
    border-radius: 14px;
    background: var(--card);
    border: 1px solid var(--border, #333);
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    text-align: left;
}

.stats-tile:hover {
    transform: translateY(-3px);
    border-color: #00ccff;
    box-shadow: 0 8px 24px rgba(0, 204, 255, 0.12);
}

.stats-tile-icon {
    position: absolute;
    right: 12px;
    bottom: 8px;
    opacity: 0.12;
    color: #00ccff;
    pointer-events: none;
    transform: scale(1.8);
    transform-origin: bottom right;
}

.stats-tile-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
    text-align: left;
}

.stats-tile-desc {
    font-size: 13px;
    color: #888;
    line-height: 1.4;
    position: relative;
    z-index: 1;
    max-width: 85%;
    text-align: left;
}

.stats-tile-disabled {
    opacity: 0.55;
    cursor: default;
}

.stats-tile-disabled:hover {
    transform: none;
    border-color: var(--border, #333);
    box-shadow: none;
}

.light .stats-tile { border-color: #dee2e6; }

.light .stats-tile:hover {
    border-color: #007bff;
    box-shadow: 0 8px 24px rgba(0, 123, 255, 0.1);
}

.light .stats-tile-icon { color: #007bff; }

#boardGrid .stats-tile {
    min-height: 180px;
    padding: 24px 22px;
    text-align: left;
}

#boardGrid .stats-tile-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 10px;
}

#boardGrid .stats-tile-desc {
    font-size: 15px;
    line-height: 1.45;
    max-width: 90%;
}

#boardViewModal .board-view-text {
    display: block;
    width: 100%;
    text-align: left !important;
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 16px;
    word-break: break-word;
    margin: 0;
    padding: 0;
}

#boardEditModal input[type="text"],
#boardEditModal input[type="file"],
#boardEditModal select,
#boardEditModal textarea {
    background: #333 !important;
    color: #fff !important;
    border: 1px solid #555 !important;
}

.light #boardEditModal input[type="text"],
.light #boardEditModal input[type="file"],
.light #boardEditModal select,
.light #boardEditModal textarea {
    background: #f0f0f0 !important;
    color: #111 !important;
    border: 1px solid #ccc !important;
}

.light #boardEditModal .modal-body label { color: #222 !important; }

.light #boardEditModal #boardFilesList > div {
    background: #f3f3f3 !important;
    border-color: #ddd !important;
    color: #111 !important;
}

.light #boardEditModal small { color: #666 !important; }

/* Responsive */
@media (max-width: 1400px) {
    .sidebar {
        width: 220px;
        min-width: 220px;
    }

    .main { padding: 18px 14px; }

    th, td {
        padding: 10px 8px;
        font-size: 13.5px;
    }

    h1 { font-size: 24px; }
    h2 { font-size: 18px; }
}

@media (max-width: 1280px) {
    .sidebar {
        width: 200px;
        min-width: 200px;
    }

    .logo {
        font-size: 22px;
        padding: 14px 16px;
    }

    .menu-item {
        padding: 10px 14px;
        margin: 2px 6px;
        font-size: 14px;
    }

    .main { padding: 14px 12px; }

    .card {
        padding: 14px;
        margin-bottom: 16px;
    }

    #statsCard [style*="grid-template-columns"] {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
        gap: 8px !important;
    }

    .stat-card h3 { font-size: 20px !important; }
}

@media (max-width: 1024px) {
    body {
        flex-direction: column;
        height: auto;
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid #2a2a2f;
        max-height: 48vh;
        overflow-y: auto;
    }

    .light .sidebar { border-bottom-color: #dee2e6; }

    .main { padding: 12px; }

    table { min-width: 640px; }
}
/* Модалки: текст строго слева, без центрирования */
.modal .modal-content {
    text-align: left !important;
    align-items: stretch !important;
}

.modal .modal-header,
.modal .modal-header h2 {
    text-align: left !important;
    justify-content: flex-start !important;
}

.modal .modal-body {
    display: block !important;
    text-align: left !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    white-space: normal !important;
}

.modal .modal-body * {
    text-align: left !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.modal .modal-footer {
    display: flex !important;
    justify-content: flex-end !important;
    text-align: right !important;
}

.modal .modal-footer * {
    text-align: center !important; /* кнопки */
}

/* Настройки ЗП — поля */
.salary-input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #555;
    background: #333;
    color: #fff;
    box-sizing: border-box;
}

.light .salary-input {
    background: #f3f3f3 !important;
    color: #111 !important;
    border: 1px solid #ccc !important;
}

.light #salaryModal label {
    color: #222 !important;
}

.light #salaryModal .modal-body p {
    color: #666 !important;
}

.light #salaryModal .modal-footer {
    border-top-color: #ddd !important;
}