/* ============================================================
   CRM Platform — app.css
   Минимальный, чистый, без зависимостей
   ============================================================ */

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

:root {
    --c-bg:        #f4f6f9;
    --c-surface:   #ffffff;
    --c-border:    #e2e8f0;
    --c-text:      #1e293b;
    --c-muted:     #64748b;
    --c-primary:   #2563eb;
    --c-primary-h: #1d4ed8;
    --c-success:   #16a34a;
    --c-warning:   #d97706;
    --c-danger:    #dc2626;
    --c-new:       #3b82f6;
    --c-progress:  #f59e0b;
    --c-done:      #22c55e;
    --radius:      8px;
    --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ---------- Layout ---------- */

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

.sidebar {
    width: 220px;
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--c-primary);
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--c-border);
}

.sidebar-nav {
    list-style: none;
    padding: 16px 0;
    flex: 1;
}

.sidebar-nav li a {
    display: block;
    padding: 10px 20px;
    color: var(--c-muted);
    font-size: 14px;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li a.active {
    background: #eff6ff;
    color: var(--c-primary);
    border-left-color: var(--c-primary);
    text-decoration: none;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--c-border);
    font-size: 13px;
    color: var(--c-muted);
}

.sidebar-footer form { margin-top: 6px; }

.main { flex: 1; padding: 32px; overflow-y: auto; }

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header p { color: var(--c-muted); font-size: 14px; }

/* ---------- Cards ---------- */

.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--c-text);
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--c-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--c-muted);
    margin-top: 4px;
}

/* ---------- Таблица ---------- */

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--c-border);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--c-muted);
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--c-border);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* ---------- Формы ---------- */

.form-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-muted);
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--c-text);
    background: var(--c-surface);
    transition: border-color .15s;
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

textarea { min-height: 120px; resize: vertical; }

.error-msg {
    color: var(--c-danger);
    font-size: 12px;
    margin-top: 4px;
}

/* ---------- Кнопки ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, opacity .15s;
    line-height: 1;
}

.btn-primary   { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-h); text-decoration: none; }
.btn-success   { background: var(--c-success); color: #fff; }
.btn-success:hover { opacity: .85; text-decoration: none; }
.btn-danger    { background: var(--c-danger);  color: #fff; }
.btn-danger:hover  { opacity: .85; text-decoration: none; }
.btn-ghost     { background: transparent; color: var(--c-primary); border: 1px solid var(--c-primary); }
.btn-ghost:hover   { background: #eff6ff; text-decoration: none; }
.btn-sm        { padding: 6px 12px; font-size: 13px; }

/* ---------- Бейджи статуса ---------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
}

.badge-new      { background: #dbeafe; color: #1e40af; }
.badge-progress { background: #fef3c7; color: #92400e; }
.badge-done     { background: #dcfce7; color: #166534; }

/* ---------- Алерты ---------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
    border-left: 4px solid;
}

.alert-success { background: #f0fdf4; border-color: var(--c-success); color: #166534; }
.alert-error   { background: #fef2f2; border-color: var(--c-danger);  color: #991b1b; }

/* ---------- Логин-страница ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-bg);
}

.login-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
}

.login-card h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-card p { color: var(--c-muted); font-size: 14px; margin-bottom: 24px; }

/* ---------- Таймер ---------- */

.timer {
    font-size: 32px;
    font-weight: 700;
    color: var(--c-warning);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
}

/* ---------- Баланс ---------- */

.balance-display {
    font-size: 36px;
    font-weight: 800;
    color: var(--c-success);
    letter-spacing: -.02em;
}

/* ---------- Утилиты ---------- */

.text-muted  { color: var(--c-muted); }
.text-sm     { font-size: 13px; }
.text-right  { text-align: right; }
.mt-4        { margin-top: 16px; }
.mt-8        { margin-top: 32px; }
.mb-4        { margin-bottom: 16px; }
.flex        { display: flex; align-items: center; }
.gap-2       { gap: 8px; }
.gap-4       { gap: 16px; }
.justify-between { justify-content: space-between; }
.w-full      { width: 100%; }

/* ============================================================
   НОВЫЕ КОМПОНЕНТЫ — приоритет, тип лица, форма имени
   ============================================================ */

/* ── Двухколоночная форма (Имя / Фамилия) ─────────────────── */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ── Переключатель типа лица ───────────────────────────────── */
.entity-type-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.entity-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-muted);
    background: var(--c-surface);
    transition: border-color .15s, color .15s, background .15s;
    user-select: none;
    flex: 1;
    justify-content: center;
    min-width: 140px;
}

.entity-tab input[type="radio"] {
    display: none;
}

.entity-tab:hover {
    border-color: var(--c-primary);
    color: var(--c-primary);
    background: #eff6ff;
}

.entity-tab.active {
    border-color: var(--c-primary);
    color: var(--c-primary);
    background: #eff6ff;
    font-weight: 600;
}

/* ── Переключатель приоритета ──────────────────────────────── */
.priority-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.priority-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--c-muted);
    background: var(--c-surface);
    transition: border-color .15s, color .15s, background .15s;
    user-select: none;
    flex: 1;
    justify-content: center;
    min-width: 100px;
}

.priority-tab input[type="radio"] {
    display: none;
}

.priority-tab.priority-low.active  { border-color: #6b7280; color: #374151; background: #f9fafb; }
.priority-tab.priority-low:hover   { border-color: #9ca3af; color: #374151; }

.priority-tab.priority-medium.active { border-color: #d97706; color: #92400e; background: #fffbeb; }
.priority-tab.priority-medium:hover  { border-color: #d97706; color: #92400e; }

.priority-tab.priority-high.active { border-color: #dc2626; color: #991b1b; background: #fef2f2; }
.priority-tab.priority-high:hover  { border-color: #ef4444; color: #991b1b; }

/* ── Бейджи приоритета в таблицах/списках ──────────────────── */
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.priority-badge-high {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    box-shadow: 0 0 0 1px rgba(220,38,38,.12);
    animation: pulse-high 2.5s ease-in-out infinite;
}

@keyframes pulse-high {
    0%, 100% { box-shadow: 0 0 0 1px rgba(220,38,38,.12); }
    50%       { box-shadow: 0 0 0 3px rgba(220,38,38,.18); }
}

.priority-badge-medium {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.priority-badge-low {
    background: #f9fafb;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

/* ── Строки с высоким приоритетом в таблице ─────────────────── */
tr.row-priority-high {
    background: #fff8f8 !important;
    border-left: 3px solid #ef4444;
}

tr.row-priority-low {
    opacity: 0.82;
}

/* ── Данные юридического лица ──────────────────────────────── */
.client-legal-badge {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
    padding: 4px 8px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    font-size: 12px;
    color: #0369a1;
    font-weight: 500;
}

.client-legal-badge .text-muted {
    color: #64748b;
    font-weight: 400;
}

/* ── Обязательный маркер ───────────────────────────────────── */
.text-danger { color: var(--c-danger); }

/* ── Карточка инфо клиента в заявке (задача 4) ─────────────── */
.client-info-card {
    background: #f8fafc;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-top: 12px;
    font-size: 13px;
}

.client-info-card .ci-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--c-muted);
    margin-bottom: 6px;
}

.client-info-card .ci-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.client-info-card .ci-field {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.client-info-card .ci-field span:first-child {
    font-size: 11px;
    color: var(--c-muted);
}

.client-info-card .ci-field strong {
    font-size: 14px;
    color: var(--c-text);
}
