/* ============================================================
   Hostmon — темы и вёрстка. Темы через CSS-переменные:
   :root[data-theme="dark"] / [data-theme="light"].
   ============================================================ */

* { box-sizing: border-box; }

:root, :root[data-theme="dark"] {
    --bg:        #0f1420;
    --panel:     #161d2c;
    --panel-2:   #1c2537;
    --border:    #2a3550;
    --text:      #dbe4f5;
    --muted:     #8494b3;
    --accent:    #4da3ff;
    --ok:        #3ecf8e;
    --danger:    #ff6161;
    --chart-grid:#27324c;
    --shadow:    0 8px 28px rgba(0,0,0,.5);
    --titlebar:  #1a2334;
}

:root[data-theme="light"] {
    --bg:        #eef1f6;
    --panel:     #ffffff;
    --panel-2:   #f5f7fb;
    --border:    #d4dbe8;
    --text:      #1c2436;
    --muted:     #5b6880;
    --accent:    #1f6fd6;
    --ok:        #178a5e;
    --danger:    #d63c3c;
    --chart-grid:#dde3ee;
    --shadow:    0 8px 24px rgba(30,45,80,.18);
    --titlebar:  #f7f9fc;
}

html, body { height: 100%; }
body {
    margin: 0;
    font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }

/* ---------- кнопки / формы ---------- */
.btn, button {
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 12px;
    cursor: pointer;
}
.btn:hover, button:hover { border-color: var(--accent); }
.btn.small { padding: 2px 8px; font-size: 12.5px; }
.btn.danger { color: var(--danger); }
.btn-link { background: none; border: none; color: var(--muted); padding: 4px 6px; }
.btn-link:hover { color: var(--accent); border-color: transparent; }

input, select {
    font: inherit;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.alert {
    background: rgba(255, 97, 97, .12);
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 14px;
}
.alert.ok { background: rgba(62, 207, 142, .1); border-color: var(--ok); color: var(--ok); }

/* ---------- логин ---------- */
.login-body { justify-content: center; align-items: center; overflow: auto; }
.login-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 34px 38px;
    width: 340px;
}
.login-card h1 { margin: 0 0 2px; font-size: 24px; }
.login-card p { margin: 0 0 20px; }
.login-card label { display: block; margin-top: 14px; color: var(--muted); font-size: 13px; }
.login-card input { width: 100%; margin-top: 5px; padding: 8px 10px; }
.login-card button[type=submit] { width: 100%; margin-top: 20px; padding: 9px; background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }

/* ---------- верхняя панель ---------- */
.topbar {
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; }
.top-right { display: flex; align-items: center; gap: 8px; }

/* ---------- каркас дашборда ---------- */
.layout { flex: 1; display: flex; min-height: 0; }

.sidebar {
    flex: 0 0 216px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 12px 10px;
    overflow-y: auto;
}
.side-heading {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin: 14px 6px 6px;
}
.side-heading:first-child { margin-top: 2px; }
.sidebar button.menu-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 1px solid transparent;
    padding: 7px 10px;
    margin-bottom: 2px;
    border-radius: 6px;
}
.sidebar button.menu-item:hover { background: var(--panel-2); border-color: var(--border); }
#open-list { list-style: none; margin: 0; padding: 0; }
#open-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
}
#open-list li:hover { background: var(--panel-2); }
#open-list li.minimized { color: var(--muted); font-style: italic; }

.grid { flex: 1; position: relative; overflow: hidden; min-width: 0; }

/* ---------- окна ---------- */
.win {
    position: absolute;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-width: 340px;
    min-height: 260px;
}
.win-titlebar {
    height: 38px;
    flex: 0 0 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    background: var(--titlebar);
    border-bottom: 1px solid var(--border);
    border-radius: 7px 7px 0 0;
    cursor: move;
    user-select: none;
}
.win-title { font-weight: 600; white-space: nowrap; }
.win-latest { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.win-titlebar select { padding: 2px 6px; font-size: 12.5px; max-width: 130px; }
.win-buttons { display: flex; gap: 4px; margin-left: auto; }
.win-buttons button {
    width: 26px; height: 24px;
    padding: 0; line-height: 1;
    background: none; border-color: transparent;
    color: var(--muted); font-size: 15px;
}
.win-buttons button:hover { color: var(--text); border-color: var(--border); }

.win-body { flex: 1; position: relative; min-height: 0; padding: 8px; overflow: auto; display: flex; flex-direction: column; }
.chart-wrap { position: relative; width: 100%; flex: 1; min-height: 0; }
.win-footer { color: var(--muted); font-size: 12px; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 0 auto; }

/* свёрнутое окно — только заголовок */
.win.minimized .win-body, .win.minimized .win-resize { display: none; }
.win.minimized { min-height: 0; height: 38px !important; border-radius: 7px; }
.win.minimized .win-titlebar { cursor: pointer; border-bottom: none; border-radius: 7px; height: auto; flex-basis: auto; padding-top: 6px; padding-bottom: 6px; }

/* ручка изменения размера (правый нижний угол) */
.win-resize {
    position: absolute;
    right: 0; bottom: 0;
    width: 18px; height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, var(--muted) 50%);
    opacity: .45;
    border-radius: 0 0 7px 0;
}

/* ---------- IPMI: сетка мини-графиков ---------- */
.ipmi-pick summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.ipmi-checks { max-height: 130px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
.sensor-label { display: block; font-size: 12.5px; }
.ping-status { max-height: 40%; overflow: auto; margin-bottom: 8px; flex: 0 0 auto; }
.ipmi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; flex: 1; min-height: 0; align-content: start; overflow-y: auto; margin-top: 6px; }
.ipmi-cell { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; display: flex; flex-direction: column; min-height: 150px; }
.ipmi-cell .ipmi-name { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.ipmi-cell .ipmi-val { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.ipmi-cell .chart-wrap { flex: 1; min-height: 70px; }

/* ---------- VPN / ping: таблицы ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.table tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 9px; font-size: 11.5px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); margin-right: 6px; }
.rtt-ok { color: var(--ok); }
.rtt-bad { color: var(--danger); }

/* ---------- страница пользователей ---------- */
.page-body { overflow: auto; display: block; }
.page-main { max-width: 900px; margin: 26px auto; padding: 0 16px; }
.page-main h1 { font-size: 22px; margin: 0 0 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.form-inline { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.form-inline label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13px; }
.actions { white-space: nowrap; }
.inline-form summary { cursor: pointer; color: var(--accent); font-size: 12.5px; margin-right: 8px; }
.inline-form form { display: inline-flex; gap: 6px; align-items: center; vertical-align: middle; }
.back-link { color: inherit; font-weight: 700; }
