/* ═══════════════════════════════════════════════════════
   styles.css - Тёмная тема учётной системы
   ═══════════════════════════════════════════════════════ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0d1117;
    --bg-2: #161b22;
    --bg-3: #1c2128;
    --border: #2d3a2d;
    --border-2: #30363d;
    --text: #e6edf3;
    --text-dim: #8b949e;
    --green: #4a6a3a;
    --green-hi: #5c8a48;
    --red: #f85149;
    --orange: #f0883e;
    --yellow: #d29922;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-3);
    color: var(--text);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    padding: 8px 12px;
    width: 100%;
    outline: none;
    transition: border .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--green-hi); }
input.error, select.error, textarea.error { border-color: var(--red); }
textarea { resize: vertical; min-height: 70px; }

/* ═══════════════ HEADER ═══════════════ */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border-2);
    position: sticky;
    top: 0;
    z-index: 100;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 22px; }
.logo-text { font-weight: 600; font-size: 15px; }
.logo-ver { font-size: 11px; color: var(--text-dim); }
.sync-status {
    font-size: 11px;
    color: var(--green-hi);
    background: rgba(74, 106, 58, .2);
    padding: 2px 8px;
    border-radius: 10px;
}
.sync-status.offline { color: var(--orange); background: rgba(240, 136, 62, .2); }

.top-actions { display: flex; align-items: center; gap: 8px; }
.user-badge {
    font-size: 12px;
    padding: 4px 10px;
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    border-radius: 16px;
}
.icon-btn {
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    color: var(--text);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.icon-btn:hover { background: var(--border); }

.badge-notif {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red);
    color: white;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ═══════════════ NOTIF / REFS PANELS ═══════════════ */
.notif-panel, .refs-panel {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 380px;
    max-height: 70vh;
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .6);
    padding: 12px;
    z-index: 200;
    display: none;
    overflow: hidden;
}
.notif-panel.active, .refs-panel.active { display: block; }
.refs-panel { width: 720px; max-width: calc(100vw - 40px); }

.notif-header, .refs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-2);
    margin-bottom: 8px;
    font-weight: 600;
}
.notif-list, .refs-grid { max-height: 55vh; overflow-y: auto; }

.notif-item {
    padding: 8px;
    border-bottom: 1px solid var(--border-2);
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.notif-item .time { font-size: 10px; color: var(--text-dim); display: block; margin-top: 2px; }
.notif-item .dismiss { background: none; border: none; color: var(--red); font-size: 14px; padding: 0 4px; }
.notif-item.critical { color: var(--red); }
.notif-item.warning { color: var(--orange); }

/* ═══════════════ MAIN SCREEN (tiles) ═══════════════ */
#mainScreen {
    padding: 40px 20px;
    max-width: 1400px;
    margin: 0 auto;
}
.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.tile {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 12px;
    padding: 24px 20px;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 130px;
    position: relative;
}
.tile:hover {
    border-color: var(--green-hi);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.tile-icon { font-size: 40px; margin-bottom: 8px; }
.tile-name { font-weight: 600; font-size: 15px; }
.tile-count { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.tile-lock { position: absolute; top: 10px; right: 12px; font-size: 14px; opacity: .6; }
.tile-badge {
    position: absolute;
    top: 8px;
    right: 10px;
    background: var(--red);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}

/* ═══════════════ TABS ═══════════════ */
.tabs-wrapper { display: none; }
.tabs-wrapper.active { display: block; }

.tabs-bar {
    display: flex;
    gap: 4px;
    padding: 8px 20px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border-2);
    overflow-x: auto;
    white-space: nowrap;
}
.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
}
.tab-btn:hover { background: var(--bg-3); color: var(--text); }
.tab-btn.active {
    background: var(--green);
    color: white;
    border-color: var(--green-hi);
}

.tab-content { display: none; padding: 16px 20px; max-width: 1400px; margin: 0 auto; }
.tab-content.active { display: block; }

/* ═══════════════ STAT CARDS ═══════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}
.stat-num { display: block; font-size: 26px; font-weight: 700; }
.stat-num.green { color: var(--green-hi); }
.stat-num.red { color: var(--red); }
.stat-num.orange { color: var(--orange); }
.stat-num.yellow { color: var(--yellow); }
.stat-label { font-size: 11px; color: var(--text-dim); margin-top: 4px; display: block; }

/* ═══════════════ FILTERS ═══════════════ */
.filters {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}
.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 13px;
}
.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}
.filter-row:last-child { margin-bottom: 0; }

/* ═══════════════ TABLE ═══════════════ */
.table-card {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-3);
    border-bottom: 1px solid var(--border-2);
    font-weight: 600;
    font-size: 13px;
}
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
thead th {
    background: var(--bg-3);
    color: var(--text-dim);
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    font-size: 11px;
    letter-spacing: .3px;
    border-bottom: 1px solid var(--border-2);
    white-space: nowrap;
}
tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--bg-3);
    white-space: nowrap;
}
tbody tr:hover { background: var(--bg-3); }
tbody tr:last-child td { border-bottom: none; }

.clickable { cursor: pointer; font-size: 16px; }
.clickable:hover { color: var(--green-hi); }

/* ═══════════════ BADGES ═══════════════ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-green { background: rgba(74, 106, 58, .3); color: #7ec26b; }
.badge-red { background: rgba(248, 81, 73, .2); color: #ff7a72; }
.badge-orange { background: rgba(240, 136, 62, .2); color: #ffab5c; }
.badge-yellow { background: rgba(210, 153, 34, .2); color: #e0b84a; }

/* ═══════════════ BUTTONS ═══════════════ */
.btn-small {
    background: var(--bg-3);
    color: var(--text);
    border: 1px solid var(--border-2);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: 12px;
    transition: all .15s;
}
.btn-small:hover { background: var(--border); }
.btn-small.primary {
    background: var(--green);
    border-color: var(--green-hi);
    color: white;
}
.btn-small.primary:hover { background: var(--green-hi); }
.btn-small.danger {
    background: rgba(248, 81, 73, .15);
    border-color: var(--red);
    color: var(--red);
}

.btn-primary {
    background: var(--green);
    border: 1px solid var(--green-hi);
    color: white;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}
.btn-primary:hover { background: var(--green-hi); }

.btn-secondary {
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    color: var(--text);
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
}
.btn-secondary:hover { background: var(--border); }

/* ═══════════════ BOTTOM ACTIONS ═══════════════ */
.bottom-actions {
    display: flex;
    gap: 10px;
    padding: 12px 20px;
    background: var(--bg-2);
    border-top: 1px solid var(--border-2);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
}
.btn-sync, .btn-export {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    color: white;
}
.btn-sync { background: var(--green); }
.btn-sync:hover { background: var(--green-hi); }
.btn-sync.active { opacity: .6; }
.btn-export { background: #1f4a6a; }
.btn-export:hover { background: #2a5f88; }

/* ═══════════════ AUTH MODAL ═══════════════ */
.auth-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .75);
    backdrop-filter: blur(4px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.auth-overlay.active { display: flex; }

.auth-box {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 12px;
    padding: 26px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .8);
}
.auth-title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.auth-sub { font-size: 12px; color: var(--text-dim); margin-bottom: 18px; }
.auth-box select, .auth-box input { margin-bottom: 12px; }
.auth-error {
    display: none;
    color: var(--red);
    font-size: 12px;
    margin-bottom: 12px;
    padding: 6px 10px;
    background: rgba(248, 81, 73, .1);
    border-radius: 6px;
}
.auth-error.show { display: block; }
.auth-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-auth {
    flex: 1;
    background: var(--green);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
}
.btn-auth:hover { background: var(--green-hi); }
.btn-cancel {
    flex: 1;
    background: var(--bg-3);
    color: var(--text);
    border: 1px solid var(--border-2);
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
}
.btn-cancel:hover { background: var(--border); }

/* ═══════════════ MODAL (общий) ═══════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .75);
    z-index: 9000;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 12px;
    width: 100%;
    max-width: 620px;
    padding: 20px;
    margin: auto 0;
}
.modal-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-2);
}
.form-group { margin-bottom: 12px; }
.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.form-group .required { color: var(--red); }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
@media (max-width: 500px) {
    .form-row { grid-template-columns: 1fr; }
}
.validation-error {
    display: none;
    color: var(--red);
    font-size: 11px;
    margin-top: 4px;
}
.validation-error.show { display: block; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border-2);
    flex-wrap: wrap;
}

/* ═══════════════ CARD (внутри модалки) ═══════════════ */
.car-card, .weapon-card {
    background: var(--bg-3);
    border-radius: 8px;
    padding: 12px;
}
.field {
    display: flex;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-2);
    font-size: 12px;
    gap: 8px;
}
.field .label { color: var(--text-dim); width: 140px; flex-shrink: 0; }
.field .value { color: var(--text); flex: 1; }

/* ═══════════════ HISTORY LIST ═══════════════ */
.history-list, .history-log-list {
    padding: 10px 16px;
    max-height: 70vh;
    overflow-y: auto;
}

/* ═══════════════ TOAST ═══════════════ */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    color: var(--text);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 10000;
    box-shadow: 0 6px 30px rgba(0, 0, 0, .5);
    transition: all .3s;
    max-width: 90vw;
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.sync { border-color: var(--green-hi); color: var(--green-hi); }

/* ═══════════════ SCROLLBAR ═══════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--green); }

/* ═══════════════ MOBILE ═══════════════ */
@media (max-width: 700px) {
    .logo-text { font-size: 13px; }
    .logo-ver, .sync-status { display: none; }
    .notif-panel { width: calc(100vw - 20px); right: 10px; }
    .tabs-bar { padding: 6px 10px; }
    .tab-content { padding: 12px 10px; }
    #mainScreen { padding: 20px 12px; }
    .field .label { width: 100px; font-size: 11px; }
}
