* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Arial, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f3f6fb;
    color: #1f2937;
    font-size: 20px;
    line-height: 1.45;

    /* Отступ снизу, чтобы контент не прятался под нижним меню */
    padding-bottom: 145px;
}

.app {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 18px;
}

h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.15;
}

h2 {
    margin-top: 0;
    font-size: 26px;
}

.card {
    background: #ffffff;
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

.login-wrap {
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
}

label {
    display: block;
    font-weight: 700;
    margin-top: 18px;
    margin-bottom: 8px;
}

input,
select,
textarea {
    width: 100%;
    font-size: 20px;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid #bfdbfe;
    border-color: #3b82f6;
}

.btn {
    width: 100%;
    min-height: 56px;
    border: 0;
    border-radius: 14px;
    font-size: 22px;
    font-weight: 700;
    margin-top: 22px;
    cursor: pointer;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:active {
    background: #1d4ed8;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:active {
    background: #991b1b;
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
}

.btn-warning:active {
    background: #b45309;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin: 16px 0;
    font-weight: 700;
}

.alert-red {
    background: #fee2e2;
    color: #991b1b;
}

.alert-green {
    background: #dcfce7;
    color: #166534;
}

.muted,
.small-muted {
    color: #64748b;
}

.small-muted {
    font-size: 16px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #e2e8f0;
    color: #0f172a;
    text-decoration: none;
    font-size: 17px;
    font-weight: 700;
}

.hello strong {
    font-size: 24px;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.stat {
    color: #0f172a;
}

.stat-label {
    font-size: 18px;
    font-weight: 700;
}

.stat-value {
    font-size: 44px;
    font-weight: 800;
    line-height: 1.1;
    margin-top: 8px;
}

.stat-sub {
    margin-top: 6px;
    color: #475569;
    font-size: 17px;
}

.blue {
    border-left: 8px solid #2563eb;
}

.green {
    border-left: 8px solid #16a34a;
}

.yellow {
    border-left: 8px solid #f59e0b;
}

.todo {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.todo-item {
    padding: 14px;
    border-radius: 12px;
    background: #f1f5f9;
}

.todo-item.done {
    background: #dcfce7;
    color: #166534;
    font-weight: 700;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-item {
    display: block;
    padding: 18px;
    border-radius: 14px;
    background: #fff;
    text-decoration: none;
    color: #1f2937;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
    font-weight: 700;
}

.menu-item.disabled {
    opacity: 0.55;
}

.btn-link {
    display: block;
    width: 100%;
    padding: 18px;
    margin-bottom: 16px;
    border-radius: 16px;
    background: #2563eb;
    color: #fff;
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.tenant-card.inactive {
    opacity: 0.65;
    background: #f8fafc;
}

.tenant-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.status {
    white-space: nowrap;
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 800;
}

.status-green {
    background: #dcfce7;
    color: #166534;
}

.status-gray {
    background: #e5e7eb;
    color: #374151;
}

.status-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-red {
    background: #fee2e2;
    color: #991b1b;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 16px;
}

.info-grid > div {
    padding: 12px;
    border-radius: 12px;
    background: #f8fafc;
}

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.btn-small {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    font-weight: 700;
}

.btn-small.secondary {
    background: #e2e8f0;
    color: #0f172a;
}

.form-card h2 {
    margin-top: 26px;
}

.form-card h2:first-child {
    margin-top: 0;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
}

.checkbox-row input {
    width: 26px;
    height: 26px;
}

.checkbox-row label {
    margin: 0;
}

.note {
    margin-top: 16px;
    padding: 14px;
    border-radius: 12px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 17px;
}

.mini-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid #e2e8f0;
}

.mini-row:last-child {
    border-bottom: 0;
}

.reading-card {
    border-left: 8px solid #cbd5e1;
}

.reading-filled {
    border-left-color: #16a34a;
}

.reading-error {
    border-left-color: #dc2626;
    background: #fff1f2;
}

.report-text {
    width: 100%;
    min-height: 260px;
    font-size: 22px;
    line-height: 1.5;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    white-space: pre-wrap;
}

.period-card {
    border-left: 8px solid #2563eb;
}

.big-period {
    font-size: 34px;
    font-weight: 900;
    color: #1d4ed8;
    margin: 6px 0 14px 0;
}

.balance-warning {
    border-left: 8px solid #dc2626;
}

/* =========================
   Крупное нижнее меню
========================= */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;

    display: flex;
    gap: 10px;
    overflow-x: auto;

    padding: 12px 12px calc(16px + env(safe-area-inset-bottom));

    background: #ffffff;
    border-top: 2px solid #cbd5e1;
    box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.20);

    -webkit-overflow-scrolling: touch;
}

.bottom-nav-item {
    min-width: 116px;
    flex: 0 0 auto;

    min-height: 78px;
    padding: 10px 12px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    border-radius: 18px;

    background: #f1f5f9;
    color: #0f172a;

    text-decoration: none;
    font-weight: 800;
    border: 1px solid #dbe3ef;
}

.bottom-nav-item span {
    display: block;
    font-size: 32px;
    line-height: 1;
    margin-bottom: 7px;
}

.bottom-nav-item small {
    display: block;
    font-size: 17px;
    line-height: 1.1;
    white-space: nowrap;
}

.bottom-nav-item:active {
    background: #dbeafe;
    transform: scale(0.98);
}

.bottom-nav-item:hover {
    background: #e0f2fe;
}

/* =========================
   Адаптация под широкий экран
========================= */

@media (min-width: 680px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
.status-yellow {
    background: #fef3c7;
    color: #92400e;
}
.contract-danger {
    border-left: 10px solid #dc2626;
    background: #fff7f7;
}

.contract-warning {
    border-left: 10px solid #f59e0b;
    background: #fffbeb;
}

.contract-ok {
    border-left: 10px solid #16a34a;
}

.contract-danger h2,
.contract-warning h2,
.contract-ok h2 {
    margin-bottom: 12px;
}

.contract-danger .status,
.contract-warning .status,
.contract-ok .status {
    font-size: 18px;
    padding: 10px 14px;
}
.top-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.user-pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
}
.table-scroll {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.data-table th,
.data-table td {
    border: 1px solid #cbd5e1;
    padding: 8px 10px;
    white-space: nowrap;
    background: #fff;
}

.data-table th {
    background: #e2e8f0;
    font-weight: 800;
}
.invoice-widget {
    margin-top: 18px;
    box-shadow: none;
    border: 1px solid #e2e8f0;
}

.invoice-widget h2 {
    font-size: 22px;
    margin-bottom: 14px;
}

.invoice-ok {
    background: #f0fdf4;
    border-left: 8px solid #16a34a;
}

.invoice-debt {
    background: #fff7f7;
    border-left: 8px solid #dc2626;
}
/* =========================
   Адаптация для телефонов Android
========================= */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

img,
table,
input,
select,
textarea,
button {
    max-width: 100%;
}

@media (max-width: 480px) {
    body {
        font-size: 18px;
        padding-bottom: 118px;
    }

    .app {
        padding: 12px;
        max-width: 100%;
    }

    h1 {
        font-size: 28px;
        word-break: break-word;
    }

    h2 {
        font-size: 22px;
    }

    .card {
        padding: 16px;
        border-radius: 16px;
        margin-bottom: 12px;
    }

    .topbar {
        gap: 10px;
        margin-bottom: 14px;
    }

    .logout {
        min-height: 42px;
        padding: 8px 12px;
        font-size: 16px;
        border-radius: 12px;
    }

    .small-muted {
        font-size: 14px;
    }

    input,
    select,
    textarea {
        font-size: 18px;
        padding: 14px;
        border-radius: 12px;
    }

    label {
        font-size: 18px;
        margin-top: 14px;
    }

    .btn {
        min-height: 52px;
        font-size: 20px;
        border-radius: 13px;
        margin-top: 18px;
    }

    .btn-link {
        padding: 16px;
        font-size: 20px;
        border-radius: 14px;
    }

    .grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .stat-value {
        font-size: 32px;
        line-height: 1.15;
        word-break: break-word;
    }

    .stat-label {
        font-size: 16px;
    }

    .stat-sub {
        font-size: 15px;
    }

    .big-period {
        font-size: 28px;
        word-break: break-word;
    }

    .tenant-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .status {
        font-size: 15px;
        padding: 8px 12px;
    }

    .info-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .info-grid > div {
        padding: 10px;
    }

    .mini-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-actions {
        flex-direction: column;
        gap: 8px;
    }

    .btn-small {
        width: 100%;
        min-height: 48px;
        font-size: 17px;
    }

    .report-text {
        font-size: 18px;
        min-height: 220px;
    }

    .note {
        font-size: 16px;
        padding: 12px;
    }

    .menu-item {
        padding: 16px;
        font-size: 18px;
    }

    /*
     * Нижнее меню на телефоне
     */
    .bottom-nav {
        gap: 8px;
        padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
    }

    .bottom-nav-item {
        min-width: 88px;
        min-height: 66px;
        padding: 8px 8px;
        border-radius: 14px;
    }

    .bottom-nav-item span {
        font-size: 25px;
        margin-bottom: 5px;
    }

    .bottom-nav-item small {
        font-size: 13px;
    }
}

/* Очень узкие экраны */
@media (max-width: 380px) {
    body {
        font-size: 17px;
    }

    h1 {
        font-size: 26px;
    }

    .stat-value {
        font-size: 28px;
    }

    .bottom-nav-item {
        min-width: 82px;
    }

    .bottom-nav-item small {
        font-size: 12px;
    }
}
/* =========================
   Компактная версия для телефона
   Должна быть в самом конце файла
========================= */

@media (max-width: 480px) {
    body {
        font-size: 15px !important;
        line-height: 1.32 !important;
        padding-bottom: 92px !important;
    }

    .app {
        padding: 8px !important;
        max-width: 100% !important;
    }

    h1 {
        font-size: 24px !important;
        line-height: 1.15 !important;
    }

    h2 {
        font-size: 19px !important;
        line-height: 1.2 !important;
        margin-bottom: 8px !important;
    }

    .card {
        padding: 12px !important;
        border-radius: 14px !important;
        margin-bottom: 9px !important;
        box-shadow: 0 3px 12px rgba(15, 23, 42, 0.07) !important;
    }

    .topbar {
        gap: 8px !important;
        margin-bottom: 10px !important;
        align-items: flex-start !important;
    }

    .logout {
        min-height: 36px !important;
        padding: 6px 10px !important;
        font-size: 14px !important;
        border-radius: 10px !important;
    }

    .small-muted {
        font-size: 12px !important;
    }

    .muted {
        font-size: 14px !important;
    }

    label {
        font-size: 15px !important;
        margin-top: 10px !important;
        margin-bottom: 5px !important;
    }

    input,
    select,
    textarea {
        font-size: 15px !important;
        padding: 10px !important;
        border-radius: 10px !important;
    }

    .btn {
        min-height: 44px !important;
        font-size: 16px !important;
        border-radius: 11px !important;
        margin-top: 12px !important;
    }

    .btn-link {
        padding: 12px !important;
        font-size: 16px !important;
        border-radius: 12px !important;
        margin-bottom: 10px !important;
    }

    .btn-small {
        min-height: 38px !important;
        padding: 7px 10px !important;
        font-size: 14px !important;
        border-radius: 10px !important;
    }

    .grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .stat-label {
        font-size: 13px !important;
    }

    .stat-value {
        font-size: 25px !important;
        line-height: 1.1 !important;
        margin-top: 4px !important;
    }

    .stat-sub {
        font-size: 12px !important;
        margin-top: 3px !important;
    }

    .big-period {
        font-size: 24px !important;
        margin: 3px 0 8px 0 !important;
    }

    .tenant-head {
        flex-direction: row !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    .tenant-head h2 {
        font-size: 22px !important;
        margin-bottom: 4px !important;
    }

    .status {
        font-size: 12px !important;
        padding: 5px 8px !important;
        border-radius: 999px !important;
    }

    .info-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 7px !important;
        margin-top: 10px !important;
    }

    .info-grid > div {
        padding: 8px !important;
        border-radius: 10px !important;
    }

    .info-grid strong {
        font-size: 15px !important;
    }

    .mini-row {
        padding: 9px 0 !important;
        gap: 6px !important;
    }

    .card-actions {
        gap: 6px !important;
        margin-top: 10px !important;
    }

    .note {
        font-size: 13px !important;
        padding: 9px !important;
        border-radius: 10px !important;
        margin-top: 10px !important;
    }

    .alert {
        padding: 10px 12px !important;
        border-radius: 10px !important;
        margin: 10px 0 !important;
        font-size: 14px !important;
    }

    .menu {
        gap: 7px !important;
    }

    .menu-item {
        padding: 12px !important;
        font-size: 15px !important;
        border-radius: 11px !important;
    }

    .checkbox-row {
        margin-top: 10px !important;
        padding: 9px !important;
        border-radius: 10px !important;
        gap: 8px !important;
    }

    .checkbox-row input {
        width: 20px !important;
        height: 20px !important;
    }

    .checkbox-row label {
        font-size: 15px !important;
    }

    .report-text {
        font-size: 15px !important;
        min-height: 180px !important;
        padding: 10px !important;
    }

    .data-table {
        font-size: 12px !important;
    }

    .data-table th,
    .data-table td {
        padding: 5px 6px !important;
    }

    /*
     * Компактное нижнее меню
     */
    .bottom-nav {
        gap: 5px !important;
        padding: 6px 6px calc(7px + env(safe-area-inset-bottom)) !important;
    }

    .bottom-nav-item {
        min-width: 72px !important;
        min-height: 54px !important;
        padding: 5px 6px !important;
        border-radius: 11px !important;
    }

    .bottom-nav-item span {
        font-size: 21px !important;
        margin-bottom: 3px !important;
    }

    .bottom-nav-item small {
        font-size: 11px !important;
        line-height: 1.05 !important;
    }

    .invoice-widget {
        margin-top: 10px !important;
    }

    .invoice-widget h2 {
        font-size: 18px !important;
        margin-bottom: 8px !important;
    }
}

/* Еще компактнее для очень узких экранов */
@media (max-width: 380px) {
    body {
        font-size: 14px !important;
    }

    h1 {
        font-size: 22px !important;
    }

    h2 {
        font-size: 18px !important;
    }

    .tenant-head h2 {
        font-size: 20px !important;
    }

    .stat-value {
        font-size: 23px !important;
    }

    .info-grid {
        grid-template-columns: 1fr !important;
    }

    .bottom-nav-item {
        min-width: 68px !important;
    }

    .bottom-nav-item small {
        font-size: 10px !important;
    }
}
/* =========================
   Компактная версия для планшетов
   Android / iPad-подобные экраны
   Должна быть в самом конце файла
========================= */

@media (min-width: 481px) and (max-width: 1200px) {
    body {
        font-size: 16px !important;
        line-height: 1.35 !important;
        padding-bottom: 88px !important;
    }

    .app {
        max-width: 900px !important;
        padding: 12px !important;
    }

    h1 {
        font-size: 30px !important;
        line-height: 1.15 !important;
    }

    h2 {
        font-size: 22px !important;
        line-height: 1.2 !important;
        margin-bottom: 10px !important;
    }

    .card {
        padding: 14px !important;
        border-radius: 16px !important;
        margin-bottom: 12px !important;
        box-shadow: 0 4px 14px rgba(15, 23, 42, 0.07) !important;
    }

    .topbar {
        margin-bottom: 12px !important;
    }

    .logout {
        min-height: 38px !important;
        padding: 7px 12px !important;
        font-size: 15px !important;
        border-radius: 11px !important;
    }

    .small-muted {
        font-size: 13px !important;
    }

    .muted {
        font-size: 15px !important;
    }

    label {
        font-size: 16px !important;
        margin-top: 12px !important;
        margin-bottom: 6px !important;
    }

    input,
    select,
    textarea {
        font-size: 16px !important;
        padding: 11px 12px !important;
        border-radius: 12px !important;
    }

    .btn {
        min-height: 46px !important;
        font-size: 17px !important;
        border-radius: 12px !important;
        margin-top: 14px !important;
    }

    .btn-link {
        padding: 13px !important;
        font-size: 17px !important;
        border-radius: 13px !important;
        margin-bottom: 12px !important;
    }

    .btn-small {
        min-height: 40px !important;
        padding: 8px 12px !important;
        font-size: 15px !important;
        border-radius: 10px !important;
    }

    .grid {
        gap: 10px !important;
    }

    .stat-label {
        font-size: 14px !important;
    }

    .stat-value {
        font-size: 30px !important;
        line-height: 1.1 !important;
        margin-top: 5px !important;
    }

    .stat-sub {
        font-size: 13px !important;
        margin-top: 4px !important;
    }

    .big-period {
        font-size: 30px !important;
        margin: 4px 0 10px 0 !important;
    }

    .tenant-head h2 {
        font-size: 24px !important;
        margin-bottom: 5px !important;
    }

    .status {
        font-size: 13px !important;
        padding: 6px 9px !important;
    }

    .info-grid {
        gap: 8px !important;
        margin-top: 10px !important;
    }

    .info-grid > div {
        padding: 9px !important;
        border-radius: 10px !important;
    }

    .info-grid strong {
        font-size: 16px !important;
    }

    .mini-row {
        padding: 10px 0 !important;
        gap: 8px !important;
    }

    .card-actions {
        gap: 8px !important;
        margin-top: 12px !important;
    }

    .note {
        font-size: 14px !important;
        padding: 10px !important;
        border-radius: 10px !important;
        margin-top: 10px !important;
    }

    .alert {
        padding: 11px 13px !important;
        border-radius: 11px !important;
        margin: 12px 0 !important;
        font-size: 15px !important;
    }

    .menu {
        gap: 8px !important;
    }

    .menu-item {
        padding: 13px !important;
        font-size: 16px !important;
        border-radius: 12px !important;
    }

    .checkbox-row {
        margin-top: 12px !important;
        padding: 10px !important;
        border-radius: 11px !important;
        gap: 9px !important;
    }

    .checkbox-row input {
        width: 22px !important;
        height: 22px !important;
    }

    .checkbox-row label {
        font-size: 16px !important;
    }

    .report-text {
        font-size: 16px !important;
        min-height: 200px !important;
        padding: 12px !important;
    }

    .invoice-widget {
        margin-top: 12px !important;
    }

    .invoice-widget h2 {
        font-size: 20px !important;
        margin-bottom: 9px !important;
    }

    /*
     * Главное: уменьшаем нижнее меню на планшете
     */
    .bottom-nav {
        gap: 6px !important;
        padding: 6px 8px calc(8px + env(safe-area-inset-bottom)) !important;
    }

    .bottom-nav-item {
        min-width: 92px !important;
        min-height: 58px !important;
        padding: 6px 8px !important;
        border-radius: 12px !important;
    }

    .bottom-nav-item span {
        font-size: 24px !important;
        margin-bottom: 4px !important;
    }

    .bottom-nav-item small {
        font-size: 12px !important;
        line-height: 1.05 !important;
    }
}