/* ============================================================
   CRM Шиномонтаж — Industrial Dashboard Theme
   Тёмный индустриальный стиль с оранжевыми акцентами
   ============================================================ */

:root {
    --bg-base: #1a1d23;
    --bg-sidebar: #14161b;
    --bg-card: #22252d;
    --bg-input: #2a2d36;
    --bg-hover: #2d303a;
    --border: #2d3039;
    --border-light: #383b46;

    --text: #e4e6ea;
    --text-muted: #8b8fa3;
    --text-heading: #f0f1f5;

    --accent: #f0883e;
    --accent-hover: #e07a32;
    --accent-dim: rgba(240, 136, 62, 0.12);

    --blue: #4a9eff;
    --green: #34c759;
    --red: #e74c3c;
    --yellow: #f0a03e;
    --purple: #a78bfa;

    --radius: 8px;
    --radius-sm: 5px;
    --shadow: 0 2px 12px rgba(0,0,0,0.25);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ---- Login page ---- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #14161b 0%, #1e2130 50%, #1a1d23 100%);
}

.login-box {
    width: 400px;
    max-width: 95vw;
    padding: 40px 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text-heading); margin-bottom: 4px; }
.login-logo p { color: var(--text-muted); font-size: 13px; }

.login-form .field { margin-bottom: 16px; }
.login-form .field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-muted); }

.btn-full { width: 100%; justify-content: center; margin-top: 8px; }

/* ---- App Layout ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}
.brand-icon { display: flex; align-items: center; color: var(--accent); }
.nav-icon { flex-shrink: 0; opacity: 0.7; transition: opacity 0.15s; }
.sidebar-nav li a:hover .nav-icon,
.sidebar-nav li a.active .nav-icon { opacity: 1; }
.panel-icon { flex-shrink: 0; vertical-align: middle; margin-right: 6px; }
.brand-text { font-size: 16px; font-weight: 700; color: var(--text-heading); }

.sidebar-nav { flex: 1; }
.sidebar-nav ul { list-style: none; padding: 12px 0; }
.sidebar-nav li { padding: 0; }
.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    font-size: 13.5px;
    color: var(--text);
    transition: background 0.15s;
    border-left: 3px solid transparent;
}
.sidebar-nav li a:hover { background: var(--bg-hover); color: var(--text-heading); }
.sidebar-nav li a.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}
.nav-section {
    padding: 16px 20px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

/* ---- Main area ---- */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---- Topbar ---- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 28px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text-heading); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { font-size: 13px; color: var(--text); }
.topbar-user em { color: var(--text-muted); font-style: normal; font-size: 12px; }

/* ---- Content ---- */
.content {
    padding: 24px 28px;
    flex: 1;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 20px;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header .page-title { margin-bottom: 0; }
.header-actions { display: flex; gap: 8px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    color: var(--text);
    background: transparent;
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); color: var(--text-heading); }
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-danger { color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { color: var(--green); border-color: var(--green); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-outline { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-warn { color: var(--yellow); border-color: var(--yellow); }

/* ---- Flash messages ---- */
.flash {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
}
.flash-success { background: rgba(52,199,89,0.12); color: var(--green); border: 1px solid rgba(52,199,89,0.25); }
.flash-error { background: rgba(231,76,60,0.12); color: var(--red); border: 1px solid rgba(231,76,60,0.25); }
.flash-info { background: rgba(74,158,255,0.10); color: var(--blue); border: 1px solid rgba(74,158,255,0.20); }

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-light); }
.stat-number { font-size: 26px; font-weight: 700; color: var(--text-heading); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-warn .stat-number { color: var(--yellow); }
.stat-danger .stat-number { color: var(--red); }
.stat-success .stat-number { color: var(--green); }

/* ---- Dash Grid ---- */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.dash-panel h2 { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--text-heading); }

/* ---- Tables ---- */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:hover { background: var(--bg-hover); }
.table-sm th, .table-sm td { padding: 7px 10px; font-size: 12.5px; }
.table-total td { border-top: 2px solid var(--border); padding-top: 12px; }
.cell-actions { white-space: nowrap; display: flex; gap: 4px; align-items: center; }
.cell-warn { color: var(--yellow); font-weight: 600; }
.row-warn { background: rgba(240,160,62,0.04); }
.row-inactive { opacity: 0.5; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-new { background: rgba(74,158,255,0.15); color: var(--blue); }
.badge-in_progress { background: rgba(240,160,62,0.15); color: var(--yellow); }
.badge-done { background: rgba(52,199,89,0.15); color: var(--green); }
.badge-paid { background: rgba(52,199,89,0.20); color: var(--green); }
.badge-cancelled { background: rgba(231,76,60,0.12); color: var(--red); }
.badge-draft { background: rgba(139,143,163,0.12); color: var(--text-muted); }
.badge-ordered { background: rgba(74,158,255,0.12); color: var(--blue); }
.badge-received { background: rgba(52,199,89,0.12); color: var(--green); }
.badge-summer { background: rgba(240,136,62,0.12); color: var(--accent); }
.badge-winter { background: rgba(74,158,255,0.12); color: var(--blue); }
.badge-all_season { background: rgba(167,139,250,0.12); color: var(--purple); }

/* ---- Forms ---- */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.field { margin-bottom: 14px; }
.field label {
    display: block;
    margin-bottom: 5px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 13.5px;
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s;
    font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.field textarea { resize: vertical; min-height: 60px; }
.field select { cursor: pointer; }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ---- Search & filter ---- */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.search-bar input {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.search-bar input:focus { outline: none; border-color: var(--accent); }
.search-bar select {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.filter-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-bar .btn-sm { padding: 4px 12px; }

/* ---- Detail card ---- */
.detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 600px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-item { display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted); font-weight: 600; }
.detail-value { font-size: 14px; color: var(--text); }
.detail-notes {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ---- Delete form ---- */
.delete-form { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.status-actions { margin: 20px 0; padding: 16px 0; border-top: 1px solid var(--border); }
.status-actions h3 { font-size: 14px; margin-bottom: 10px; color: var(--text-heading); }

/* ---- Procurement items ---- */
.procurement-item-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.procurement-item-row input {
    padding: 7px 10px;
    font-size: 13px;
    color: var(--text);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.procurement-item-row input:focus { outline: none; border-color: var(--accent); }
.item-total { font-size: 13px; color: var(--text-muted); min-width: 100px; white-space: nowrap; }

/* ---- Empty state ---- */
.empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* ---- Stock summary ---- */
.stock-summary {
    display: flex;
    gap: 24px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    flex-wrap: wrap;
}
.text-warn { color: var(--yellow); }
.text-danger { color: var(--red); }

/* ---- Misc ---- */
h2 { font-size: 16px; font-weight: 600; margin: 20px 0 12px; color: var(--text-heading); }
h3 { font-size: 14px; font-weight: 600; margin: 18px 0 10px; color: var(--text-heading); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .content { padding: 16px; }
    .topbar { padding: 10px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
