/* =========================================
   Villart Partner CRM — Стили (mobile-first)
   ========================================= */

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: #f5f6fa; color: #2c3e50; line-height: 1.5; min-height: 100vh; }
a { color: #3498db; text-decoration: none; }
a:hover { color: #2980b9; text-decoration: underline; }
hr { border: none; border-top: 1px solid #eee; margin: 15px 0; }
code { background: #f0f0f0; padding: 2px 6px; border-radius: 3px; font-size: 0.9em; }

/* --- Auth Pages --- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, #2c3e50, #3498db); }
.auth-container { width: 100%; max-width: 420px; }
.auth-card { background: #fff; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.2); padding: 40px 30px; }
.auth-header { text-align: center; margin-bottom: 30px; }
.auth-header h1 { font-size: 1.5rem; color: #2c3e50; margin: 10px 0 5px; }
.auth-header p { color: #7f8c8d; font-size: .9rem; }
.auth-icon { font-size: 2.5rem; color: #3498db; }
.auth-hint { text-align: center; color: #95a5a6; font-size: .8rem; margin-top: 15px; }

/* --- Layout --- */
.sidebar { position: fixed; top: 0; left: 0; width: 250px; height: 100vh; background: #2c3e50; color: #ecf0f1; z-index: 1000; overflow-y: auto; transition: transform .3s; transform: translateX(-100%); }
.sidebar.open { transform: translateX(0); }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; display: none; }
.sidebar-overlay.active { display: block; }
.sidebar-header { padding: 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand { font-size: 1.3rem; font-weight: 700; color: #fff; }
.sidebar-logo { max-height: 40px; }
.sidebar-nav { padding: 10px 0; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: #bdc3c7; transition: all .2s; text-decoration: none; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(52,152,219,.3); color: #fff; border-left: 3px solid #3498db; }
.nav-item i { width: 20px; text-align: center; }
.nav-divider { border-top: 1px solid rgba(255,255,255,.1); margin: 10px 0; }
.nav-group-title { padding: 8px 20px; font-size: .75rem; text-transform: uppercase; color: #7f8c8d; letter-spacing: 1px; }

.main-wrapper { transition: margin-left .3s; }
.topbar { display: flex; align-items: center; gap: 15px; padding: 12px 20px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); position: sticky; top: 0; z-index: 100; }
.topbar-title { font-size: 1.1rem; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn-burger { background: none; border: none; font-size: 1.3rem; color: #2c3e50; cursor: pointer; padding: 5px; }
.content { padding: 20px; }
.footer { padding: 15px 20px; text-align: center; color: #95a5a6; font-size: .8rem; border-top: 1px solid #eee; }

/* Desktop sidebar */
@media (min-width: 768px) {
    .sidebar { transform: translateX(0); }
    .sidebar-overlay { display: none !important; }
    .main-wrapper { margin-left: 250px; }
    .btn-burger { display: none; }
    .content { padding: 25px; }
}

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border: none; border-radius: 6px; font-size: .9rem; font-weight: 500; cursor: pointer; transition: all .2s; text-decoration: none; line-height: 1.4; white-space: nowrap; }
.btn:hover { text-decoration: none; opacity: .9; transform: translateY(-1px); }
.btn-primary { background: #3498db; color: #fff; }
.btn-primary:hover { background: #2980b9; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #219a52; color: #fff; }
.btn-warning { background: #f39c12; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-outline { background: transparent; border: 1px solid #ddd; color: #555; }
.btn-outline:hover { border-color: #3498db; color: #3498db; }
.btn-block { display: flex; justify-content: center; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-xs { padding: 4px 8px; font-size: .75rem; }
.btn-icon { background: none; border: none; font-size: 1.2rem; color: #555; cursor: pointer; position: relative; padding: 5px; }

/* --- Cards --- */
.card { background: #fff; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.06); margin-bottom: 20px; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid #f0f0f0; flex-wrap: wrap; gap: 10px; }
.card-header h3 { font-size: 1rem; font-weight: 600; display: flex; align-items: center; gap: 8px; margin: 0; }
.card-header h3 i { color: #3498db; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 20px; }

/* --- Dashboard Cards --- */
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
.dash-card { background: #fff; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.06); padding: 20px; display: flex; align-items: center; gap: 15px; }
.dash-card-icon { width: 50px; height: 50px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.3rem; flex-shrink: 0; }
.dash-card-number { font-size: 1.4rem; font-weight: 700; color: #2c3e50; }
.dash-card-label { font-size: .8rem; color: #7f8c8d; }

.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 20px; }
@media (min-width: 768px) { .dashboard-grid { grid-template-columns: 1fr 1fr; } }

/* --- Tables --- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { background: #f8f9fa; padding: 10px 12px; text-align: left; font-weight: 600; color: #555; border-bottom: 2px solid #eee; white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.table-striped tbody tr:nth-child(even) { background: #fafbfc; }
.table tbody tr:hover { background: #f0f7ff; }
.table-sm td, .table-sm th { padding: 6px 10px; font-size: .85rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.row-inactive { opacity: .5; }

/* --- Badges --- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: .75rem; font-weight: 600; color: #fff; white-space: nowrap; }
.badge-primary { background: #3498db; }
.badge-lg { padding: 5px 14px; font-size: .85rem; }

/* --- Forms --- */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; font-size: .9rem; color: #555; }
.form-control { display: block; width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: .9rem; font-family: inherit; transition: border-color .2s; background: #fff; }
.form-control:focus { outline: none; border-color: #3498db; box-shadow: 0 0 0 3px rgba(52,152,219,.15); }
textarea.form-control { resize: vertical; }
select.form-control { appearance: auto; }
.form-control-color { width: 45px; height: 38px; padding: 3px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 20px; }
@media (min-width: 600px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 15px; border-top: 1px solid #eee; flex-wrap: wrap; }
.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-inline { display: flex; gap: 15px; align-items: center; flex-wrap: wrap; }
.form-static { padding: 10px 12px; background: #f8f9fa; border-radius: 6px; font-weight: 600; font-size: 1rem; color: #2c3e50; }
.checkbox-label { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* --- Filters --- */
.filters { padding: 15px 20px; background: #fafbfc; border-bottom: 1px solid #f0f0f0; }
.filters-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters-row .form-control { flex: 1; min-width: 150px; }
.filters-row .btn { flex-shrink: 0; }

/* --- Alerts --- */
.alert { padding: 12px 20px; border-radius: 8px; margin: 10px 20px; display: flex; align-items: center; gap: 10px; font-size: .9rem; cursor: pointer; animation: slideIn .3s ease; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; }
.alert-close { margin-left: auto; background: none; border: none; font-size: 1.2rem; cursor: pointer; opacity: .5; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Notifications --- */
.notif-wrapper { position: relative; }
.notif-badge { position: absolute; top: -2px; right: -2px; background: #e74c3c; color: #fff; font-size: .65rem; font-weight: 700; padding: 1px 5px; border-radius: 10px; min-width: 16px; text-align: center; }
.notif-dropdown { position: absolute; right: 0; top: 100%; width: 320px; background: #fff; border-radius: 10px; box-shadow: 0 5px 30px rgba(0,0,0,.15); display: none; z-index: 200; overflow: hidden; }
.notif-dropdown.open { display: block; }
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; border-bottom: 1px solid #eee; }
.notif-header a { font-size: .8rem; }
.notif-list { max-height: 300px; overflow-y: auto; }
.notif-footer { display: block; text-align: center; padding: 10px; border-top: 1px solid #eee; font-size: .85rem; }
.notif-item { display: flex; gap: 12px; padding: 12px 15px; border-bottom: 1px solid #f5f5f5; color: #555; text-decoration: none; transition: background .2s; }
.notif-item:hover { background: #f8f9fa; text-decoration: none; color: #555; }
.notif-unread { background: #f0f7ff; }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; background: #ecf5ff; display: flex; align-items: center; justify-content: center; color: #3498db; flex-shrink: 0; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: .85rem; color: #2c3e50; }
.notif-message { font-size: .8rem; color: #7f8c8d; margin-top: 2px; }
.notif-time { font-size: .75rem; color: #bdc3c7; margin-top: 3px; }
.notif-empty { padding: 20px; text-align: center; color: #95a5a6; }

/* --- Profile dropdown --- */
.profile-wrapper { position: relative; }
.btn-profile { display: flex; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; font-size: .9rem; color: #555; padding: 5px; }
.btn-profile i:first-child { font-size: 1.4rem; color: #3498db; }
.profile-name { display: none; }
@media (min-width: 600px) { .profile-name { display: inline; } }
.profile-dropdown { position: absolute; right: 0; top: 100%; width: 220px; background: #fff; border-radius: 10px; box-shadow: 0 5px 30px rgba(0,0,0,.15); display: none; z-index: 200; overflow: hidden; }
.profile-dropdown.open { display: block; }
.profile-info { padding: 12px 15px; border-bottom: 1px solid #eee; }
.profile-info strong { display: block; }
.profile-info small { color: #95a5a6; }
.profile-dropdown a { display: flex; align-items: center; gap: 8px; padding: 10px 15px; color: #555; transition: background .2s; text-decoration: none; }
.profile-dropdown a:hover { background: #f8f9fa; text-decoration: none; }
.text-danger { color: #e74c3c !important; }

/* --- Stage Progress --- */
.stage-progress { display: flex; overflow-x: auto; gap: 0; padding: 10px 0; }
.stage-step { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 80px; position: relative; }
.stage-step::after { content: ''; position: absolute; top: 16px; left: 50%; width: 100%; height: 2px; background: #e0e0e0; z-index: 0; }
.stage-step:last-child::after { display: none; }
.stage-step.passed::after { background: #27ae60; }
.stage-step.current::after { background: linear-gradient(to right, #27ae60 50%, #e0e0e0 50%); }
.stage-dot { width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 3px solid #e0e0e0; display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; z-index: 1; color: #999; transition: all .3s; }
.stage-step.passed .stage-dot { background: #27ae60; border-color: #27ae60; color: #fff; }
.stage-step.current .stage-dot { border-width: 3px; transform: scale(1.2); color: #fff; box-shadow: 0 0 0 4px rgba(52,152,219,.2); }
.stage-label { font-size: .65rem; color: #999; text-align: center; margin-top: 6px; line-height: 1.2; max-width: 90px; }
.stage-step.current .stage-label, .stage-step.passed .stage-label { color: #2c3e50; font-weight: 600; }

/* --- Detail Grid --- */
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 20px; }
@media (min-width: 768px) { .detail-grid { grid-template-columns: 1fr 1fr; } }

/* --- Info rows --- */
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f5f5f5; }
.info-label { color: #7f8c8d; font-size: .85rem; flex-shrink: 0; margin-right: 10px; }

/* --- Finance --- */
.finance-summary { display: flex; flex-wrap: wrap; gap: 15px; }
.finance-item { flex: 1; min-width: 140px; padding: 15px; background: #f8f9fa; border-radius: 8px; text-align: center; }
.finance-label { font-size: .8rem; color: #7f8c8d; display: block; }
.finance-value { font-size: 1.2rem; font-weight: 700; display: block; margin-top: 5px; }
.finance-highlight { background: #fff3f3; border: 1px solid #f8d7da; }
.finance-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f5f5f5; }
.finance-total { border-bottom: none; padding-top: 15px; margin-top: 5px; border-top: 2px solid #eee; }

/* --- Timeline --- */
.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: #e0e0e0; }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot { position: absolute; left: -26px; top: 4px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }
.timeline-title { font-weight: 600; font-size: .9rem; }
.timeline-meta { font-size: .8rem; color: #95a5a6; margin-top: 2px; }
.timeline-comment { font-size: .85rem; color: #666; margin-top: 4px; background: #f8f9fa; padding: 6px 10px; border-radius: 6px; }

/* --- Comments --- */
.comment { padding: 12px; border-radius: 8px; margin-bottom: 10px; }
.comment-internal { background: #f8f9fa; border-left: 3px solid #95a5a6; }
.comment-public { background: #eafaf1; border-left: 3px solid #27ae60; }
.comment-header { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.comment-date { font-size: .8rem; color: #95a5a6; }
.comment-visibility { font-size: .8rem; color: #bdc3c7; }
.comment-text { font-size: .9rem; line-height: 1.5; }

/* --- Documents --- */
.doc-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f5f5f5; }
.doc-icon { width: 36px; height: 36px; background: #ecf5ff; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #3498db; flex-shrink: 0; }
.doc-info { flex: 1; }
.doc-info a { font-weight: 500; }
.doc-info small { display: block; color: #95a5a6; }
.doc-visibility { color: #bdc3c7; }

/* --- Funnel --- */
.funnel-item { margin-bottom: 8px; }
.funnel-label { font-size: .8rem; color: #555; margin-bottom: 3px; }
.funnel-bar-wrapper { background: #f0f0f0; border-radius: 4px; height: 24px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 4px; display: flex; align-items: center; padding: 0 8px; color: #fff; font-size: .75rem; font-weight: 600; min-width: 24px; transition: width .5s; }

/* --- Manager load --- */
.manager-load-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f5f5f5; }

/* --- Pagination --- */
.pagination { display: flex; justify-content: center; gap: 4px; margin-top: 15px; flex-wrap: wrap; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid #ddd; border-radius: 6px; font-size: .85rem; color: #555; text-decoration: none; transition: all .2s; }
.page-link:hover { background: #3498db; color: #fff; border-color: #3498db; text-decoration: none; }
.page-link.active { background: #3498db; color: #fff; border-color: #3498db; font-weight: 600; }
.page-dots { display: flex; align-items: center; padding: 0 5px; color: #999; }
.pagination-info { text-align: center; font-size: .8rem; color: #95a5a6; margin-top: 8px; }

/* --- Stage row (set editor) --- */
.stage-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #f5f5f5; flex-wrap: wrap; }
.stage-row .form-control { flex: 1; min-width: 150px; }
.stage-handle { color: #ccc; cursor: grab; }

/* --- Settings nav --- */
.settings-nav { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Client header --- */
.client-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.client-info-main { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
.client-info-main h2 { font-size: 1.3rem; }
.client-actions { display: flex; gap: 8px; }

/* --- Utilities --- */
.text-muted { color: #95a5a6; }
.text-primary { color: #3498db; }
.text-success { color: #27ae60; }
.text-warning { color: #f39c12; }
.mb-10 { margin-bottom: 10px; }
.mb-15 { margin-bottom: 15px; }
.mb-20 { margin-bottom: 20px; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }

/* --- Mobile adjustments --- */
@media (max-width: 480px) {
    .auth-card { padding: 25px 20px; }
    .dashboard-cards { grid-template-columns: 1fr 1fr; }
    .dash-card { padding: 12px; gap: 10px; }
    .dash-card-icon { width: 40px; height: 40px; font-size: 1rem; }
    .dash-card-number { font-size: 1.1rem; }
    .finance-summary { flex-direction: column; }
    .filters-row { flex-direction: column; }
    .filters-row .form-control { min-width: auto; }
    .stage-progress { gap: 0; }
    .stage-step { min-width: 60px; }
    .detail-grid { grid-template-columns: 1fr; }
}
