@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&family=Nunito+Sans:wght@400;500;600&display=swap');

:root {
    --bg:           #f0f2f5;
    --sidebar-bg:   #181f2e;
    --sidebar-w:    260px;
    --white:        #ffffff;
    --border:       #e4e8ef;
    --text:         #1a2332;
    --text-2:       #4a5568;
    --text-muted:   #8b97aa;
    --blue:         #2563eb;
    --blue-lt:      #dbeafe;
    --blue-hv:      #1d4ed8;
    --blue-soft:    #eff6ff;
    --green:        #059669;
    --green-lt:     #d1fae5;
    --orange:       #d97706;
    --orange-lt:    #fef3c7;
    --red:          #dc2626;
    --red-lt:       #fee2e2;
    --r-sm:         8px;
    --r:            12px;
    --r-lg:         16px;
    --shadow-sm:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow:       0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.04);
    --font:         'Nunito', sans-serif;
    --mono:         'Nunito Sans', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.sidebar { position: fixed; top:0; left:0; bottom:0; width: var(--sidebar-w); background: var(--sidebar-bg); display: flex; flex-direction: column; z-index: 100; }
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-icon { width: 40px; height: 40px; background: var(--blue); border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: #fff; flex-shrink: 0; }
.brand-name { display: block; font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.brand-sub { display: block; font-size: 11px; color: rgba(255,255,255,.38); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r-sm); color: rgba(255,255,255,.5); font-size: 14px; font-weight: 500; transition: all .15s; text-decoration: none; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); text-decoration: none; }
.nav-item.active { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.4); }
.nav-divider { height: 1px; background: rgba(255,255,255,.07); margin: 6px 0; }

.sidebar-footer { padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; gap: 10px; }
.user-info { flex: 1; min-width: 0; }
.user-avatar { width: 34px; height: 34px; background: rgba(255,255,255,.12); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: rgba(255,255,255,.9); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 11px; color: rgba(255,255,255,.38); margin-top: 1px; }
.logout-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm); color: rgba(255,255,255,.3); transition: all .15s; flex-shrink: 0; }
.logout-btn svg { width: 16px; height: 16px; }
.logout-btn:hover { color: #fff; background: rgba(255,255,255,.1); text-decoration: none; }

.page-header { padding: 28px 32px 0; background: transparent; }
.page-header-inner { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.page-title { font-size: 22px; font-weight: 800; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.page-body { flex: 1; padding: 24px 32px; max-width: 1200px; width: 100%; }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: var(--r-sm); font-size: 14px; font-weight: 600; border: none; cursor: pointer; transition: all .15s; text-decoration: none; font-family: var(--font); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.btn-primary:hover { background: var(--blue-hv); color: #fff; text-decoration: none; transform: translateY(-1px); }
.btn-secondary { background: var(--white); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }

.card { background: var(--white); border-radius: var(--r); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 700; }
.card-body { padding: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--r); padding: 20px 22px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.stat-card.blue::before { background: var(--blue); }
.stat-card.green::before { background: var(--green); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.red::before { background: var(--red); }
.stat-card-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px; }
.stat-card-value { font-size: 32px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card-sub { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-new      { background: var(--blue-lt); color: var(--blue); }
.status-progress { background: var(--orange-lt); color: var(--orange); }
.status-done     { background: var(--green-lt); color: var(--green); }
.status-rework   { background: var(--red-lt); color: var(--red); }

.requests-filters { background: var(--white); border-radius: var(--r); padding: 16px 20px; margin-bottom: 20px; display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.filter-group { display: flex; flex-direction: column; gap: 5px; }
.filter-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.filter-input, .filter-select { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: var(--r-sm); font-size: 14px; font-family: var(--font); color: var(--text); background: var(--bg); outline: none; transition: border-color .15s; min-width: 150px; }
.filter-input:focus, .filter-select:focus { border-color: var(--blue); background: var(--white); }
.filter-search { min-width: 240px; }

.requests-list { display: flex; flex-direction: column; gap: 10px; }
.request-card { background: var(--white); border-radius: var(--r); padding: 16px 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); cursor: pointer; transition: all .2s; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.request-card:hover { box-shadow: var(--shadow); border-color: var(--blue); transform: translateY(-1px); text-decoration: none; color: inherit; }
.request-card-left { min-width: 0; }
.request-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.request-id { font-size: 12px; font-weight: 700; color: var(--text-muted); background: var(--bg); padding: 2px 8px; border-radius: 20px; }
.request-category { font-size: 12px; font-weight: 600; color: var(--blue); background: var(--blue-soft); padding: 2px 8px; border-radius: 20px; }
.request-desc { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.request-meta { font-size: 12px; color: var(--text-muted); }
.request-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.request-date { font-size: 11px; color: var(--text-muted); font-weight: 500; }

.residents-list { display: flex; flex-direction: column; gap: 10px; }
.resident-card { background: var(--white); border-radius: var(--r); padding: 16px 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); cursor: pointer; transition: all .2s; display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit; }
.resident-card:hover { box-shadow: var(--shadow); border-color: var(--blue); transform: translateY(-1px); text-decoration: none; color: inherit; }
.resident-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--blue-lt); color: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; flex-shrink: 0; }
.resident-info { flex: 1; min-width: 0; }
.resident-name { font-size: 14px; font-weight: 700; color: var(--text); }
.resident-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.resident-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; margin-top: 4px; }
.pagination-info { font-size: 13px; color: var(--text-muted); }
.pagination-pages { display: flex; gap: 6px; }
.page-btn { min-width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm); font-size: 13px; font-weight: 600; border: 1.5px solid var(--border); background: var(--white); color: var(--text-2); cursor: pointer; transition: all .15s; text-decoration: none; }
.page-btn:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.page-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.request-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.detail-row { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 16px; }
.detail-row:last-child { border-bottom: none; }
.detail-key { font-size: 13px; color: var(--text-muted); font-weight: 500; flex-shrink: 0; }
.detail-value { font-size: 14px; font-weight: 500; text-align: right; }
.description-block { background: var(--bg); border-radius: var(--r-sm); padding: 16px; font-size: 14px; line-height: 1.65; margin-top: 10px; }
.section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 14px; }

.history-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: none; }
.history-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); flex-shrink: 0; margin-top: 4px; }
.history-body { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.history-date { font-size: 11px; color: var(--text-muted); display: block; margin-top: 3px; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.status-opt { padding: 12px; border: 2px solid var(--border); border-radius: var(--r-sm); cursor: pointer; text-align: center; font-size: 13px; font-weight: 600; transition: all .15s; background: var(--white); user-select: none; }
.status-opt:hover { border-color: var(--blue); background: var(--blue-soft); }
.status-opt.picked { border-color: var(--blue); background: var(--blue-lt); color: var(--blue); }
textarea.filter-input { resize: vertical; min-height: 72px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 44px; margin-bottom: 12px; opacity: .5; }
.empty-state-text { font-size: 14px; line-height: 1.6; }

.auth-message { padding: 12px 16px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; margin-top: 8px; }
.auth-message.loading { background: var(--blue-lt); color: var(--blue); }
.auth-message.success { background: var(--green-lt); color: var(--green); }
.auth-message.error   { background: var(--red-lt); color: var(--red); }

.login-page { background: var(--sidebar-bg); min-height: 100vh; }
.login-layout { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-left { padding: 60px 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-logo { width: 52px; height: 52px; background: var(--blue); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 800; color: #fff; }
.login-complex-name { font-size: 22px; font-weight: 800; color: #fff; }
.login-tagline { font-size: 34px; font-weight: 300; color: rgba(255,255,255,.8); line-height: 1.3; }
.login-stats { display: flex; gap: 40px; }
.login-stat { display: flex; flex-direction: column; }
.stat-number { font-size: 38px; font-weight: 800; color: #fff; line-height: 1; }
.stat-label { font-size: 12px; color: rgba(255,255,255,.38); margin-top: 4px; }
.login-right { background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 60px 56px; }
.login-card { width: 100%; max-width: 400px; }
.login-title { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.login-desc { font-size: 14px; color: var(--text-2); margin-bottom: 28px; line-height: 1.6; }
#tg-widget { margin-bottom: 8px; }
.login-help { margin-top: 20px; font-size: 13px; color: var(--text-muted); }

.mobile-nav { display: none; }

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding-bottom: 72px; }
    .page-header { padding: 16px 16px 0; }
    .page-body { padding: 16px; }
    .dashboard-grid { grid-template-columns: 1fr !important; }
    .request-layout { grid-template-columns: 1fr !important; }
    .stats-grid { grid-template-columns: 1fr 1fr !important; }
    .requests-filters { flex-direction: column; }
    .filter-input, .filter-select { min-width: 100% !important; width: 100%; }
    .login-left { display: none; }
    .login-layout { grid-template-columns: 1fr; }
    .login-right { padding: 40px 24px; }

    .mobile-nav { display: block; position: fixed; bottom: 0; left: 0; right: 0; height: 60px; background: var(--sidebar-bg); border-top: 1px solid rgba(255,255,255,.1); z-index: 200; }
    .mobile-nav-items { display: flex; height: 100%; }
    .mobile-nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: rgba(255,255,255,.4); text-decoration: none; font-size: 10px; font-weight: 600; transition: color .15s; }
    .mobile-nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
    .mobile-nav-item:hover, .mobile-nav-item.active { color: #fff; text-decoration: none; }
    .mobile-nav-item.active svg { color: #60a5fa; }
}

@media (max-width: 768px) {
    body { overflow-x: hidden; }
    .main-content { overflow-x: hidden; max-width: 100vw; }
    .page-body { overflow-x: hidden; }
    .card { overflow: hidden; }
    #mobile-nav { overflow: hidden; }
    .mobile-nav-items { overflow: hidden; }
    .stats-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 768px) {
    .card-body a { min-width: 0 !important; max-width: 100% !important; }
    .card-body a div { min-width: 0; overflow: hidden; }
    .card-body a div div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ── ДАШБОРД ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.dash-requests { padding: 8px 12px; }
.dash-req-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px;
    border-radius: var(--r-sm);
    text-decoration: none;
    color: inherit;
    transition: background .15s;
    min-width: 0;
}
.dash-req-item:hover { background: var(--bg); text-decoration: none; color: inherit; }
.dash-req-id {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    background: var(--bg); padding: 2px 7px; border-radius: 20px;
    flex-shrink: 0;
}
.dash-req-body { flex: 1; min-width: 0; }
.dash-req-desc {
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-req-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.dash-req-badge { flex-shrink: 0; }

.building-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.building-row:last-child { border-bottom: none; }
.building-name { font-size: 14px; font-weight: 500; flex-shrink: 0; }
.building-bar-wrap {
    display: flex; align-items: center; gap: 10px;
    flex: 1; justify-content: flex-end;
}
.building-bar {
    width: 80px; height: 6px;
    background: var(--border); border-radius: 3px;
    overflow: hidden; flex-shrink: 0;
}
.building-bar-fill { height: 100%; background: var(--blue); border-radius: 3px; }
.building-count { font-size: 14px; font-weight: 700; min-width: 24px; text-align: right; flex-shrink: 0; }

@media (max-width: 768px) {
    .dashboard-grid { grid-template-columns: 1fr !important; }
    .building-bar { width: 50px; }
    .dash-req-badge { display: inline-flex; }
}

@media (max-width: 768px) {
    .dash-req-item { flex-wrap: nowrap; overflow: hidden; }
    .dash-req-body { overflow: hidden; min-width: 0; }
    .dash-req-id { display: none; }

    .building-row { flex-wrap: nowrap; }
    .building-bar-wrap { flex-shrink: 0; min-width: 0; }
    .building-bar { width: 40px; }
    .building-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
}
