/* --- ДИЗАЙН (app.teyadoors.com) --- */
:root {
    --bg: #f3f4f6;
    --card: #ffffff;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --primary-dark: #1d4ed8;
    --signature-ink: #1d4ed8;
    --signature-bg: #f5f9ff;
    --signature-border: #93b4df;
    --accent: #0f766e;
    --border: #e5e7eb;
    --muted: #6b7280;
    --danger: #b91c1c;
    --text-main: #111827;
    --shadow-soft: 0 12px 30px rgba(15, 23, 42, 0.08);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-pill: 999px;
    --input-height: 42px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 16px;
    font-family: "Carlito", "Montserrat", system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at top left, #e0f2fe 0, #f3f4f6 38%, #e5e7eb 100%);
    color: var(--text-main);
}

.app-shell { max-width: 900px; margin: 0 auto 48px; }

.app-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.brand-block { display: flex; align-items: center; gap: 12px; }
.sync-status { flex: 1 1 auto; min-width: 0; text-align: center; }
.header-user-block { text-align: right; min-width: fit-content; }
.current-user-line { font-size: 11px; color: var(--muted); margin-top: 5px; }

.brand-logo {
    width: 46px; height: 46px; border-radius: 14px;
    background: linear-gradient(135deg, #1e293b, #0f172a);
    display: flex; align-items: center; justify-content: center;
    color: #f9fafb; font-weight: 700; font-size: 20px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.35);
}

.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.brand-subtitle { font-size: 11px; font-weight: 500; text-transform: uppercase; color: var(--muted); letter-spacing: 0.15em; }

.role-test-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 14px;
    background: #1e3a8a;
    color: #ffffff;
    padding: 10px;
    text-align: center;
    font-size: 0.9rem;
    border-bottom: 2px solid #3b82f6;
}

.role-test-main,
.role-test-switch,
.role-test-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
}

.role-test-label { color: #cbd5e1; }
.active-role {
    color: #fcd34d;
    font-weight: 800;
    text-decoration: underline;
}

.role-switch-link,
.admin-tool-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border-radius: 6px;
    padding: 4px 9px;
    color: #ffffff;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.role-switch-link { color: #fcd34d; }
.role-switch-link.admin { color: #6ee7b7; }
.admin-tool-link.users { background: #2563eb; }
.admin-tool-link.clients { background: #0f766e; }
.admin-tool-link.notices { background: #7c3aed; }
.admin-tool-link.permissions { background: #10b981; }

.card { background: rgba(255,255,255,0.95); border-radius: 20px; padding: 20px; box-shadow: var(--shadow-soft); margin-bottom: 16px; border: 1px solid rgba(255,255,255,0.5); }
.card-title { font-size: 16px; font-weight: 600; text-transform: uppercase; margin-bottom: 15px; color: var(--primary-dark); }

.field-input, select.field-input { width: 100%; border-radius: var(--radius-pill); border: 1px solid var(--border); padding: 10px 14px; font-size: 14px; background: #fff; outline: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px 24px; border-radius: var(--radius-pill); border: none; font-weight: 600; cursor: pointer; width: 100%; font-size: 14px; transition: 0.2s; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); }
.btn-primary:active { transform: scale(0.98); }
.btn-danger { background: #fee2e2; color: #b91c1c; width: auto; padding: 8px 16px; font-size: 12px; }
.btn-update { background: #dbeafe; color: #1e40af; width: auto; padding: 8px 16px; font-size: 12px; margin-left: 10px;}
.btn-small-action { margin-left: 10px; width: auto; font-size: 12px; padding: 8px 16px; }

/* Таблица */
.custom-table { width: 100%; border-collapse: collapse; }
.custom-table th { text-align: left; padding: 10px; color: var(--muted); font-size: 11px; text-transform: uppercase; border-bottom: 2px solid var(--border); }
.custom-table td { padding: 12px 10px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.stock-badge { padding: 4px 8px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.stock-ok { background: #dcfce7; color: #15803d; }
.stock-low { background: #fee2e2; color: #b91c1c; }

/* Подпис */
canvas { border: 2px dashed var(--signature-border); border-radius: 12px; width: 100%; height: 160px; background: var(--signature-bg); cursor: crosshair; }

/* Модален прозорец (за добавяне на артикули) */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); align-items: center; justify-content: center; }
.modal-content { background-color: #fefefe; padding: 20px; border-radius: 20px; width: 90%; max-width: 400px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); }
.modal input { width: 100%; margin-bottom: 10px; padding: 10px; border-radius: 8px; border: 1px solid #ddd; }

@media (max-width: 640px) {
    body { padding: 10px; }
    .app-shell {
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        overflow-x: hidden;
        margin-bottom: 32px;
    }
    .app-header {
        display: grid;
        grid-template-columns: 1fr;
        align-items: start;
        gap: 10px;
    }
    .sync-status,
    .header-user-block {
        width: 100%;
        text-align: left;
    }
    .role-test-panel {
        align-items: stretch;
        gap: 8px;
        border-radius: 8px;
        font-size: 13px;
    }
    .role-test-main,
    .role-test-switch,
    .role-test-nav {
        width: 100%;
        justify-content: stretch;
    }
    .role-test-main {
        display: grid;
        grid-template-columns: 1fr;
        text-align: left;
    }
    .role-test-switch,
    .role-test-nav {
        display: grid;
        grid-template-columns: 1fr;
    }
    .role-test-label {
        grid-column: 1 / -1;
        text-align: left;
    }
    .role-switch-link,
    .admin-tool-link {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        min-height: 36px;
        padding: 7px 8px;
        white-space: normal;
        overflow-wrap: anywhere;
        line-height: 1.12;
    }
}

/* ПЕЧАТ */
#print-section { display: none; }
@media print {
    .app-shell, .app-header, .card, button, .modal { display: none !important; }
    @page { size: auto; margin: 10mm; }
    html, body { margin: 0; padding: 0; background: white; }
    #print-section { display: block !important; width: 100%; }
    .print-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
    .print-table th, .print-table td { border: 1px solid #000; padding: 6px; font-size: 12px; color: black; }
    .signatures { display: flex; justify-content: space-between; margin-top: 50px; }
    .sig-box { width: 40%; text-align: center; }
    .sig-img { max-height: 80px; max-width: 100%; }
}
