:root {
    /* Цветовая палитра */
    --primary: #0066CC; /* Более спокойный корпоративный синий */
    --primary-hover: #0052A3;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;

    /* Фон и текст */
    --body-bg: #f8f9fa; /* Светлый фон */
    --sidebar-bg: #1a202c; /* Более глубокий темный цвет для админки */
    --sidebar-text: #ecf0f1;
    --sidebar-active: #34495e;
    --text-main: #333333;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    
    /* Компоненты */
    --card-bg: #ffffff;
    --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    --input-bg: #ffffff;
    --input-border: #ced4da;
    --radius: 6px;
    --transition: all 0.2s ease-in-out;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
}

body { 
    background: var(--body-bg); 
    color: var(--text-main); 
    display: flex; 
    height: 100vh; 
    overflow: hidden; 
    font-size: 14px;
    line-height: 1.5;
}

a { text-decoration: none; color: inherit; transition: var(--transition); }

/* Sidebar */
.sidebar { 
    width: 280px; 
    background: var(--sidebar-bg); 
    color: var(--sidebar-text); 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0; 
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
    z-index: 100;
}

.brand { 
    padding: 20px; 
    background: rgba(0,0,0,0.2);
}
.brand-title {
    font-weight: 700; 
    font-size: 18px; 
    color: #fff;
    margin-bottom: 5px;
    display: flex;
    align-items: center; 
    gap: 10px; 
}
.brand-desc {
    font-size: 11px;
    color: #a0aec0;
    line-height: 1.4;
}

.menu { flex: 1; padding: 15px 0; overflow-y: auto; }

.menu-category { 
    padding: 20px 25px 10px; 
    font-size: 10px; 
    text-transform: uppercase; 
    color: #718096; 
    font-weight: 700; 
    letter-spacing: 1px;
}

.menu a { 
    display: block;
    padding: 12px 25px; 
    color: #bdc3c7; 
    border-left: 3px solid transparent;
    transition: background 0.2s, color 0.2s;
}
.menu a .menu-item-content {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
    font-size: 14px;
    font-weight: 500;
    color: #e2e8f0;
}
.menu a .menu-item-desc {
    font-size: 11px;
    color: #718096;
    margin-left: 30px; /* отступ под иконку */
    display: block;
    line-height: 1.3;
}

.sidebar-footer {
    padding: 20px;
    background: rgba(0,0,0,0.1);
    border-top: 1px solid rgba(255,255,255,0.05);
}

.menu a i { margin-right: 10px; width: 20px; text-align: center; }

.menu a:hover { color: #fff; background: rgba(255,255,255,0.05); }

.menu a.active { 
    color: #fff; 
    background: var(--sidebar-active); 
    border-left-color: var(--primary);
}

/* Main Content */
.main-content { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}

.header { 
    height: 60px; 
    background: white; 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    align-items: center; 
    padding: 0 30px; 
    justify-content: space-between;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    z-index: 90;
}

.breadcrumbs { font-size: 18px; font-weight: 600; color: var(--text-main); }
.user-menu { display: flex; align-items: center; gap: 20px; font-size: 14px; }
.user-menu a.logout { color: var(--danger); font-weight: 500; }

.page-container { 
    padding: 30px; 
    max-width: 1400px; 
    width: 100%;
    margin: 0 auto;
    overflow-y: auto;
    flex: 1;
}

/* Components */
h1 { font-size: 26px; font-weight: 700; margin-bottom: 25px; color: #2c3e50; }
h3 { font-size: 18px; font-weight: 600; margin-bottom: 15px; color: #34495e; }

.card { 
    background: var(--card-bg); 
    border: 1px solid var(--border-color); 
    border-radius: var(--radius); 
    padding: 25px; 
    margin-bottom: 25px; 
    box-shadow: var(--card-shadow); 
}

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
th { 
    text-align: left; 
    padding: 12px 15px; 
    background: #f8f9fa; 
    border-bottom: 2px solid var(--border-color); 
    font-weight: 600; 
    color: var(--text-muted);
    font-size: 13px;
}
td { 
    padding: 12px 15px; 
    border-bottom: 1px solid var(--border-color); 
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background-color: #f8f9fa; }

/* Buttons */
.btn { 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary); 
    color: white; 
    border: 1px solid transparent; 
    padding: 8px 16px; 
    border-radius: var(--radius); 
    cursor: pointer; 
    font-size: 14px; 
    font-weight: 500;
    transition: var(--transition);
    gap: 5px;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; box-shadow: 0 2px 4px rgba(0,0,0,0.1); opacity: 0.95; }

.btn-secondary { background: #e2e8f0; color: #2d3748; }
.btn-secondary:hover { background: #cbd5e0; color: #1a202c; }

.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: #f7fafc; border-color: #cbd5e0; }

.btn-ghost { background: transparent; color: var(--text-muted); padding: 5px 10px; }
.btn-ghost:hover { background: rgba(0,0,0,0.05); color: var(--text-main); }

.btn-sidebar { 
    width: 100%; 
    background: rgba(255,255,255,0.1); 
    color: #fff; 
    border: 1px solid rgba(255,255,255,0.1);
}
.btn-sidebar:hover { background: rgba(255,255,255,0.2); }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: #555; }
.form-group input, .form-group select, .form-group textarea { 
    width: 100%; 
    padding: 10px 12px; 
    border: 1px solid var(--input-border); 
    border-radius: var(--radius); 
    font-size: 14px; 
    transition: var(--transition);
    background-color: var(--input-bg);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { 
    border-color: var(--primary); 
    outline: none; 
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/* P2P filter panel: unify vertical spacing */
.contracts-panel .contracts-filter-body {
    padding-top: 16px !important;
}
.contracts-panel .contracts-filter-body .form-group {
    margin: 0 0 14px 0 !important; /* one consistent spacing between fields */
}
.contracts-panel .contracts-filter-body .form-group label {
    margin-bottom: 8px !important; /* consistent label-to-field gap */
}
.contracts-panel .contracts-filter-body .form-group:last-of-type {
    margin-bottom: 0 !important;
}

/* Legacy Bootstrap-like "form-horizontal" fallback (keeps layout consistent) */
.form-horizontal .form-group.row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.form-horizontal .form-group.row .control-label.col-lg-3 {
    width: 25%;
    text-align: right;
    padding-right: 15px;
    font-weight: bold;
    color: #333;
}

.form-horizontal .form-group.row .col-lg-9 {
    width: 75%;
}

.form-horizontal .form-group.row .col-lg-3 {
    width: 25%;
}

.form-horizontal .help-block {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

/* Login */
.login-page { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    height: 100vh; 
    background: #f0f2f5; 
}
.login-box { 
    background: white; 
    padding: 40px; 
    border-radius: 8px; 
    width: 400px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.05); 
}
.login-box h2 { text-align: center; color: #2c3e50; margin-bottom: 30px; font-size: 24px; }

/* Badges */
.badge { 
    padding: 4px 8px; 
    border-radius: 4px; 
    font-size: 12px; 
    font-weight: 600; 
}
.badge-gray { background: #e9ecef; color: #495057; }
.badge-blue { background: #e7f5ff; color: #004085; }
.badge-green { background: #d4edda; color: #155724; }
.badge-red { background: #f8d7da; color: #721c24; }

/* Dashboard Widgets */
.hero-block {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--card-shadow);
}
.hero-content h2 { margin-bottom: 10px; font-size: 24px; color: #2d3748; }
.hero-content .subtitle { color: #718096; font-size: 12px; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; margin-bottom: 5px; }
.hero-content p { color: #4a5568; margin-bottom: 20px; max-width: 600px; }

.stat-card {
    background: #f7fafc;
    border-radius: 6px;
    padding: 15px 20px;
    min-width: 160px;
    border: 1px solid #edf2f7;
}
.stat-card .label { font-size: 11px; text-transform: uppercase; color: #718096; font-weight: 600; margin-bottom: 5px; }
.stat-card .value { font-size: 20px; font-weight: 700; color: #2d3748; }

.metric-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--card-shadow);
}
.metric-card .icon { font-size: 24px; color: var(--primary); margin-bottom: 10px; }
.metric-card .number { font-size: 28px; font-weight: 700; color: #2d3748; margin-bottom: 5px; }
.metric-card .label { color: #718096; font-size: 13px; }

.action-card {
    display: block;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: var(--card-shadow);
    height: 100%;
}
.action-card:hover { transform: translateY(-2px); box-shadow: 0 4px 6px rgba(0,0,0,0.05); border-color: #cbd5e0; }
.action-card .header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.action-card .icon { width: 40px; height: 40px; background: #ebf8ff; color: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.action-card h4 { margin: 0; font-size: 16px; font-weight: 600; color: #2d3748; }
.action-card p { margin: 0; font-size: 13px; color: #718096; line-height: 1.4; margin-top: 8px; }
.action-card .arrow { color: #cbd5e0; transition: 0.2s; }
.action-card:hover .arrow { color: var(--primary); transform: translateX(3px); }

/* P2P layout: move left sidebar to top, expand page width */
.layout-p2p-top {
    flex-direction: column;
}

.layout-p2p-top .sidebar {
    width: 100%;
    box-shadow: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    max-height: 120px;
    overflow-y: visible;
}

.layout-p2p-top .menu {
    flex: none;
    overflow-y: hidden;
    overflow-x: auto;
    display: flex;
    flex-wrap: nowrap;
}

.layout-p2p-top .menu-category {
    display: none;
}

.layout-p2p-top .menu a {
    border-left: 0;
    border-top: 0;
    border-bottom: 3px solid transparent;
    flex: 0 0 auto;
    min-width: 0;
    padding: 8px 14px;
    white-space: nowrap;
}

.layout-p2p-top .menu a.active {
    border-left-color: transparent;
    border-bottom-color: var(--primary);
}

.layout-p2p-top .menu a .menu-item-desc {
    display: none;
}

.layout-p2p-top .page-container {
    max-width: none;
    margin: 0;
    padding-left: 16px;
    padding-right: 16px;
}

@media (max-width: 768px) {
    .layout-p2p-top .menu a {
        padding: 8px 12px;
    }
}

/* Compact brand row */
.layout-p2p-top .brand {
    padding: 10px 16px;
}

.layout-p2p-top .brand-desc {
    display: none;
}

.layout-p2p-top .brand-title {
    font-size: 14px;
}

.layout-p2p-top .menu a .menu-item-content {
    font-size: 13px;
}

/* --- P2P notifications & confirm modal (used across p2p + admin) --- */
.alert {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.06);
    font-size: 14px;
    line-height: 1.4;
    background: #fff;
    box-shadow: 0 10px 22px rgba(16, 24, 40, 0.06);
}
.alert-danger {
    background: #fff5f6;
    border-color: rgba(180, 35, 24, 0.18);
    color: #b42318;
}
.alert-success {
    background: #f0fff4;
    border-color: rgba(6, 118, 71, 0.18);
    color: #067647;
}
.alert-warning {
    background: #fffbeb;
    border-color: rgba(240, 140, 0, 0.20);
    color: #b45309;
}

.p2p-confirm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.p2p-confirm-backdrop.is-open {
    display: flex;
}
.p2p-confirm-modal {
    width: 100%;
    max-width: 520px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 18px 48px rgba(0,0,0,0.20);
    overflow: hidden;
}
.p2p-confirm-head {
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #eef2f6;
    display: flex;
    gap: 10px;
    align-items: center;
}
.p2p-confirm-head .icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fee2e2;
    color: #b42318;
    font-weight: 700;
}
.p2p-confirm-body {
    padding: 16px;
    color: #1f2d3d;
    font-size: 14px;
    line-height: 1.5;
}
.p2p-confirm-actions {
    padding: 12px 16px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.p2p-confirm-btn {
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.p2p-confirm-btn.cancel {
    background: #f1f5f9;
    color: #334155;
}
.p2p-confirm-btn.ok {
    background: #ef4444;
    color: #fff;
}
