/* Адмінка ТЖКП — сучасний інтерфейс з виїзною боковою панеллю.
   Темний сайдбар, світлий контент, картки. */

:root {
    --side-bg: #101b26;
    --side-bg2: #0b141d;
    --side-text: #9fb3c2;
    --side-active: #ffffff;
    --accent: #14b8a6;
    --accent2: #0ea5e9;
    --bg: #f2f5f8;
    --card: #ffffff;
    --text: #1c2b36;
    --muted: #718796;
    --border: #e3e9ee;
    --danger: #dc2626;
    --success: #16a34a;
    --warn: #b45309;
    --radius: 16px;
    --side-w: 248px;
    --side-w-min: 68px;
}

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

body {
    font-family: -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

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

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

/* ---------- Сайдбар ---------- */
.sidebar {
    width: var(--side-w);
    background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg2) 100%);
    color: var(--side-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: width .22s ease, transform .22s ease;
    overflow: hidden;
}
.sidebar-logo {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 18px;
    white-space: nowrap;
}
.logo-badge {
    min-width: 36px; height: 36px;
    background: var(--accent);
    color: #fff; font-weight: 800; font-size: 19px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}
.logo-text { color: #fff; font-weight: 700; font-size: 17px; letter-spacing: .3px; }

.sidebar-section {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px;
    padding: 14px 20px 8px; color: #5c7284; white-space: nowrap;
}
.sidebar-nav { flex: 1; }
.sidebar-nav a, .sidebar-footer a {
    display: flex; align-items: center; gap: 14px;
    padding: 11px 20px;
    color: var(--side-text);
    font-size: 14.5px;
    white-space: nowrap;
    border-left: 3px solid transparent;
}
.sidebar-nav a i, .sidebar-footer a i { font-style: normal; font-size: 17px; min-width: 22px; text-align: center; }
.sidebar-nav a:hover, .sidebar-footer a:hover { color: #fff; background: rgba(255,255,255,.05); text-decoration: none; }
.sidebar-nav a.active {
    color: var(--side-active);
    background: rgba(20,184,166,.12);
    border-left-color: var(--accent);
}
.sidebar-footer { padding: 10px 0 18px; border-top: 1px solid rgba(255,255,255,.07); }

/* згорнутий сайдбар (десктоп) */
.layout.collapsed .sidebar { width: var(--side-w-min); }
.layout.collapsed .logo-text,
.layout.collapsed .sidebar-section,
.layout.collapsed .sidebar-nav a span,
.layout.collapsed .sidebar-footer a span { opacity: 0; pointer-events: none; }
.layout.collapsed .main { margin-left: var(--side-w-min); }

.sidebar-overlay { display: none; }

/* ---------- Контент ---------- */
.main {
    flex: 1;
    margin-left: var(--side-w);
    transition: margin-left .22s ease;
    min-width: 0;
}
.topbar {
    background: var(--card);
    display: flex; align-items: center; gap: 16px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
}
.burger {
    width: 42px; height: 42px;
    font-size: 19px;
    border: 1.5px solid var(--accent2);
    color: var(--accent2);
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
}
.topbar-search { flex: 1; max-width: 560px; }
.topbar-search input {
    width: 100%;
    padding: 11px 16px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 12px;
    font-size: 14.5px;
    outline: none;
}
.topbar-search input:focus { border-color: var(--accent2); background: #fff; }
.topbar-user { margin-left: auto; font-size: 14px; color: var(--muted); white-space: nowrap; }
.topbar-user b { color: var(--text); }

.content { padding: 24px; max-width: 1280px; }

#flash { padding: 0 24px; }
.flash { padding: 12px 18px; border-radius: 12px; margin-top: 14px; font-size: 14.5px; }
.flash-success { background: #dcfce7; color: var(--success); }
.flash-error { background: #fee2e2; color: var(--danger); }
.flash-info { background: #e0f2fe; color: #075985; }

/* ---------- Заголовки та картки ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 23px; font-weight: 800; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(16,27,38,.06), 0 8px 24px rgba(16,27,38,.04);
    padding: 22px;
    margin-bottom: 18px;
}
.card h2 { font-size: 16.5px; font-weight: 700; margin-bottom: 14px; }

/* статистичні картки */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(16,27,38,.06);
    padding: 18px 20px;
    position: relative;
}
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 800; margin: 8px 0 2px; }
.stat-note { font-size: 13px; color: var(--muted); }
.stat-icon {
    position: absolute; top: 16px; right: 16px;
    width: 42px; height: 42px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px;
}
.ic-teal { background: #ccfbf1; }
.ic-blue { background: #e0f2fe; }
.ic-violet { background: #ede9fe; }
.ic-red { background: #fee2e2; }
.stat-danger .stat-value { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Форми ---------- */
label { display: block; font-size: 13.5px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=tel], input[type=email], input[type=password],
input[type=number], input[type=month], input[type=date], input[type=search], select {
    width: 100%;
    padding: 11px 14px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    outline: none;
}
input:focus, select:focus { border-color: var(--accent2); }
input[type=file] { font-size: 14px; margin-top: 4px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 160px; }

.btn {
    display: inline-block;
    margin-top: 16px;
    padding: 11px 22px;
    font-size: 14.5px; font-weight: 700;
    color: #fff;
    background: var(--accent);
    border: none; border-radius: 10px;
    cursor: pointer;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-blue { background: var(--accent2); }
.btn-light { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 7px 14px; font-size: 13.5px; margin-top: 0; }
.btn-danger { background: var(--danger); }

/* ---------- Таблиці ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.list th {
    text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
    color: var(--muted); padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
table.list td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover td { background: #f8fafc; }
td.num, th.num { text-align: right; white-space: nowrap; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-failed { background: #fee2e2; color: var(--danger); }
.badge-new, .badge-pending { background: #fef3c7; color: var(--warn); }
.badge-owner { background: #ede9fe; color: #6d28d9; }
.badge-manager { background: #e0f2fe; color: #075985; }
.badge-off { background: #f1f5f9; color: var(--muted); }

/* команда (dashboard) */
.team-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.team-row:last-child { border-bottom: none; }
.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.team-name { flex: 1; }
.team-name b { display: block; font-size: 14.5px; }
.team-name span { font-size: 12.5px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot-on { background: var(--success); }
.dot-off { background: #cbd5e1; }

/* графік */
.chart-box { position: relative; }
.chart-box canvas { width: 100%; height: 280px; display: block; }
.chart-legend { display: flex; gap: 18px; font-size: 13px; color: var(--muted); justify-content: flex-end; margin-bottom: 8px; }
.chart-legend i { font-style: normal; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }

/* модалка */
.modal-back {
    position: fixed; inset: 0; background: rgba(12,20,28,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 60; padding: 16px;
}
.modal {
    background: #fff; border-radius: var(--radius);
    max-width: 520px; width: 100%; max-height: 90vh; overflow: auto;
    padding: 24px;
}
.modal h2 { margin-bottom: 6px; }

/* центрований екран входу */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .logo-badge { margin: 0 auto 14px; width: 52px; min-width: 52px; height: 52px; font-size: 26px; border-radius: 14px; }
.auth-card h1 { text-align: center; font-size: 21px; margin-bottom: 4px; }
.auth-card .page-sub { text-align: center; margin-bottom: 10px; }

/* ---------- Мобільний: сайдбар виїжджає поверх ---------- */
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); width: var(--side-w) !important; }
    .layout.mobile-open .sidebar { transform: translateX(0); }
    .layout.mobile-open .sidebar-overlay {
        display: block; position: fixed; inset: 0;
        background: rgba(12,20,28,.45); z-index: 35;
    }
    .layout.collapsed .logo-text,
    .layout.collapsed .sidebar-section,
    .layout.collapsed .sidebar-nav a span,
    .layout.collapsed .sidebar-footer a span { opacity: 1; pointer-events: auto; }
    .main { margin-left: 0 !important; }
    .content { padding: 16px; }
    .topbar { padding: 10px 14px; }
    .topbar-user { display: none; }
}
