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

/* ══════════════════════════════════════════════════════════════
   CSS RESET & BASE
   ══════════════════════════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f4f6f9;
    color: #1e293b;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}
a { color: #6366f1; text-decoration: none; transition: color .2s; }
a:hover { color: #4f46e5; }
img { max-width: 100%; }
table { border-collapse: collapse; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ══════════════════════════════════════════════════════════════
   LAYOUT — SIDEBAR
   ══════════════════════════════════════════════════════════════ */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 260px; background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform .3s ease;
    overflow-y: auto;
}
.sidebar-logo {
    padding: 20px 24px; font-size: 20px; font-weight: 700;
    color: #6366f1; display: flex; align-items: center; gap: 8px;
    border-bottom: 1px solid #f0f0f0;
}
.sidebar-logo span { font-size: 26px; }
.sidebar-logo small { font-size: 11px; color: #94a3b8; font-weight: 400; margin-left: 4px; }
.sidebar-nav { flex: 1; padding: 12px; }
.nav-section-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: #94a3b8; letter-spacing: .5px;
    padding: 16px 12px 6px; margin-top: 4px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 8px;
    color: #475569; font-weight: 500; font-size: 14px;
    transition: all .15s; cursor: pointer; margin-bottom: 2px;
}
.nav-item:hover { background: #f1f5f9; color: #1e293b; }
.nav-item.active { background: #6366f1; color: #fff; }
.nav-item.active:hover { background: #4f46e5; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.sidebar-footer {
    padding: 16px 20px; border-top: 1px solid #f0f0f0;
    display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 99;
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT — MAIN CONTENT
   ══════════════════════════════════════════════════════════════ */
.main-content { margin-left: 260px; min-height: 100vh; }
.header-bar {
    background: #fff; padding: 14px 28px;
    border-bottom: 1px solid #e5e7eb;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}
.header-bar h1 { font-size: 18px; font-weight: 600; color: #1e293b; }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #64748b; }
.sidebar-toggle {
    display: none; background: none; border: none;
    font-size: 22px; cursor: pointer; color: #475569; margin-right: 14px;
}
.content-body { padding: 24px 28px; }

/* ══════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════ */
.card {
    background: #fff; border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    padding: 24px; margin-bottom: 20px;
    transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: #1e293b; }

/* ══════════════════════════════════════════════════════════════
   STAT CARDS
   ══════════════════════════════════════════════════════════════ */
.stats-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: #fff; border-radius: 12px; padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    display: flex; align-items: center; gap: 16px;
    border-left: 4px solid transparent;
    transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.blue { border-left-color: #6366f1; }
.stat-card.green { border-left-color: #10b981; }
.stat-card.orange { border-left-color: #f59e0b; }
.stat-card.red { border-left-color: #ef4444; }
.stat-card.purple { border-left-color: #8b5cf6; }
.stat-icon {
    width: 48px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue { background: #eef2ff; color: #6366f1; }
.stat-icon.green { background: #ecfdf5; color: #10b981; }
.stat-icon.orange { background: #fffbeb; color: #f59e0b; }
.stat-icon.red { background: #fef2f2; color: #ef4444; }
.stat-icon.purple { background: #f5f3ff; color: #8b5cf6; }
.stat-number { font-size: 28px; font-weight: 700; line-height: 1; color: #1e293b; }
.stat-label { font-size: 13px; color: #94a3b8; margin-top: 2px; }

/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: 8px; font-weight: 500;
    border: none; cursor: pointer; transition: all .15s;
    font-size: 14px; text-decoration: none;
}
.btn:hover { filter: brightness(.95); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover { background: #4f46e5; color: #fff; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-outline { background: transparent; border: 1px solid #e2e8f0; color: #475569; }
.btn-outline:hover { background: #f8fafc; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-telegram { background: #0088cc; color: #fff; }
.btn-telegram:hover { background: #006da3; color: #fff; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-weight: 500; margin-bottom: 6px;
    color: #374151; font-size: 14px;
}
.form-label .required { color: #ef4444; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px; border: 1px solid #e2e8f0;
    border-radius: 8px; background: #fff; color: #1e293b;
    transition: border-color .2s, box-shadow .2s; font-size: 14px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.form-input.error { border-color: #ef4444; }
.form-error { color: #ef4444; font-size: 12px; margin-top: 4px; }
.form-hint { color: #94a3b8; font-size: 12px; margin-top: 4px; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: #6366f1; }

/* ══════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════ */
.table-container { overflow-x: auto; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    background: #f8f9fb; padding: 12px 16px; font-weight: 600;
    font-size: 13px; color: #64748b; text-align: left;
    border-bottom: 1px solid #e5e7eb; white-space: nowrap;
    position: sticky; top: 0;
}
.data-table td {
    padding: 12px 16px; border-bottom: 1px solid #f1f5f9;
    font-size: 14px; color: #334155;
}
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:nth-child(even) { background: #fafbfc; }
.data-table tbody tr:nth-child(even):hover { background: #f1f5f9; }

/* Request & Response rows */
.request-row { cursor: pointer; }
.request-row td { font-weight: 600; color: #1e293b; }
.request-row .expand-icon { transition: transform .2s; display: inline-block; }
.request-row.expanded .expand-icon { transform: rotate(90deg); }
.response-row { display: none; }
.response-row.visible { display: table-row; }
.response-row td { padding-left: 40px; font-weight: 400; background: #f8fdf8; }
.response-row td:first-child { border-left: 3px solid #d1d5db; }
.response-row.min-price td { background: #ecfdf5; }
.response-row.min-price td:first-child { border-left-color: #10b981; }
.response-row.chosen td { background: #eef2ff; }
.response-row.chosen td:first-child { border-left-color: #6366f1; }
.response-row.new-response td { animation: pulseNew 1s ease infinite; }

/* ══════════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex; align-items: center; padding: 3px 10px;
    border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge-open { background: #ecfdf5; color: #059669; }
.badge-closed { background: #fef2f2; color: #dc2626; }
.badge-new { background: #fffbeb; color: #d97706; animation: pulseNew 1.5s ease infinite; }
.badge-superadmin { background: #f5f3ff; color: #7c3aed; }
.badge-manager { background: #eef2ff; color: #4f46e5; }
.badge-carrier { background: #ecfdf5; color: #059669; }
.badge-grain { background: #fef9c3; color: #a16207; }
.badge-export { background: #fce7f3; color: #be185d; }
.badge-all { background: #e0e7ff; color: #3730a3; }

/* ══════════════════════════════════════════════════════════════
   ALERTS
   ══════════════════════════════════════════════════════════════ */
.alert {
    padding: 14px 18px; border-radius: 10px; margin-bottom: 16px;
    display: flex; align-items: flex-start; gap: 10px; font-size: 14px;
}
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; }

/* ══════════════════════════════════════════════════════════════
   TABS
   ══════════════════════════════════════════════════════════════ */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e5e7eb; margin-bottom: 20px; }
.tab-btn {
    padding: 10px 20px; font-weight: 500; color: #64748b;
    border: none; background: none; cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: all .15s; font-size: 14px;
}
.tab-btn:hover { color: #6366f1; }
.tab-btn.active { color: #6366f1; border-bottom-color: #6366f1; font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ══════════════════════════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════════════════════════ */
.filter-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 0; margin-bottom: 16px; flex-wrap: wrap;
}
.filter-btn {
    padding: 7px 14px; border: 1px solid #e2e8f0; border-radius: 8px;
    background: #fff; color: #475569; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all .15s;
}
.filter-btn:hover { border-color: #6366f1; color: #6366f1; }
.filter-btn.active { background: #6366f1; color: #fff; border-color: #6366f1; }

/* ══════════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════════ */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 200;
    align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff; border-radius: 14px; padding: 28px;
    max-width: 500px; width: 100%; max-height: 90vh; overflow-y: auto;
    animation: fadeIn .2s ease;
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ══════════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════════ */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: 10px; color: #fff;
    font-size: 14px; font-weight: 500; min-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    animation: slideIn .3s ease; display: flex; align-items: center; gap: 8px;
}
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.info { background: #6366f1; }
.toast.warning { background: #f59e0b; }

/* ══════════════════════════════════════════════════════════════
   AVATAR
   ══════════════════════════════════════════════════════════════ */
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: #6366f1; color: #fff; display: flex;
    align-items: center; justify-content: center;
    font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }

/* ══════════════════════════════════════════════════════════════
   AUTH PAGES
   ══════════════════════════════════════════════════════════════ */
.auth-wrapper {
    min-height: 100vh; display: flex; align-items: center;
    justify-content: center; padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.auth-container {
    background: #fff; border-radius: 16px; padding: 40px;
    max-width: 440px; width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.auth-logo {
    text-align: center; margin-bottom: 28px;
}
.auth-logo h1 { font-size: 28px; color: #6366f1; }
.auth-logo p { color: #94a3b8; margin-top: 6px; font-size: 14px; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: #64748b; }

/* ══════════════════════════════════════════════════════════════
   PREVIEW AREA
   ══════════════════════════════════════════════════════════════ */
.preview-area {
    background: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 10px; padding: 20px; margin: 16px 0;
    white-space: pre-wrap; font-family: 'Courier New', monospace;
    font-size: 13px; line-height: 1.7; max-height: 400px;
    overflow-y: auto; color: #334155;
}

/* ══════════════════════════════════════════════════════════════
   CONTEXT MENU
   ══════════════════════════════════════════════════════════════ */
.context-menu {
    display: none; position: fixed; background: #fff;
    border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
    border: 1px solid #e5e7eb; padding: 6px; z-index: 250; min-width: 180px;
}
.context-menu.active { display: block; }
.context-menu-item {
    padding: 8px 14px; border-radius: 6px; cursor: pointer;
    font-size: 13px; display: flex; align-items: center; gap: 8px;
    transition: background .1s;
}
.context-menu-item:hover { background: #f1f5f9; }

/* ══════════════════════════════════════════════════════════════
   REQUEST CLOSED BANNER
   ══════════════════════════════════════════════════════════════ */
.request-closed-banner {
    text-align: center; padding: 60px 20px;
}
.request-closed-banner .icon { font-size: 64px; margin-bottom: 16px; }
.request-closed-banner h2 { color: #ef4444; margin-bottom: 8px; }
.request-closed-banner p { color: #64748b; }

/* ══════════════════════════════════════════════════════════════
   QUICK ACTIONS
   ══════════════════════════════════════════════════════════════ */
.quick-actions {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px;
}
.quick-action-card {
    background: #fff; border-radius: 12px; padding: 20px;
    text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: all .2s; cursor: pointer; text-decoration: none; color: #1e293b;
}
.quick-action-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.1); }
.quick-action-card .icon { font-size: 32px; margin-bottom: 8px; }
.quick-action-card .label { font-weight: 500; font-size: 14px; }

/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════════ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulseNew { 0%, 100% { opacity: 1; } 50% { opacity: .6; background: #fef3c7; } }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: calc(200px + 100%) 0; } }
.fade-in { animation: fadeIn .3s ease; }

/* ══════════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════════ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-success { color: #10b981; }
.text-danger { color: #ef4444; }
.text-warning { color: #f59e0b; }
.text-muted { color: #94a3b8; }
.text-primary { color: #6366f1; }
.fw-600 { font-weight: 600; }
.fs-sm { font-size: 13px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.p-1 { padding: 8px; } .p-2 { padding: 16px; } .p-3 { padding: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.visible { display: block !important; }
.cursor-pointer { cursor: pointer; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — TABLET
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .header-bar { padding: 12px 16px; }
    .header-bar h1 { font-size: 16px; }
    .content-body { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .btn-group { flex-direction: column; }
    .btn-group .btn { width: 100%; justify-content: center; }
    .filter-bar { gap: 6px; }
    .filter-btn { padding: 6px 10px; font-size: 12px; }
    .data-table th, .data-table td { padding: 10px 12px; font-size: 13px; }
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab-btn { white-space: nowrap; padding: 10px 14px; font-size: 13px; }
    .modal { padding: 20px; margin: 10px; }
    .auth-container { padding: 28px 20px; }
}

@media (max-width: 480px) {
    .stat-card { padding: 14px 16px; }
    .stat-number { font-size: 22px; }
    .stat-icon { width: 40px; height: 40px; font-size: 18px; }
    .header-user span { display: none; }
    .content-body { padding: 12px; }
}
