* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f4f5f7;
    color: #1f2430;
}
a { color: #1a56db; text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.container.narrow { max-width: 700px; }

/* Top bar */
.topbar { background: #1f2937; color: #fff; }
.topbar-inner {
    max-width: 1200px; margin: 0 auto; padding: 14px 20px;
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.topbar .brand { color: #fff; font-weight: 600; font-size: 18px; }
.topbar nav { display: flex; gap: 18px; flex: 1; align-items: center; }
.topbar nav a { color: #d1d5db; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav .btn-accent {
    background: #1a56db;
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    transition: background .15s;
}
.topbar nav .btn-accent:hover { background: #1543ad; text-decoration: none; color: #fff; }
.user-box { display: flex; align-items: center; gap: 14px; font-size: 14px; color: #d1d5db; }
.user-box a { color: #f87171; }
.mobile-menu-toggle { display: none; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
    background: #fff; padding: 40px; border-radius: 10px; width: 320px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08); display: flex; flex-direction: column; gap: 14px;
}
.login-box h1 { font-size: 18px; margin: 0 0 10px; text-align: center; }

/* Forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #4b5563; margin-bottom: 12px; }
input, select, button {
    font-family: inherit; font-size: 14px; padding: 9px 11px;
    border: 1px solid #d1d5db; border-radius: 6px; background: #fff;
}
button { background: #1a56db; color: #fff; border: none; cursor: pointer; font-weight: 500; }
button:hover { background: #1543ad; }
input[readonly] { background: #f3f4f6; color: #6b7280; cursor: not-allowed; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 6px; }
.btn-cancel { color: #6b7280; }
.btn-link { background: none; border: none; color: #1a56db; cursor: pointer; padding: 0; font-size: 13px; }
.hint { font-size: 12px; color: #9ca3af; margin-top: 10px; }

/* Cards */
.card, .card-form { background: #fff; border-radius: 10px; padding: 22px 24px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.card h2, .card-form h2 { font-size: 15px; color: #374151; margin: 0 0 14px; }
.card h1 { margin-top: 0; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.info-grid div { display: flex; flex-direction: column; gap: 3px; }
.info-grid span { font-size: 12px; color: #9ca3af; }
.info-grid b { font-size: 14px; font-weight: 500; }

/* Page head / search */
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.export-links { font-size: 13px; color: #6b7280; }
.search-form { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-form input[type=text] { flex: 1; min-width: 200px; }
.btn-clear { align-self: center; font-size: 13px; }
.results-count { font-size: 13px; color: #6b7280; margin: 0 0 10px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid #eef0f3; }
.data-table th { background: #f9fafb; color: #6b7280; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.data-table.small th, .data-table.small td { font-size: 12px; padding: 8px 10px; }
.data-table .empty { text-align: center; color: #9ca3af; padding: 30px; }
.debt { color: #dc2626; font-weight: 600; }

.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a { padding: 6px 11px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; color: #374151; }
.pagination a.active { background: #1a56db; color: #fff; border-color: #1a56db; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

.back-link { display: inline-block; margin-bottom: 14px; font-size: 13px; }

/* Documents */
.doc-list { list-style: none; padding: 0; margin: 0 0 16px; }
.doc-list li { padding: 8px 0; border-bottom: 1px solid #f0f1f3; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }
.doc-meta { font-size: 12px; color: #9ca3af; }
.inline-form { display: flex; gap: 10px; align-items: center; }

.add-service-details { margin-top: 16px; }
.data-table .category-row td {
    background: #eef1f6; font-weight: 600; font-size: 12px; color: #4b5563;
    text-transform: uppercase; letter-spacing: .3px; padding: 8px 12px;
}
.add-service-details summary { cursor: pointer; color: #1a56db; font-weight: 500; margin-bottom: 12px; }

/* ============================================================
   МОБІЛЬНА АДАПТИВНІСТЬ
   ============================================================ */

/* Планшет і менше */
@media (max-width: 860px) {
    .container { padding: 16px 14px 50px; }
    .info-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* Телефон */
@media (max-width: 640px) {
    input, select, button, textarea { font-size: 16px; }

    .container { padding: 14px 12px 40px; }
    .container.narrow { max-width: 100%; }

    /* Шапка сайту: компактний burger тільки на телефоні */
    .topbar-inner {
        position: relative;
        padding: 12px 14px;
        gap: 0;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    .topbar .brand {
        font-size: 16px;
        line-height: 1.25;
        max-width: calc(100% - 56px);
    }
    .mobile-menu-toggle {
        display: inline-flex;
        width: 44px;
        height: 44px;
        min-height: 44px;
        padding: 0;
        border: 1px solid rgba(255,255,255,.22);
        border-radius: 9px;
        background: rgba(255,255,255,.06);
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 5px;
        flex: 0 0 44px;
    }
    .mobile-menu-toggle:hover { background: rgba(255,255,255,.12); }
    .mobile-menu-toggle span {
        display: block;
        width: 20px;
        height: 2px;
        border-radius: 2px;
        background: #fff;
        transition: transform .2s ease, opacity .2s ease;
    }
    .topbar nav,
    .topbar .user-box {
        display: none;
        flex-basis: 100%;
        width: 100%;
    }
    .topbar.menu-open nav {
        display: flex;
        order: 3;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid rgba(255,255,255,.12);
        font-size: 14px;
    }
    .topbar.menu-open nav a {
        display: block;
        width: 100%;
        padding: 11px 12px;
        border-radius: 7px;
    }
    .topbar.menu-open nav a:not(.btn-accent):hover { background: rgba(255,255,255,.07); }
    .topbar.menu-open nav .btn-accent {
        width: 100%;
        padding: 11px 12px;
        text-align: left;
    }
    .topbar.menu-open .user-box {
        display: flex;
        order: 4;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 12px;
        margin-top: 8px;
        border-top: 1px solid rgba(255,255,255,.12);
        font-size: 12px;
    }
    .topbar.menu-open .mobile-menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .topbar.menu-open .mobile-menu-toggle span:nth-child(2) { opacity: 0; }
    .topbar.menu-open .mobile-menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* Форми: два поля в рядок -> один стовпчик */
    .row-2 { grid-template-columns: 1fr; gap: 0; }
    label { margin-bottom: 14px; }
    input, select, button {
        padding: 11px 12px;
        min-height: 44px;
    }
    .card, .card-form { padding: 16px; }
    .form-actions { flex-wrap: wrap; }
    .form-actions button, .form-actions a { width: 100%; text-align: center; }
    .inline-form { flex-wrap: wrap; }
    .inline-form.wrap input[type=text] { width: 100%; }
    .inline-form.wrap button { width: 100%; }

    /* Пошук і шапка списку - в стовпчик */
    .page-head { flex-direction: column; align-items: flex-start; }
    .search-form { flex-direction: column; align-items: stretch; }
    .search-form select, .search-form input[type=text] { width: 100%; }
    .btn-clear { align-self: flex-start; }

    /* Таблиці -> картки замість горизонтального скролу */
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table {
        background: transparent; box-shadow: none; border-radius: 0;
    }
    .data-table tr {
        background: #fff; border-radius: 10px; margin-bottom: 12px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.06); padding: 4px 14px; border-bottom: none;
    }
    .data-table td {
        display: flex; justify-content: space-between; align-items: center;
        gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0f1f3; text-align: right;
    }
    .data-table td:last-child { border-bottom: none; }
    .data-table td::before {
        content: attr(data-label); font-weight: 500; color: #6b7280;
        font-size: 12px; text-align: left; flex-shrink: 0;
    }
    .data-table td[data-label=""]::before { content: none; }
    .data-table td[data-label=""] { justify-content: center; }
    .data-table .empty { background: #fff; border-radius: 10px; padding: 24px; }

    /* Пагінація */
    .pagination { flex-wrap: wrap; justify-content: center; }
    .pagination a { min-width: 40px; text-align: center; padding: 8px 10px; }

    /* Документи */
    .doc-list li { flex-direction: column; align-items: flex-start; }

    /* Логін по центру, повна ширина з відступами */
    .login-box { width: 100%; max-width: 320px; margin: 0 16px; padding: 28px 22px; }
}
