/* ============================================================
   Дашборд ДАН — оформление
   Расположение: /var/www/dan/public/assets/app.css

   Тёмная тема. Числа выравниваются по разрядам (tabular-nums):
   в таблицах про деньги это важнее выбора гарнитуры.
   ============================================================ */

:root {
    /* Основа — графит, не синевато-чёрный */
    --bg:        #101319;
    --panel:     #171B23;
    --panel-2:   #1D222C;
    --border:    #242B36;
    --border-2:  #303845;

    --text:      #E6EAF0;
    --muted:     #97A1B2;
    --muted-2:   #6B7688;

    /* Сигнальные цвета приглушены: на тёмном неон режет глаз */
    --green:     #3FA97A;
    --green-bg:  rgba(63, 169, 122, .14);
    --yellow:    #D99A3C;
    --yellow-bg: rgba(217, 154, 60, .14);
    --red:       #D95757;
    --red-bg:    rgba(217, 87, 87, .14);
    --grey:      #4A5364;
    --grey-bg:   rgba(74, 83, 100, .18);

    --accent:    #4B7BE5;
    --accent-bg: rgba(75, 123, 229, .12);

    --sidebar-w: 232px;
    --radius:    10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Все числовые значения — моноширинными цифрами */
.num, .kpi-value, table td, .lot-count {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Видимый фокус с клавиатуры — обязателен для доступности */
a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ==================== КАРКАС ==================== */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
}

.brand-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.brand-sub {
    font-size: 12px;
    color: var(--muted-2);
    margin-top: 2px;
}

.nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.nav-group {
    font-size: 11px;
    color: var(--muted-2);
    padding: 0 8px;
    margin: 14px 0 6px;
}

.nav-group:first-child { margin-top: 0; }

.nav a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.3;
    transition: background .12s, color .12s;
}

.nav a:hover {
    background: var(--panel-2);
    color: var(--text);
    text-decoration: none;
}

.nav a.active {
    background: var(--accent-bg);
    color: var(--accent);
}

/* Точка-светофор у пункта меню */
.nav .sig {
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-foot {
    padding: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.user-name { color: var(--text); }
.user-role { color: var(--muted-2); margin-top: 1px; }
.user-out  { color: var(--muted-2); font-size: 12px; margin-top: 6px; display: inline-block; }

/* ==================== ВЕРХНЯЯ ПОЛОСА ==================== */

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.page-sub {
    font-size: 12px;
    color: var(--muted-2);
    margin-top: 2px;
}

.updated {
    font-size: 12px;
    color: var(--muted-2);
    text-align: right;
}

.content { padding: 22px 24px 40px; }

/* ==================== ПЛИТКИ БЛОКОВ ==================== */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.tile {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 16px 14px;
    display: block;
    color: inherit;
}

.tile:hover {
    border-color: var(--border-2);
    text-decoration: none;
}

.tile-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 11px;
}

.tile-name {
    font-size: 12px;
    color: var(--muted);
}

.tile-sig {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: auto;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 25px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -.02em;
}

.kpi-note {
    font-size: 12px;
    color: var(--muted-2);
    margin-top: 5px;
    min-height: 18px;
}

.bar {
    height: 3px;
    background: var(--panel-2);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.bar span {
    display: block;
    height: 100%;
    border-radius: 2px;
}

/* Состояния светофора */
.s-green  { color: var(--green); }
.s-yellow { color: var(--yellow); }
.s-red    { color: var(--red); }
.s-grey   { color: var(--muted-2); }

.bg-green  { background: var(--green); }
.bg-yellow { background: var(--yellow); }
.bg-red    { background: var(--red); }
.bg-grey   { background: var(--grey); }

/* ==================== ПАНЕЛИ ==================== */

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-title { font-size: 14px; font-weight: 600; }
.panel-sub   { font-size: 12px; color: var(--muted-2); }
.panel-body  { padding: 16px; }

.cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

/* ==================== ШАХМАТКА ==================== */
/* Каждая квартира — клетка, цвет по статусу.
   Главный элемент экрана: видно распроданность целиком. */

.chess {
    display: flex;
    gap: 26px;
    flex-wrap: wrap;
}

.chess-building { min-width: 0; }

.chess-title {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.chess-floor {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}

.chess-floor-no {
    width: 20px;
    font-size: 10px;
    color: var(--muted-2);
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.cell {
    width: 15px;
    height: 15px;
    border-radius: 3px;
    flex-shrink: 0;
    cursor: default;
}

.cell-free         { background: var(--green); }
.cell-booked_soft  { background: var(--yellow); }
.cell-booked_paid  { background: var(--yellow); opacity: .65; }
.cell-sold         { background: var(--accent); }
.cell-not_for_sale { background: var(--grey); }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 16px;
    font-size: 12px;
    color: var(--muted);
}

.legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: -1px;
}

/* ==================== ТАБЛИЦЫ ==================== */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    color: var(--muted-2);
    padding: 0 10px 8px 0;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 8px 10px 8px 0;
    border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }

td.r, th.r { text-align: right; padding-right: 0; }

/* ==================== ПУСТЫЕ СОСТОЯНИЯ ==================== */
/* Пустой экран — приглашение к действию, а не извинение */

.empty {
    padding: 22px 16px;
    text-align: center;
    color: var(--muted-2);
    font-size: 13px;
}

.empty strong {
    display: block;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 4px;
}

/* ==================== ВХОД ==================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 340px;
}

.login-title {
    font-size: 19px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -.01em;
}

.login-sub {
    font-size: 13px;
    color: var(--muted-2);
    margin-bottom: 22px;
}

.field { margin-bottom: 12px; }

.field label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 9px 11px;
    background: var(--panel);
    border: 1px solid var(--border-2);
    border-radius: 7px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

input:focus {
    border-color: var(--accent);
    outline: none;
}

button {
    width: 100%;
    padding: 10px;
    background: var(--accent);
    border: none;
    border-radius: 7px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    margin-top: 6px;
}

button:hover { background: #3D6BD1; }

.error {
    background: var(--red-bg);
    border: 1px solid rgba(217, 87, 87, .3);
    color: var(--red);
    padding: 9px 11px;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 14px;
}

/* ==================== ТЕЛЕФОН И ПЛАНШЕТ ==================== */

@media (max-width: 900px) {
    .layout { flex-direction: column; }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .nav {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding: 10px;
    }

    .nav-group { display: none; }

    .nav a { white-space: nowrap; }

    .sidebar-foot {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    .topbar { padding: 14px 16px; }
    .content { padding: 16px; }

    .tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

    .kpi-value { font-size: 21px; }

    .cell { width: 12px; height: 12px; }

    .chess { gap: 18px; }
}

@media (max-width: 520px) {
    .tiles { grid-template-columns: repeat(2, 1fr); }
    .updated { display: none; }
}

/* Уважаем системную настройку «уменьшить движение» */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
