/* =============================================
   Mega Mechanika — Portal Shared Styles
   Вынесено из 13 прототипов (prototypes/*.html)
   Mobile-first, min-touch 48px, brand #c2001c
   ============================================= */

/* === RESET + BASE === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: #f4f6f9;
    color: #1f2937;
    padding: 20px;
    -webkit-text-size-adjust: 100%;
}

/* === CSS VARIABLES === */
:root {
    --brand: #c2001c;
    --brand-dark: #a30017;
    --green: #15803d;
    --green-dark: #166534;
    --green-bg: #dcfce7;
    --green-surface: #f0fdf4;
    --red: #9f1239;
    --red-bg: #fee2e2;
    --red-surface: #fff1f2;
    --amber: #92400e;
    --amber-bg: #fef3c7;
    --amber-surface: #fffbeb;
    --blue: #1e40af;
    --blue-bg: #dbeafe;
    --surface: #fff;
    --surface-secondary: #fafbfc;
    --surface-subtle: #f8fafc;
    --bg: #f4f6f9;
    --text: #1f2937;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f1f5f9;
    --input-border: #d1d5db;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;
    --touch-min: 48px;
    --shadow-card: 0 12px 30px rgba(31, 41, 55, 0.12);
}

/* === CONTAINER === */
.container {
    max-width: 880px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

/* === HEADER === */
.header {
    background: var(--brand);
    color: #fff;
    padding: 18px 24px;
}
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.header h1 { font-size: 18px; font-weight: 700; margin-bottom: 0; }
.header .order-id { font-size: 13px; opacity: 0.9; }
.header .vehicle-info { font-size: 12px; opacity: 0.85; margin-top: 4px; }
.header-logo { height: 36px; width: auto; filter: brightness(0) invert(1); opacity: 0.9; }

/* === BREADCRUMBS === */
.breadcrumbs {
    padding: 10px 24px;
    background: var(--surface-secondary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 11px;
}
.bc-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    border-radius: 50%;
    text-decoration: none;
    font-weight: 600;
    font-size: 10px;
}
.bc-step.done    { background: var(--green-bg); color: var(--green); }
.bc-step.current { background: var(--brand); color: #fff; }
.bc-step.partial { background: var(--amber-bg); color: var(--amber); }
.bc-step.planned { background: var(--border-light); color: var(--text-faint); }
.bc-arrow { color: var(--input-border); font-size: 10px; }

/* === RUNNING TOTAL BAR === */
.running-total {
    background: #fff5f5;
    border-bottom: 1px solid #fecaca;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}
.rt-label { color: var(--text-muted); }
.rt-amount { font-size: 18px; font-weight: 700; color: var(--brand); }
.rt-breakdown { font-size: 11px; color: var(--text-faint); }

/* === CONTENT BODY === */
.body { padding: 20px 24px; }

/* === SECTION === */
.section { margin-bottom: 20px; }
.section-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--brand);
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Section with border (old style for 01-04) */
.section-bordered {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

/* Collapsible section group */
.section-group { margin-bottom: 8px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.section-header {
    display: flex; align-items: center; gap: 10px; padding: 14px 16px;
    background: var(--surface-subtle); cursor: pointer; user-select: none;
    min-height: var(--touch-min);
}
.section-header:hover { background: var(--border-light); }
.section-icon { font-size: 18px; }
.section-count { font-size: 12px; color: var(--text-muted); }
.section-chevron { color: var(--text-faint); font-size: 12px; transition: transform 0.2s; }
.section-group.open .section-chevron { transform: rotate(180deg); }
.section-body { display: none; padding: 12px; border-top: 1px solid var(--border); }
.section-group.open .section-body { display: block; }

/* === BUTTONS === */
.btn {
    border: none; padding: 12px 18px; border-radius: var(--radius-sm);
    font-weight: 700; cursor: pointer; font-size: 13px; font-family: inherit;
    min-height: var(--touch-min);
}
.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--border); color: #111827; }
.btn-small     { padding: 8px 12px; font-size: 12px; min-height: 36px; }

/* Pill buttons (newer) */
.nav-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px; border: 1px solid var(--input-border);
    border-radius: var(--radius-pill); font-size: 13px; font-weight: 600;
    text-decoration: none; color: var(--text); background: var(--surface);
    cursor: pointer; font-family: inherit; min-height: var(--touch-min);
}
.nav-btn:hover { background: var(--border-light); }
.nav-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.nav-btn.primary:hover { background: var(--brand-dark); }
.nav-btn.primary:disabled, .nav-btn.primary[disabled] { background: var(--text-faint); border-color: var(--text-faint); cursor: not-allowed; opacity: 0.7; }
.nav-btn.green { background: var(--green); color: #fff; border-color: var(--green); }
.nav-btn.green:hover { background: var(--green-dark); }

/* Status buttons (pill toggles) */
.status-btn {
    border: 1px solid var(--border); background: var(--surface);
    border-radius: var(--radius-pill); padding: 6px 14px;
    font-size: 11px; cursor: pointer; font-weight: 600; font-family: inherit;
    min-height: 36px;
}
.status-btn:hover { border-color: var(--brand); color: var(--brand); }
.status-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* === STAGE NAV (footer) === */
.stage-nav {
    display: flex; justify-content: space-between;
    padding: 16px 24px; border-top: 1px solid var(--border-light);
    background: var(--surface-secondary); flex-wrap: wrap; gap: 8px;
}

/* === BADGES / TAGS === */
.badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 10px; font-weight: 700; }
.badge-critical { background: var(--red-bg); color: var(--red); }
.badge-section { background: var(--blue-bg); color: var(--blue); }

.tag { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; }
.tag-green  { background: var(--green-bg); color: var(--green-dark); }
.tag-red    { background: var(--red-bg); color: #991b1b; }
.tag-yellow { background: var(--amber-bg); color: var(--amber); }
.tag-blue   { background: var(--blue-bg); color: var(--blue); }
.tag-gray   { background: #f3f4f6; color: var(--text-muted); }

/* Status badges */
.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: var(--radius-pill);
    font-size: 10px; font-weight: 700; text-transform: uppercase; white-space: nowrap;
}
.status-badge.needed   { background: var(--border-light); color: var(--text-muted); }
.status-badge.ordered  { background: var(--blue-bg); color: var(--blue); }
.status-badge.transit  { background: var(--amber-bg); color: var(--amber); }
.status-badge.received { background: var(--green-bg); color: var(--green-dark); }
.status-badge.skipped  { background: var(--red-bg); color: #991b1b; }

/* === DATA TABLE === */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.data-table th {
    background: var(--border-light); padding: 8px 10px; text-align: left;
    font-weight: 700; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted);
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border-light); }
.data-table tr:hover { background: var(--surface-secondary); }
.data-table tfoot td { font-weight: 700; border-top: 2px solid var(--border); padding-top: 10px; }
.subtotal-row td { background: var(--surface-subtle); font-weight: 600; }
.grand-total-row td { background: var(--amber-bg); font-weight: 700; font-size: 14px; }

/* === CHECKLIST ITEM === */
.checklist-item {
    display: flex; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border-light); align-items: flex-start;
}
.checklist-item:last-child { border-bottom: none; }
.check-box { width: 20px; height: 20px; accent-color: var(--brand); margin-top: 2px; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 13px; font-weight: 600; }
.item-meta  { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.item-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.item-comment {
    width: 200px; min-height: 50px; font-size: 11px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 6px; resize: vertical; font-family: inherit;
}

/* === PHOTO === */
.photo-btn {
    border: 1px solid var(--input-border); border-radius: var(--radius-pill);
    padding: 4px 12px; font-size: 11px; font-weight: 700; cursor: pointer;
    background: var(--surface); display: inline-flex; align-items: center; gap: 4px;
    min-height: 36px;
}
.photo-btn input[type="file"] { display: none; }
.photo-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-preview img {
    width: 80px; height: 60px; object-fit: cover;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
}

/* Dashed label photo (03-osmotr, 08-defektovka style) */
.photo-label {
    border: 1px dashed var(--border); border-radius: var(--radius-pill);
    padding: 4px 10px; font-size: 11px; font-weight: 700;
    cursor: pointer; color: #111827; background: var(--surface);
    display: inline-flex; align-items: center; gap: 4px;
    min-height: 36px;
}
.photo-label input[type="file"] { display: none; }

/* Gallery grid */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-subtle); }
.gallery-thumb { height: 100px; background: var(--border); display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--text-faint); }
.gallery-caption { padding: 6px 8px; font-size: 10px; color: var(--text-muted); line-height: 1.3; }

/* === HINTS / WARNINGS === */
.hint { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.hint-warning {
    color: var(--amber); background: var(--amber-surface);
    border: 1px solid #fcd34d; padding: 8px 10px;
    border-radius: var(--radius-sm);
}

/* === CASCADE BLOCK === */
.cascade-block {
    background: var(--amber-surface); border: 1px solid #fde68a;
    border-radius: var(--radius-sm); padding: 10px 12px;
    margin-bottom: 12px; font-size: 12px;
}
.cascade-label { font-weight: 700; color: var(--amber); margin-bottom: 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; }
.cascade-text { color: #78350f; line-height: 1.4; }

/* === INPUTS === */
input, textarea, select {
    font-family: inherit;
    font-size: 13px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    padding: 10px;
    width: 100%;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(194, 0, 28, 0.1);
}

/* === TIMER === */
.timer-widget {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 24px; background: #f0f9ff;
    border-bottom: 1px solid #e0f2fe; font-size: 12px;
}
.timer-value { font-size: 16px; font-weight: 700; font-family: monospace; color: #0369a1; }
.timer-norm  { font-size: 11px; color: var(--text-muted); }
.timer-btn {
    border: 1px solid #bae6fd; background: var(--surface);
    border-radius: var(--radius-pill); padding: 2px 10px;
    cursor: pointer; font-size: 11px;
}

/* === SIGNATURE === */
.signature-block {
    border: 2px dashed var(--border); border-radius: var(--radius-md);
    padding: 16px; text-align: center; margin-bottom: 12px;
}
.signature-block.signed { border-color: var(--green); border-style: solid; background: var(--green-surface); }
.signature-block h3 { font-size: 14px; margin-bottom: 10px; }
.sig-canvas {
    border: 1px solid var(--input-border); border-radius: var(--radius-sm);
    background: var(--surface-secondary); cursor: crosshair;
    max-width: 100%; display: block; margin: 0 auto;
    touch-action: none;
}
.sig-canvas.has-signature { border-color: #86efac; border-style: solid; }
.sig-row { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.sig-name {
    padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 13px; width: 260px;
}
.sig-date { font-size: 12px; color: var(--text-muted); padding: 8px 12px; background: var(--surface-subtle); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.sig-actions { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.sig-btn {
    background: var(--brand); color: #fff; border: none;
    border-radius: var(--radius-pill); padding: 8px 24px;
    font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
    min-height: var(--touch-min);
}
.sig-btn:hover { background: var(--brand-dark); }
.sig-btn.clear { background: var(--surface); color: var(--text-muted); border: 1px solid var(--input-border); }
.sig-btn.clear:hover { background: #f3f4f6; }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-faint); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* === PRINT === */
@media print {
    body { background: #fff; padding: 0; }
    .container { box-shadow: none; border-radius: 0; }
    .stage-nav, .canvas-actions, .decision-btns, .sig-actions { display: none; }
    .section-body { display: block !important; }
    .cascade-block { break-inside: avoid; }
    .running-total { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* === RESPONSIVE — MOBILE FIRST === */
@media (max-width: 768px) {
    body { padding: 8px; }
    .container { border-radius: var(--radius-md); }
    .header { padding: 14px 16px; }
    .header-row { flex-direction: column; align-items: flex-start; }
    .body { padding: 14px 16px; }
    .breadcrumbs { padding: 8px 16px; overflow-x: auto; flex-wrap: nowrap; }
    .running-total { padding: 8px 16px; flex-wrap: wrap; }
    .stage-nav { padding: 12px 16px; }
    .checklist-item { flex-direction: column; }
    .item-actions { align-items: flex-start; flex-direction: row; gap: 8px; }
    .item-comment { width: 100%; }
    .sig-name { width: 100%; }
    .data-table { display: block; overflow-x: auto; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    input, textarea, select { font-size: 16px; } /* prevent iOS zoom */
}
