:root {
    --sidebar-width: 264px;
    --sidebar-bg: #0f172a;
    --sidebar-bg-2: #111c31;
    --accent: #f97316;
    --accent-soft: #fff1e7;
    --ink: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f4f6fa;
    --card: #ffffff;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
}

a { text-decoration: none; }

.app-shell { min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0b1220 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px 16px;
    color: #fff;
    font-weight: 700;
    font-size: 20px;
    letter-spacing: .4px;
}
.brand-mark {
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 11px;
    background: linear-gradient(135deg, #fb923c, #ea580c);
    color: #fff;
    font-size: 18px;
}
.brand-text span { color: var(--accent); }
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px 16px;
    scrollbar-width: thin;
}
.nav-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #64748b;
    padding: 16px 10px 6px;
    font-weight: 700;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #cbd5e1;
    font-size: 13.5px;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.nav-item i { width: 18px; font-size: 15px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
    background: rgba(249, 115, 22, .14);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    color: #e2e8f0; padding: 8px; border-radius: 10px;
}
.sidebar-user:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-user strong { display: block; font-size: 13px; line-height: 1.2; }
.sidebar-user small { color: #94a3b8; font-size: 11px; }

.avatar {
    width: 36px; height: 36px; flex: 0 0 36px;
    border-radius: 50%;
    background: #f97316;
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; text-transform: uppercase;
}
.avatar-sm { width: 28px; height: 28px; flex-basis: 28px; font-size: 12px; }

/* ---------------- Main ---------------- */
.app-main { margin-left: var(--sidebar-width); min-height: 100vh; position: relative; }
/* Полупрозрачная атмосферная подложка: современная светлая ремзона за панелями */
.app-main::before {
    content: "";
    position: fixed;
    inset: 0;
    background-color: #e9eff7;
    background-image: url("https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=Modern%20bright%20high-tech%20auto%20repair%20workshop%20interior%2C%20several%20cars%20on%20lifts%2C%20polished%20light%20grey%20floor%2C%20white%20walls%20with%20blue%20LED%20accents%2C%20dark%20tires%20and%20service%20equipment%2C%20wide-angle%20architectural%20photography%2C%20high%20contrast%2C%20photorealistic%2C%20daylight&image_size=landscape_16_9");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    opacity: .26;
    filter: saturate(1.12) contrast(1.06);
    pointer-events: none;
    z-index: 0;
}
.app-main > * { position: relative; z-index: 1; }
.topbar {
    position: sticky; top: 0; z-index: 1020;
    height: 68px;
    display: flex; align-items: center; gap: 14px;
    padding: 0 28px;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.search-box {
    position: relative;
    flex: 1; max-width: 620px;
    display: flex; align-items: center;
}
.search-box > i {
    position: absolute; left: 14px; color: #94a3b8; pointer-events: none;
}
.search-box input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0 14px 0 40px;
    background: #f8fafc;
    font-size: 13.5px;
    outline: none;
}
.search-box input:focus { border-color: #fdba74; background: #fff; box-shadow: 0 0 0 4px rgba(249,115,22,.08); }
.search-results {
    position: absolute;
    top: 48px; left: 0; right: 0;
    z-index: 1100;
}
.search-results:empty { display: none; }
.search-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    max-height: 70vh;
    overflow-y: auto;
}
.search-section-title {
    font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase;
    color: var(--muted); padding: 10px 14px 4px; font-weight: 700;
}
.search-result {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px; color: var(--ink); font-size: 13px;
}
.search-result:hover { background: #f8fafc; }
.search-result i { color: #94a3b8; }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.btn-icon {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: #475569;
    font-size: 17px;
}
.btn-icon:hover { background: #f1f5f9; color: var(--ink); }
.notification-badge {
    position: absolute; top: 2px; right: 2px;
    min-width: 17px; height: 17px;
    background: #ef4444; color: #fff;
    border-radius: 99px;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 4px;
}
.notifications-menu { width: 340px; padding: 0; border: 1px solid var(--line); box-shadow: var(--shadow); }
.btn-user {
    display: inline-flex; align-items: center; gap: 8px;
    background: transparent; border: 0; color: #334155; font-size: 13px;
    padding: 4px 8px; border-radius: 10px;
}
.btn-user:hover { background: #f1f5f9; }
.btn-accent {
    background: linear-gradient(135deg, #fb923c, #ea580c);
    border: 0; color: #fff; font-weight: 600; font-size: 13px;
    border-radius: 10px; padding: 9px 15px;
    display: inline-flex; align-items: center; gap: 7px;
}
.btn-accent:hover { color: #fff; filter: brightness(1.05); }
.btn-outline-secondary { border-color: var(--line); color: #475569; }
.btn-outline-secondary:hover { background: #f1f5f9; border-color: #cbd5e1; color: var(--ink); }

.app-content { padding: 26px 28px 48px; max-width: 1620px; }

/* ---------------- Headings / cards ---------------- */
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h1 { font-size: 23px; font-weight: 700; margin: 0 0 3px; letter-spacing: -.3px; }
.page-head p { color: var(--muted); margin: 0; font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 14px 18px;
    font-weight: 600;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.kpi {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.kpi .kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.kpi .kpi-value { font-size: 27px; font-weight: 700; line-height: 1.15; margin-top: 6px; }
.kpi .kpi-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi .kpi-icon {
    position: absolute; right: 14px; top: 14px;
    width: 38px; height: 38px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    background: #f8fafc; color: #64748b; font-size: 17px;
}
.kpi.accent .kpi-icon { background: var(--accent-soft); color: #ea580c; }
.kpi.danger .kpi-value { color: #dc2626; }
.kpi.success .kpi-value { color: #059669; }

.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.fw-600 { font-weight: 600; }

/* ---------------- Tables ---------------- */
.table-card { overflow: hidden; }
.table { margin-bottom: 0; font-size: 13px; }
.table > :not(caption) > * > * { padding: 11px 16px; border-bottom-color: #f1f5f9; }
.table thead th {
    background: #f8fafc;
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table tbody tr:hover { background: #fcfdff; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table td .btn { --bs-btn-padding-y: .2rem; --bs-btn-padding-x: .45rem; --bs-btn-font-size: .78rem; }

.badge { font-weight: 600; font-size: 11px; padding: .38em .6em; border-radius: 7px; }
.badge-soft { background: #f1f5f9; color: #475569; }

/* ---------------- Forms ---------------- */
.form-label { font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-control, .form-select {
    border-color: #dbe1ea;
    border-radius: 10px;
    font-size: 13.5px;
    padding: 9px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: #fdba74;
    box-shadow: 0 0 0 4px rgba(249,115,22,.08);
}
.form-control::placeholder { color: #a1a1aa; }
.form-text { font-size: 11.5px; }
.required::after { content: " *"; color: #ef4444; }
.form-card { max-width: 860px; }
.form-actions { display: flex; gap: 8px; margin-top: 20px; }

/* ---------------- Kanban ---------------- */
.kanban {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 12px;
    align-items: flex-start;
}
.kanban-col {
    flex: 0 0 292px;
    background: #eef2f7;
    border-radius: 14px;
    padding: 12px;
    min-height: 260px;
}
.kanban-col-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 2px 4px 10px; font-weight: 700; font-size: 13px;
}
.kanban-col-head .count { background: #fff; border-radius: 20px; padding: 1px 9px; font-size: 11px; color: #64748b; }
.kanban-list { min-height: 60px; display: flex; flex-direction: column; gap: 9px; }
.task-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 11px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(15,23,42,.04);
    cursor: grab;
    color: var(--ink);
    display: block;
}
.task-card:active { cursor: grabbing; }
.task-card:hover { border-color: #fdba74; box-shadow: 0 4px 12px rgba(15,23,42,.08); }
.task-card .task-order { font-size: 11px; color: #94a3b8; font-weight: 600; letter-spacing: .3px; }
.task-card .task-title { font-weight: 600; font-size: 13.5px; margin: 3px 0 7px; line-height: 1.3; }
.task-card .task-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: #64748b; }
.task-card.overdue { border-left: 3px solid #ef4444; }
.sortable-ghost { opacity: .4; }
.sortable-drag { transform: rotate(1.5deg); }

/* ---------------- Misc ---------------- */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: #e2e8f0; }
.timeline-item { position: relative; padding: 0 0 15px 10px; font-size: 12.5px; }
.timeline-item::before {
    content: ""; position: absolute; left: -18px; top: 5px;
    width: 10px; height: 10px; border-radius: 50%;
    background: #fff; border: 2px solid var(--accent);
}

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo-thumb { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 4/3; background: #f1f5f9; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .photo-del { position: absolute; top: 4px; right: 4px; }

.empty {
    text-align: center; padding: 34px 16px; color: var(--muted);
}
.empty i { font-size: 26px; display: block; margin-bottom: 8px; color: #cbd5e1; }

.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.money-lg { font-size: 22px; font-weight: 700; }

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
.detail-grid-3 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: start; }
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13px; }
.info-list dt { color: var(--muted); font-weight: 500; }
.info-list dd { margin: 0; font-weight: 600; }

.tabs-line { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs-line .nav-link { color: var(--muted); border: 0; border-bottom: 2px solid transparent; border-radius: 0; font-size: 13px; font-weight: 600; padding: 10px 14px; white-space: nowrap; }
.tabs-line .nav-link.active { color: var(--ink); border-bottom-color: var(--accent); background: transparent; }

.checklist-section { margin-bottom: 18px; }
.checklist-row {
    display: grid;
    grid-template-columns: 1.4fr auto 1.4fr;
    gap: 10px;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid #f1f5f9;
}
.checklist-row:last-child { border-bottom: 0; }
.status-ok { color: #059669; }
.status-warning { color: #d97706; }
.status-critical { color: #dc2626; }
.status-not_checked { color: #94a3b8; }

.ai-analysis {
    white-space: pre-wrap;
    font-size: 0.92rem;
    line-height: 1.55;
    color: #1e293b;
}

.signature-wrap { border: 2px dashed #cbd5e1; border-radius: 12px; background: #fbfdff; position: relative; }
.signature-wrap canvas { width: 100%; height: 160px; touch-action: none; display: block; }
.signature-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #94a3b8; pointer-events: none; font-size: 13px; }

.messages { max-width: 1000px; }
.alert { border: 0; border-radius: 11px; font-size: 13.5px; }

.progress-thin { height: 5px; border-radius: 99px; background: #eef2f7; }
.progress-thin .progress-bar { border-radius: 99px; }

.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: #0f172a;
}
.login-hero {
    padding: 56px;
    color: #e2e8f0;
    background:
        radial-gradient(900px 500px at 10% 10%, rgba(249,115,22,.22), transparent 60%),
        radial-gradient(700px 400px at 90% 90%, rgba(59,130,246,.16), transparent 60%),
        #0f172a;
    display: flex; flex-direction: column; justify-content: center;
}
.login-hero h1 { font-size: 38px; font-weight: 700; color: #fff; line-height: 1.15; letter-spacing: -.8px; }
.login-hero p { color: #94a3b8; max-width: 480px; font-size: 15px; }
.login-hero .feature { display: flex; gap: 12px; margin-top: 16px; color: #cbd5e1; font-size: 13.5px; }
.login-hero .feature i { color: var(--accent); font-size: 17px; }
.login-panel { display: flex; align-items: center; justify-content: center; background: #f8fafc; padding: 32px; }
.login-card { width: 100%; max-width: 390px; background: #fff; border-radius: 18px; padding: 34px; box-shadow: 0 22px 60px rgba(2,6,23,.12); }

.sidebar-backdrop { display: none; }

@media (max-width: 1199px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid, .detail-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1030;
    }
    .app-main { margin-left: 0; }
    .topbar { padding: 0 14px; }
    .app-content { padding: 18px 14px 40px; }
    .login-page { grid-template-columns: 1fr; }
    .login-hero { display: none; }
}
@media (max-width: 575px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .page-head h1 { font-size: 20px; }
    .checklist-row { grid-template-columns: 1fr; }
}
