/* ================================================================
   КУБЭРА — Система управления бизнесом
   Design: Corporate dark, industrial precision
   Fonts: Unbounded (headers) + Golos Text (body)
   ================================================================ */

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

:root {
    /* Base palette */
    --bg:           #060b18;
    --bg-2:         #0a1020;
    --bg-3:         #0d1629;
    --bg-4:         #111e35;
    --bg-5:         #172240;
    --border:       #1a2540;
    --border-2:     #203058;

    /* Text */
    --text:         #e8edf5;
    --text-2:       #8ea0be;
    --text-3:       #546882;
    --text-4:       #2f4060;

    /* Accent — electric blue */
    --blue:         #1d6af0;
    --blue-2:       #2979ff;
    --blue-dim:     #1d6af018;
    --blue-glow:    0 0 20px #1d6af044;

    /* Status colors */
    --green:        #00c97a;
    --green-dim:    #00c97a18;
    --yellow:       #f0a500;
    --yellow-dim:   #f0a50018;
    --red:          #f04040;
    --red-dim:      #f0404018;
    --gray-dim:     #8ea0be18;

    --sidebar-w:    260px;
    --topbar-h:     60px;
    --radius:       8px;
    --radius-lg:    12px;
    --radius-xl:    18px;
    --transition:   .18s ease;
}

html { font-size: 15px; scroll-behavior: smooth; }
body {
    font-family: 'Golos Text', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* GLOBAL BACKGROUND GRID */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: .3;
    pointer-events: none;
    z-index: 0;
}

/* Ensure all content is above the grid */
body > * { position: relative; z-index: 1; }

/* ── LAYOUT ──────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
    overflow-x: hidden;
    max-width: 100vw;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform var(--transition);
}

.sidebar-top { flex: 1; overflow-y: auto; padding: 20px 16px; }

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    padding: 8px 8px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.brand-icon {
    width: 36px; height: 36px;
    background: var(--blue);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Unbounded', sans-serif;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
    box-shadow: var(--blue-glow);
    flex-shrink: 0;
}
.brand-logo {
    width: 36px; height: 36px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
    background: #fff;
}
.brand-name {
    font-family: 'Unbounded', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: .05em;
}

/* Nav */
.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text-4);
    padding: 0 8px;
    margin: 18px 0 6px;
}
.nav-section-label:first-child { margin-top: 0; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-3);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
    margin-bottom: 2px;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { color: var(--text-2); background: var(--bg-4); }
.nav-link.active {
    color: var(--blue-2);
    background: var(--blue-dim);
    font-weight: 600;
}
.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 3px;
    background: var(--blue);
    border-radius: 0 3px 3px 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--blue-dim);
    color: var(--blue-2);
    border: 1px solid var(--blue)44;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 20px;
}
.nav-badge-red {
    background: var(--red-dim);
    color: var(--red);
    border-color: var(--red)44;
}

/* Sidebar bottom */
.sidebar-bottom {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-user-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    transition: background var(--transition);
    min-width: 0;
}
.sidebar-user-card:hover, .sidebar-user-card.active { background: var(--bg-4); }
.user-ava {
    width: 34px; height: 34px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; color: #fff;
    flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name    { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-company { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-link {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-4);
    border-radius: var(--radius);
    transition: all var(--transition);
    flex-shrink: 0;
}
.logout-link svg { width: 18px; height: 18px; }
.logout-link:hover { color: var(--red); background: var(--red-dim); }

/* ── MAIN WRAP ───────────────────────────────────────────── */
.main-wrap {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}
.burger span { display: block; width: 20px; height: 2px; background: var(--text-2); border-radius: 2px; transition: all .2s; }
.topbar-breadcrumb { flex: 1; font-size: 15px; font-weight: 600; color: var(--text-2); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-bell {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all var(--transition);
    position: relative;
}
.topbar-bell svg { width: 20px; height: 20px; }
.topbar-bell:hover { color: var(--text); background: var(--bg-4); }
.bell-dot {
    position: absolute;
    top: 4px; right: 4px;
    width: 16px; height: 16px;
    background: var(--red);
    border-radius: 50%;
    font-size: 9px;
    font-weight: 800;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-2);
}

/* ── PAGE CONTENT ────────────────────────────────────────── */
.page-content { padding: 32px 36px; flex: 1; min-width: 0; max-width: 100%; box-sizing: border-box; }

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    gap: 16px;
}
.page-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.2;
}
.page-sub { font-size: 14px; color: var(--text-3); }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    background: radial-gradient(circle, var(--blue-dim) 0%, transparent 70%);
    pointer-events: none;
}
.stat-icon {
    font-size: 26px;
    margin-bottom: 14px;
    display: block;
}
.stat-val {
    font-family: 'Unbounded', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
    margin-bottom: 6px;
}
.stat-val.green  { color: var(--green); }
.stat-val.yellow { color: var(--yellow); }
.stat-val.red    { color: var(--red); }
.stat-val.blue   { color: var(--blue-2); }
.stat-label { font-size: 13px; color: var(--text-3); }
.stat-change { font-size: 12px; margin-top: 6px; }
.stat-change.up   { color: var(--green); }
.stat-change.down { color: var(--red); }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.card-body  { padding: 20px 24px; }
.card-link  { font-size: 13px; color: var(--blue-2); text-decoration: none; }
.card-link:hover { text-decoration: underline; }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-4);
    background: var(--bg-2);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-2);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-4); }
.td-main  { color: var(--text) !important; font-weight: 600; }
.td-small { font-size: 12px !important; color: var(--text-4) !important; }
.td-mono  { font-family: 'Courier New', monospace; font-size: 13px !important; }

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid var(--green)33;  }
.badge-blue   { background: var(--blue-dim);   color: var(--blue-2); border: 1px solid var(--blue)33;   }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid var(--yellow)33; }
.badge-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid var(--red)33;    }
.badge-gray   { background: var(--gray-dim);   color: var(--text-3); border: 1px solid var(--border-2); }

/* ── PRIORITY DOTS ───────────────────────────────────────── */
.p-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
}
.p-dot.low      { background: var(--text-4); }
.p-dot.normal   { background: var(--blue-2); }
.p-dot.high     { background: var(--yellow); box-shadow: 0 0 6px var(--yellow)88; }
.p-dot.critical { background: var(--red);    box-shadow: 0 0 8px var(--red)88; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 0%,100%{ opacity:1 } 50%{ opacity:.4 } }
@keyframes spin   { to { transform: rotate(360deg); } }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:hover { opacity: .85; transform: translateY(-1px); }
.btn:active { transform: translateY(0); opacity: 1; }

.btn-primary {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 2px 12px var(--blue)44;
}
.btn-primary:hover { background: var(--blue-2); box-shadow: 0 4px 18px var(--blue)66; }
.btn-secondary {
    background: var(--bg-4);
    color: var(--text-2);
    border-color: var(--border-2);
}
.btn-danger {
    background: var(--red-dim);
    color: var(--red);
    border-color: var(--red)33;
}
.btn-success {
    background: var(--green-dim);
    color: var(--green);
    border-color: var(--green)33;
}
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-xs { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-row { display: grid; gap: 16px; margin-bottom: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.form-label.required::after { content: ' *'; color: var(--red); }
.form-control {
    padding: 10px 14px;
    background: var(--bg-4);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
    color-scheme: dark;
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-dim); }
.form-control::placeholder { color: var(--text-4); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 12px; color: var(--text-4); margin-top: 4px; }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: var(--green-dim);  border: 1px solid var(--green)33;  color: var(--green); }
.alert-error   { background: var(--red-dim);    border: 1px solid var(--red)33;    color: var(--red); }
.alert-warning { background: var(--yellow-dim); border: 1px solid var(--yellow)33; color: var(--yellow); }
.alert-info    { background: var(--blue-dim);   border: 1px solid var(--blue)33;   color: var(--blue-2); }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(4,8,20,.8);
    backdrop-filter: blur(6px);
    z-index: 800;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }
.modal {
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-xl);
    padding: 32px 36px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,.6);
    animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform:translateY(16px); opacity:0 } to { transform:none; opacity:1 } }
.modal.modal-lg { max-width: 720px; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-family: 'Unbounded', sans-serif; font-size: 17px; font-weight: 700; color: var(--text); }
.modal-close {
    background: none; border: none;
    color: var(--text-3); font-size: 24px; line-height: 1;
    cursor: pointer; padding: 4px 6px;
    border-radius: 6px;
    transition: all var(--transition);
}
.modal-close:hover { color: var(--red); background: var(--red-dim); }
.modal-footer {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: 28px; padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ── SERVER STATUS CARD ──────────────────────────────────── */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.server-card {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    transition: border-color var(--transition), transform var(--transition);
    position: relative;
    overflow: hidden;
}
.server-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.server-card.status-running { border-left: 3px solid var(--green); }
.server-card.status-stopped { border-left: 3px solid var(--red); }
.server-card.status-maintenance { border-left: 3px solid var(--yellow); }
.server-type-icon {
    position: absolute;
    top: 16px; right: 16px;
    font-size: 24px; opacity: .3;
}
.server-name { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.server-ip   { font-size: 12px; color: var(--text-4); font-family: monospace; margin-bottom: 14px; }
.server-specs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.spec-item { text-align: center; }
.spec-val  { font-size: 16px; font-weight: 700; color: var(--text); }
.spec-lbl  { font-size: 10px; color: var(--text-4); text-transform: uppercase; letter-spacing: .05em; }

/* ── STATUS DOT ──────────────────────────────────────────── */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-3);
}
.status-dot::before {
    content: '';
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.running::before    { background: var(--green); box-shadow: 0 0 6px var(--green)88; animation: pulse 2s ease-in-out infinite; }
.status-dot.stopped::before    { background: var(--red); }
.status-dot.maintenance::before{ background: var(--yellow); }
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.5 } }

/* ── TIMELINE / COMMENTS ─────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 20px; }
.timeline-item { display: flex; gap: 14px; }
.timeline-avatar {
    width: 34px; height: 34px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800; color: #fff;
}
.timeline-body { flex: 1; }
.timeline-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.timeline-name { font-size: 13px; font-weight: 700; color: var(--text); }
.timeline-time { font-size: 12px; color: var(--text-4); }
.timeline-msg {
    background: var(--bg-4);
    border: 1px solid var(--border);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.6;
}

/* ── INVOICE AMOUNT ──────────────────────────────────────── */
.amount-big {
    font-family: 'Unbounded', sans-serif;
    font-size: 26px;
    font-weight: 700;
}
.amount-big.paid   { color: var(--green); }
.amount-big.overdue{ color: var(--red); }
.amount-big.sent   { color: var(--blue-2); }

/* ── NOTIFICATIONS LIST ──────────────────────────────────── */
.notif-list { display: flex; flex-direction: column; }
.notif-item {
    display: flex;
    gap: 14px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
    text-decoration: none;
    color: inherit;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-4); }
.notif-item.unread { background: var(--blue-dim); }
.notif-item.unread:hover { background: var(--bg-5); }
.notif-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.notif-icon.info    { background: var(--blue-dim); }
.notif-icon.success { background: var(--green-dim); }
.notif-icon.warning { background: var(--yellow-dim); }
.notif-icon.error   { background: var(--red-dim); }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.notif-msg   { font-size: 13px; color: var(--text-3); line-height: 1.4; }
.notif-time  { font-size: 11px; color: var(--text-4); margin-top: 4px; }
.unread-dot  { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-top: 6px; flex-shrink: 0; }

/* ── SERVICE CARD ────────────────────────────────────────── */
.service-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.service-card {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    transition: border-color var(--transition), transform var(--transition);
}
.service-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.service-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.service-icon-wrap {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.service-name  { font-size: 14px; font-weight: 700; color: var(--text); }
.service-cat   { font-size: 12px; color: var(--text-4); }
.service-price {
    font-family: 'Unbounded', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}
.service-price span { font-size: 12px; font-weight: 400; color: var(--text-4); }
.service-desc { font-size: 13px; color: var(--text-3); line-height: 1.5; }

/* ── PROGRESS BAR ────────────────────────────────────────── */
.progress-bar { height: 4px; background: var(--border-2); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width .5s ease; }
.progress-fill.blue   { background: var(--blue); }
.progress-fill.green  { background: var(--green); }
.progress-fill.yellow { background: var(--yellow); }
.progress-fill.red    { background: var(--red); }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-4);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .5; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-3); margin-bottom: 6px; }
.empty-sub   { font-size: 14px; }

/* ── DIVIDER ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ── TICKET DETAIL ───────────────────────────────────────── */
.ticket-detail-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}
.detail-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.detail-row:last-child { border-bottom: none; }
.detail-key { color: var(--text-3); }
.detail-val { color: var(--text); font-weight: 600; text-align: right; }

/* ── LOGIN ───────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px 60px;
    background: var(--bg);
    position: relative;
    overflow: visible;
}
.login-bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    opacity: .12;
    z-index: 0;
}
.login-bg-orb-1 {
    width: 600px; height: 600px;
    background: var(--blue);
    top: -200px; left: -200px;
}
.login-bg-orb-2 {
    width: 400px; height: 400px;
    background: #0080ff;
    bottom: -100px; right: -100px;
}
.login-box {
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-xl);
    padding: 48px 44px;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 2;
    margin-top: auto;
    margin-bottom: auto;
    align-self: center;
    box-shadow: 0 30px 80px rgba(0,0,0,.5), 0 0 0 1px var(--border);
}
/* Center vertically when page is taller than content */
.login-page::before { content: ''; flex: 1; }
.login-page::after  { content: ''; flex: 1; }
.login-logo-wrap {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 36px;
}
.login-logo-icon {
    width: 48px; height: 48px;
    background: var(--blue);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Unbounded', sans-serif;
    font-weight: 900;
    font-size: 24px;
    color: #fff;
    box-shadow: var(--blue-glow);
}
.login-logo-img {
    width: 56px; height: 56px;
    object-fit: contain;
    border-radius: 14px;
    background: #fff;
    flex-shrink: 0;
}
.login-logo-text {
    font-family: 'Unbounded', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
}
.login-logo-sub { font-size: 11px; color: var(--text-4); margin-top: 2px; }
.login-title { font-family: 'Unbounded', sans-serif; font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.login-sub   { font-size: 14px; color: var(--text-3); margin-bottom: 28px; }
.login-demo  {
    margin-top: 24px;
    padding: 14px 16px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text-4);
    line-height: 1.8;
}
.login-demo strong { color: var(--text-3); display: block; margin-bottom: 6px; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE + MOBILE BOTTOM NAV
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .ticket-detail-grid { grid-template-columns: 1fr; }
}

/* Скрыть элемент только на мобиле */
@media (max-width: 768px) {
    .mob-hide { display: none !important; }
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    :root {
        --sidebar-w:  0px;
        --mob-nav-h:  60px;
    }

    /* Sidebar: скрыт за левым краем, z-index выше overlay */
    .sidebar {
        transform: translateX(-260px);
        width: 260px !important;
        z-index: 1000;
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.35);
    }

    .main-wrap { margin-left: 0; }

    /* Бургер скрыт — навигация внизу */
    .burger { display: none !important; }

    /* Контент: отступ снизу под нижнюю панель */
    .page-content {
        padding: 14px 14px calc(var(--mob-nav-h) + 12px + env(safe-area-inset-bottom, 0px)) 14px;
    }

    .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .modal { padding: 20px 16px; max-width: calc(100vw - 32px) !important; }
    .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: 1fr !important; }
    .kpi-wide { grid-column: auto !important; }

    /* Topbar */
    .topbar { padding: 0 12px 0 16px; gap: 8px; }
    .topbar-breadcrumb { font-size: 13px; }

    /* Таблицы — горизонтальный скролл */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 480px; }

    /* Page header — компактнее */
    .page-header { flex-wrap: wrap; gap: 8px; }
    .page-title { font-size: 17px; }
    .page-sub { font-size: 12px; }
    .page-actions { width: 100%; justify-content: flex-start; }

    /* Кнопки — не вылезают за край */
    .btn { white-space: normal; word-break: break-word; }

    /* Карточки — полная ширина */
    .card { overflow-x: hidden; }

    /* Статкарточки — 2 колонки минимум */
    .stat-row { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-val  { font-size: 20px; }
    .stat-card { padding: 12px; }

    /* Формы — полная ширина */
    .form-control { max-width: 100%; box-sizing: border-box; }
    select.form-control { max-width: 100%; }

    /* Модалы — полная ширина, с учётом нижнего навбара */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
        /* Снизу — отступ под мобильный навбар */
        padding-bottom: calc(var(--mob-nav-h) + env(safe-area-inset-bottom, 0px));
    }
    .modal {
        max-width: 100% !important;
        width: 100% !important;
        border-radius: var(--radius) var(--radius) 0 0;
        /* Высота: весь экран минус навбар снизу и небольшой отступ сверху */
        max-height: calc(100vh - var(--mob-nav-h) - env(safe-area-inset-bottom, 0px) - 20px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Кнопки футера — всегда видны, липнут к низу модала */
    .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--bg-3);
        margin-left: -16px;
        margin-right: -16px;
        padding: 14px 16px;
        border-top: 1px solid var(--border);
        margin-bottom: -20px;
        z-index: 2;
    }

    /* Скрыть лишние колонки таблиц */
    .td-mono { font-size: 11px; }
}

@media (max-width: 480px) {
    .page-content { padding: 12px 10px calc(var(--mob-nav-h) + 10px + env(safe-area-inset-bottom,0px)) 10px; }
    .stat-row { grid-template-columns: 1fr 1fr; gap: 6px; }
    .stat-val  { font-size: 18px; }
    .stat-card { padding: 10px; }
    .page-title { font-size: 15px; }
    /* Кнопки мельче на очень маленьких экранах */
    .btn { padding: 7px 10px; font-size: 12px; }
    .btn-sm { padding: 5px 8px; font-size: 11px; }
    .topbar { padding: 0 10px; }
}

/* ── Универсальные мобильные фиксы ────────────────────────── */
/* Любой прямой потомок .page-content не должен вылезать */
.page-content > * { max-width: 100%; box-sizing: border-box; }

/* Таблицы всегда в обёртке со скроллом */
.table-wrap, .wt-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* ss-dropdown через fixed JS — на мобиле тоже фиксим ширину */
@media (max-width: 768px) {
    .ss-dropdown { max-width: calc(100vw - 24px) !important; }
}

/* ════════════════════════════════════════════════════════════════
   OVERLAY — тёмный фон при открытом sidebar на мобиле
   ════════════════════════════════════════════════════════════════ */
.mob-overlay { display: none; }
/* ════════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAVIGATION BAR
   ════════════════════════════════════════════════════════════════ */
.mob-nav { display: none; }

@media (max-width: 768px) {
    .mob-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        z-index: 800;
        height: calc(var(--mob-nav-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        align-items: stretch;
        background: var(--bg-1);
        border-top: 1px solid var(--border-2);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
    }

    .mob-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        text-decoration: none;
        color: var(--text-4);
        font-size: 10px;
        font-weight: 600;
        padding: 8px 4px 6px;
        position: relative;
        transition: color 0.15s;
        -webkit-tap-highlight-color: transparent;
        border: none;
        background: none;
        cursor: pointer;
        font-family: inherit;
        line-height: 1;
        min-width: 0;
    }

    .mob-nav-item svg {
        width: 22px; height: 22px;
        flex-shrink: 0;
        transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.15s;
    }

    .mob-nav-item > span:last-child {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Активный */
    .mob-nav-item.active { color: var(--blue-2); }
    .mob-nav-item.active svg { transform: translateY(-2px) scale(1.1); }
    .mob-nav-item.active::after {
        content: '';
        position: absolute;
        top: 0; left: 25%; right: 25%;
        height: 2px;
        background: var(--blue-2);
        border-radius: 0 0 3px 3px;
    }

    .mob-nav-item:active { color: var(--text-2); }
    .mob-nav-item:active svg { transform: scale(0.9); }

    /* Бейдж */
    .mob-nav-badge {
        position: absolute;
        top: 5px;
        left: calc(50% + 6px);
        min-width: 16px; height: 16px;
        padding: 0 4px;
        background: #ef4444;
        color: #fff;
        border-radius: 8px;
        font-size: 9px; font-weight: 800;
        line-height: 16px; text-align: center;
        pointer-events: none;
        border: 1.5px solid var(--bg-1);
    }

    /* Кнопка «Ещё» при открытом sidebar */
    .mob-nav-more.sidebar-open { color: var(--blue-2); }
    .mob-nav-more.sidebar-open svg { transform: rotate(90deg); }
}

[data-theme="light"] .mob-nav {
    background: rgba(255,255,255,0.97);
    border-top-color: rgba(0,0,0,0.1);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.07);
}

/* ── AJAX Notifications Dropdown ─────────────────────────────── */
.notif-bell-wrap {
    position: relative;
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 360px;
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,.45);
    z-index: 1000;
    overflow: hidden;
    animation: ddFadeIn .15s ease;
}
@keyframes ddFadeIn {
    from { opacity:0; transform:translateY(-6px); }
    to   { opacity:1; transform:translateY(0); }
}
.notif-dd-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
}
.notif-dd-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}
.notif-dd-readall {
    font-size: 11px;
    color: var(--blue-2);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.notif-dd-readall:hover { text-decoration: underline; }
.notif-dd-body {
    max-height: 340px;
    overflow-y: auto;
}
.notif-dd-loading {
    padding: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-4);
}
.notif-dd-empty {
    padding: 28px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-4);
}
.notif-dd-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .12s;
    text-decoration: none;
}
.notif-dd-item:last-child { border-bottom: none; }
.notif-dd-item:hover { background: var(--bg-4); }
.notif-dd-item.unread { background: var(--blue-dim); }
.notif-dd-item.unread:hover { background: var(--bg-4); }
.notif-dd-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}
.notif-dd-icon.info    { background: var(--blue-dim); }
.notif-dd-icon.success { background: var(--green-dim); }
.notif-dd-icon.warning { background: rgba(245,158,11,.12); }
.notif-dd-icon.error   { background: var(--red-dim); }
.notif-dd-content { flex: 1; min-width: 0; }
.notif-dd-ntitle {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-dd-msg {
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-dd-time {
    font-size: 10px;
    color: var(--text-4);
    margin-top: 3px;
}
.notif-dd-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--blue-2);
    flex-shrink: 0;
    margin-top: 6px;
}
.notif-dd-foot {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.notif-dd-foot a {
    font-size: 12px;
    color: var(--blue-2);
    text-decoration: none;
}
.notif-dd-foot a:hover { text-decoration: underline; }

/* Новое уведомление — pop-toast */
.notif-toast-wrap {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.notif-toast {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-left: 3px solid var(--blue-2);
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 280px;
    max-width: 360px;
    box-shadow: 0 6px 24px rgba(0,0,0,.4);
    pointer-events: auto;
    animation: toastIn .25s ease;
    cursor: pointer;
}
.notif-toast.success { border-left-color: var(--green); }
.notif-toast.warning { border-left-color: #f59e0b; }
.notif-toast.error   { border-left-color: var(--red); }
@keyframes toastIn {
    from { opacity:0; transform:translateX(20px); }
    to   { opacity:1; transform:translateX(0); }
}
@keyframes toastOut {
    to { opacity:0; transform:translateX(20px); height:0; padding:0; margin:0; }
}
.notif-toast.removing {
    animation: toastOut .3s ease forwards;
}
.notif-toast-title { font-size:13px; font-weight:700; color:var(--text); }
.notif-toast-msg   { font-size:12px; color:var(--text-3); margin-top:3px; }

/* ══════════════════════════════════════════════════════════════
   СВЕТЛАЯ ТЕМА
   ══════════════════════════════════════════════════════════════ */
[data-theme="light"] {
    --bg:           #f0f4fa;
    --bg-2:         #ffffff;
    --bg-3:         #f8fafc;
    --bg-4:         #eef2f8;
    --bg-5:         #e4eaf4;
    --border:       #dde4f0;
    --border-2:     #c8d4e8;

    --text:         #111827;
    --text-2:       #374151;
    --text-3:       #6b7280;
    --text-4:       #9ca3af;

    --blue:         #1d6af0;
    --blue-2:       #2563eb;
    --blue-dim:     #1d6af012;
    --blue-glow:    0 0 20px #1d6af030;

    --green:        #059669;
    --green-dim:    #05966912;
    --yellow:       #d97706;
    --yellow-dim:   #d9770612;
    --red:          #dc2626;
    --red-dim:      #dc262612;
    --gray-dim:     #6b728012;
}

/* Фон страницы */
[data-theme="light"] body { background: var(--bg); }

/* Сетка фона — светлее */
[data-theme="light"] body::before {
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    opacity: .5;
}

/* Инпуты */
[data-theme="light"] .form-control {
    color-scheme: light;
    background: #fff;
    border-color: var(--border-2);
    color: var(--text);
}
[data-theme="light"] .form-control::placeholder { color: var(--text-4); }

/* Скроллбар */
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg-3); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--border-2); }

/* Таблица — заголовок */
[data-theme="light"] .data-table th { background: var(--bg-4); }

/* Тень модала */
[data-theme="light"] .modal {
    box-shadow: 0 24px 80px rgba(0,0,0,.15);
}
[data-theme="light"] .modal-overlay { background: rgba(17,24,39,.5); }

/* Логин */
[data-theme="light"] .login-box {
    box-shadow: 0 8px 40px rgba(0,0,0,.1), 0 0 0 1px var(--border);
}

/* Stat card — убираем синий блик */
[data-theme="light"] .stat-card::after {
    background: radial-gradient(circle, #1d6af008 0%, transparent 70%);
}

/* btn-secondary */
[data-theme="light"] .btn-secondary {
    background: #fff;
    color: var(--text-2);
    border-color: var(--border-2);
}
[data-theme="light"] .btn-secondary:hover {
    background: var(--bg-4);
}

/* Тосты */
[data-theme="light"] .notif-toast {
    box-shadow: 0 6px 24px rgba(0,0,0,.12);
}

/* ── КНОПКА ПЕРЕКЛЮЧЕНИЯ ТЕМЫ ─────────────────────────────── */
.theme-toggle {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: none;
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    color: var(--text-3);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 17px;
    line-height: 1;
    flex-shrink: 0;
}
.theme-toggle:hover {
    color: var(--text);
    background: var(--bg-4);
    border-color: var(--blue);
}

/* ══════════════════════════════════════════════════════════════
   SEARCHABLE SELECT
   ══════════════════════════════════════════════════════════════ */
.ss-wrapper {
    position: relative;
    display: block;
}

/* Отображаемое поле (замена нативного select) */
.ss-display {
    display: flex;
    align-items: center;
    padding: 10px 36px 10px 14px;
    background: var(--bg-4);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    min-height: 42px;
    transition: border-color var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    outline: none;
    position: relative;
}
.ss-display::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-3);
    pointer-events: none;
    transition: transform var(--transition);
}
.ss-wrapper.ss-open .ss-display::after {
    transform: translateY(-50%) rotate(180deg);
}
.ss-display.ss-placeholder { color: var(--text-4); }
.ss-display:focus,
.ss-wrapper.ss-open .ss-display {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-dim);
}

/* Дропдаун */
.ss-dropdown {
    display: none;
    /* position и координаты задаются через JS (fixed) чтобы выйти из overflow:hidden */
    position: absolute;
    left: 0; right: 0;
    top: calc(100% + 4px);
    z-index: 99999;
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
    overflow: visible;
    animation: ssDropIn .12s ease;
}
.ss-wrapper.ss-open .ss-dropdown { display: block; }
.ss-dropdown.ss-up {
    animation: ssDropInUp .12s ease;
}
@keyframes ssDropIn   { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
@keyframes ssDropInUp { from { opacity:0; transform:translateY(4px);  } to { opacity:1; transform:none; } }

/* Поиск внутри дропдауна */
.ss-search {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: var(--bg-3);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}
.ss-search::placeholder { color: var(--text-4); }
.ss-search:focus { background: var(--bg-2); border-bottom-color: var(--blue); }

/* Список опций */
.ss-list {
    list-style: none;
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 0;
    margin: 0;
    border-radius: 0 0 var(--radius) var(--radius);
}
.ss-option {
    padding: 9px 14px;
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
}
.ss-option:hover,
.ss-option:focus { background: var(--bg-4); color: var(--text); }
.ss-option.ss-selected {
    color: var(--blue-2);
    font-weight: 600;
    background: var(--blue-dim);
}
.ss-option.ss-disabled {
    color: var(--text-4);
    cursor: default;
    font-style: italic;
}
.ss-empty {
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text-4);
    text-align: center;
    font-style: italic;
}

/* Светлая тема */
[data-theme="light"] .ss-dropdown {
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
}
[data-theme="light"] .ss-search {
    background: #fff;
    border-bottom-color: var(--border);
}
[data-theme="light"] .ss-search:focus {
    background: #f9fbff;
}
