:root {
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-text: #1f2430;
    --color-muted: #6b7280;
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-ok: #16a34a;
    --color-error: #dc2626;
    --radius: 10px;
    --gap: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
}

.guest-body {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.guest-container {
    width: 100%;
    max-width: 380px;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.login-card h1 {
    font-size: 1.3rem;
    margin: 0 0 4px;
}

.form-actions--stretch {
    justify-content: stretch;
}

.form-actions--stretch .btn {
    width: 100%;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    padding: 14px 20px;
    background: var(--color-surface);
    border-bottom: 1px solid #e5e7eb;
}

.app-header__brand {
    font-weight: 600;
    font-size: 1.1rem;
}

.app-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.app-nav a {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
}

.app-nav a:hover {
    color: var(--color-primary);
}

.app-header__user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-header__user form {
    display: inline;
}

.app-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

.dashboard h1 {
    margin-bottom: 8px;
}

.dashboard > p {
    color: var(--color-muted);
    margin-top: 0;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap);
    margin: 24px 0;
}

.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.card h2 {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: var(--color-muted);
    font-weight: 500;
}

.card__value {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
}

.panel {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn:hover {
    background: var(--color-primary-dark);
}

.health-status__list {
    list-style: none;
    padding: 0;
    margin: 16px 0 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.health-status__item {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.health-status__item.is-ok {
    background: #dcfce7;
    color: var(--color-ok);
}

.health-status__item.is-error {
    background: #fee2e2;
    color: var(--color-error);
}

.btn--secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid #d1d5db;
}

.btn--secondary:hover {
    background: #f3f4f6;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-link--danger {
    color: var(--color-error);
}

.panel-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--gap);
    margin-bottom: 16px;
}

.panel-header h1 {
    margin: 0 0 6px;
}

.muted {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    margin-right: 8px;
}

.badge--ok {
    background: #dcfce7;
    color: var(--color-ok);
}

.badge--muted {
    background: #e5e7eb;
    color: var(--color-muted);
}

.table-wrap {
    overflow-x: auto;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

.table th,
.table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid #eef0f2;
    font-size: 0.92rem;
}

.table th {
    color: var(--color-muted);
    font-weight: 500;
    font-size: 0.82rem;
    text-transform: uppercase;
}

.table-empty {
    text-align: center;
    color: var(--color-muted);
    padding: 24px !important;
}

.table-actions {
    text-align: right;
}

/* Модальное окно */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}

.modal {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 20px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.modal__header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.modal__close {
    background: none;
    border: none;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-muted);
}

/* Формы */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
}

.form-row {
    display: flex;
    gap: var(--gap);
}

.form-row .form-group {
    flex: 1 1 0;
}

.form-error {
    color: var(--color-error);
    font-size: 0.85rem;
    margin: 6px 0 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
}

.modal--wide {
    max-width: 620px;
}

/* Фильтры списка работ */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: var(--gap);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.filters select,
.filters input {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
}

.status-select {
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* Панель массового выставления счёта */
.bulk-bar {
    margin-top: var(--gap);
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.bulk-bar form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.bulk-bar input[type="text"] {
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
}

/* Карточка клиента */
.card-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gap);
}

.section {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.section h2 {
    margin: 0 0 12px;
    font-size: 1rem;
}

.entity-list {
    list-style: none;
    margin: 0 0 14px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.entity-list li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eef0f2;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-form input,
.inline-form select {
    flex: 1 1 140px;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
}

.guest-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.guest-link-row input {
    flex: 1 1 240px;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* Планшет */
@media (max-width: 900px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* Мобильный */
@media (max-width: 600px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .app-container {
        padding: 16px;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal {
        max-width: 100%;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn,
    .form-actions .btn--secondary {
        width: 100%;
        text-align: center;
    }

    .entity-list li {
        flex-direction: column;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .filters,
    .filters select,
    .filters input {
        width: 100%;
    }

    .bulk-bar form {
        flex-direction: column;
        align-items: stretch;
    }
}
