/* RMS Ops Console — дизайн-система §10.1 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root,
[data-theme="dark-ops"] {
    --bg: #0A0B0F;
    --surface: #12141C;
    --surface-2: #171A24;
    --border: #232838;
    --text: #E6E9F2;
    --muted: #8B93A7;
    --accent: #7C5CFF;
    --accent-2: #22D3EE;
    --ok: #22C55E;
    --warn: #F59E0B;
    --danger: #EF4444;
    --radius: 13px;
    --radius-sm: 10px;
    --shadow: 0 18px 50px rgba(0, 0, 0, .45);
    --glass: rgba(23, 26, 36, .72);
    --font: 'Inter', 'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

[data-theme="midnight"] {
    --bg: #05060B;
    --surface: #0B0E18;
    --surface-2: #101425;
    --border: #1B2140;
    --text: #DCE2F5;
    --muted: #7C86A8;
    --accent: #8B5CF6;
    --accent-2: #38BDF8;
    --glass: rgba(16, 20, 37, .78);
}

[data-theme="light"] {
    --bg: #F6F7FB;
    --surface: #FFFFFF;
    --surface-2: #F0F2F8;
    --border: #DCE0EC;
    --text: #151824;
    --muted: #6B7280;
    --accent: #6D4AFF;
    --accent-2: #0891B2;
    --shadow: 0 18px 50px rgba(16, 24, 40, .12);
    --glass: rgba(255, 255, 255, .82);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- каркас ---------- */
.app-shell { display: flex; min-height: 100vh; }

.rail {
    width: 64px;
    flex: 0 0 64px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 20;
}

.rail-brand {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: 15px;
}

.rail-nav { display: flex; flex-direction: column; gap: 6px; }

.rail-item {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 17px;
    transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.rail-item:hover { background: var(--surface-2); color: var(--text); transform: translateY(-1px); }
.rail-item.active { background: rgba(124, 92, 255, .16); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(124, 92, 255, .35); }

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

.topbar {
    height: 58px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--glass);
    backdrop-filter: blur(12px);
    position: sticky; top: 0; z-index: 15;
}

.search-box {
    display: flex; align-items: center; gap: 12px;
    min-width: 280px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color .18s var(--ease);
}
.search-box:hover { border-color: var(--accent); }
kbd {
    margin-left: auto;
    font-family: var(--mono); font-size: 11px;
    color: var(--muted);
    border: 1px solid var(--border); border-radius: 6px;
    padding: 1px 6px; background: var(--surface);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content { padding: 22px 24px 60px; max-width: 1500px; width: 100%; }

/* ---------- примитивы ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 780px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    padding: 8px 13px;
    border-radius: var(--radius-sm);
    font-family: var(--font); font-size: 13px; font-weight: 500;
    cursor: pointer;
    transition: background .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #6A4BFF); border-color: transparent; color: #fff; }
.btn.danger { background: rgba(239, 68, 68, .14); border-color: rgba(239, 68, 68, .4); color: var(--danger); }
.btn.sm { padding: 5px 9px; font-size: 12px; }

input, select, textarea {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 8px 11px;
    font-family: var(--font); font-size: 13px;
    outline: none;
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 92, 255, .18);
}
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }

/* ---------- таблицы / DataGrid ---------- */
table.dg { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dg th {
    text-align: left; font-weight: 500; color: var(--muted);
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    padding: 8px 10px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface);
}
table.dg td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.dg tbody tr { transition: background .15s var(--ease); }
table.dg tbody tr:hover { background: var(--surface-2); }
table.dg tbody tr.selected { background: rgba(124, 92, 255, .10); }

/* ---------- статусы ---------- */
.status-pulse {
    width: 9px; height: 9px; border-radius: 50%;
    display: inline-block; background: var(--muted);
}
.status-pulse.on { background: var(--ok); box-shadow: 0 0 0 0 rgba(34, 197, 94, .5); animation: pulse 2s infinite; }
.status-pulse.off { background: #4B5563; }
.status-pulse.warn { background: var(--warn); }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, .45); }
    70% { box-shadow: 0 0 0 9px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 500;
    border: 1px solid var(--border); color: var(--muted);
    background: var(--surface-2);
}
.chip.ok { color: var(--ok); border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .10); }
.chip.warn { color: var(--warn); border-color: rgba(245, 158, 11, .35); background: rgba(245, 158, 11, .10); }
.chip.danger { color: var(--danger); border-color: rgba(239, 68, 68, .35); background: rgba(239, 68, 68, .10); }
.chip.accent { color: var(--accent); border-color: rgba(124, 92, 255, .35); background: rgba(124, 92, 255, .10); }

/* ---------- drawer / palette / toast ---------- */
.drawer-backdrop, .palette-backdrop {
    position: fixed; inset: 0; background: rgba(3, 5, 10, .55);
    backdrop-filter: blur(2px); z-index: 40;
    animation: fade .18s var(--ease);
}
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 94vw;
    background: var(--surface); border-left: 1px solid var(--border);
    z-index: 41; padding: 18px; overflow-y: auto;
    animation: slide-in .22s var(--ease);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

.palette {
    position: fixed; top: 14vh; left: 50%; transform: translateX(-50%);
    width: 620px; max-width: 92vw;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    z-index: 41; overflow: hidden;
    animation: pop .18s var(--ease);
}
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 14px 16px; background: var(--surface); }
.palette-list { max-height: 340px; overflow-y: auto; }
.palette-item { padding: 10px 16px; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.palette-item:hover, .palette-item.sel { background: var(--surface-2); }

.toast-stack { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
    min-width: 260px; max-width: 380px;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    box-shadow: var(--shadow);
    animation: slide-up .2s var(--ease);
}
.toast.ok { border-color: rgba(34, 197, 94, .4); }
.toast.warn { border-color: rgba(245, 158, 11, .4); }
.toast.danger { border-color: rgba(239, 68, 68, .4); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateX(-50%) scale(.98); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slide-up { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- терминал ---------- */
.terminal {
    background: #07080C;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--mono); font-size: 12.5px;
    overflow: hidden;
}
.terminal-head { padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--muted); display: flex; justify-content: space-between; }
.terminal-body { padding: 12px; min-height: 220px; max-height: 420px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.terminal-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.terminal-input input { flex: 1; font-family: var(--mono); }

/* ---------- прочее ---------- */
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.filetree { font-family: var(--mono); font-size: 12.5px; }
.filetree .node { padding: 3px 0; cursor: default; display: flex; gap: 8px; align-items: center; }
.filetree .node.dir { color: var(--accent-2); }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 12px; padding: 8px 0; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--accent); flex: 0 0 8px; }
.timeline-item.critical .timeline-dot { background: var(--danger); }
.timeline-item.warn .timeline-dot { background: var(--warn); }
.timeline-body { flex: 1; border-bottom: 1px solid var(--border); padding-bottom: 8px; }

.live-viewer {
    background: #000; border: 1px solid var(--border); border-radius: var(--radius);
    min-height: 260px; display: grid; place-items: center; overflow: hidden;
}
.live-viewer img { width: 100%; height: auto; display: block; }

.totp-ring { display: inline-flex; align-items: center; gap: 10px; }
.totp-code { font-family: var(--mono); font-size: 22px; letter-spacing: .12em; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
