/* Werkflow Accounting — phone and tablet layout. Loaded after app.css. */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

[x-cloak] {
    display: none !important;
}

img,
svg,
video {
    max-width: 100%;
    height: auto;
}

.min-w-0 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-body {
    overflow-x: hidden;
}

.app-body.nav-open {
    overflow: hidden;
}

.app-shell {
    min-width: 0;
}

.app-main {
    min-width: 0;
    width: 100%;
}

.app-nav-backdrop {
    display: none;
}

.app-sidebar {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
}

.app-sidebar nav {
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}

.app-sidebar a {
    min-height: 2.75rem;
    align-items: center;
}

.app-menu-btn {
    min-width: 2.75rem;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    color: #0f172a;
    border-radius: 0.5rem;
    padding: 0 0.7rem;
    -webkit-tap-highlight-color: transparent;
}

.app-menu-btn .bars {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.app-menu-btn .bars span {
    display: block;
    width: 16px;
    height: 2px;
    background: #0f172a;
}

.app-close-btn {
    display: none;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 3.5rem;
    height: auto;
    gap: 0.5rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    background: #fff;
}

.app-header-meta {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-header-actions {
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}

.app-user {
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-content {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    min-width: 0;
}

.app-content :is(h1) {
    overflow-wrap: anywhere;
}

.app-content .overflow-hidden:has(table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.app-content table {
    max-width: none;
}

button,
a.rounded-md,
.app-content input,
.app-content select,
.app-content textarea {
    max-width: 100%;
}

button,
a.inline-flex,
.app-content .rounded-md.bg-ink,
.app-content .rounded-md.border {
    min-height: 2.5rem;
}

.swipe-hint {
    display: none;
}

.login-from-logo {
    max-height: 28px;
    max-width: 140px;
    object-fit: contain;
}

@media (max-width: 767px) {
    .app-nav-backdrop.is-visible {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(15, 23, 42, 0.55);
    }

    .app-sidebar {
        z-index: 50;
        width: min(18.5rem, 88vw);
        box-shadow: 12px 0 40px rgba(0, 0, 0, 0.28);
    }

    .app-close-btn {
        display: inline-flex;
        margin-left: auto;
        min-width: 2.5rem;
        min-height: 2.5rem;
        align-items: center;
        justify-content: center;
        border-radius: 0.375rem;
        color: #e2e8f0;
    }

    .app-user-role,
    .app-period {
        display: none;
    }

    .app-header {
        flex-wrap: wrap;
        row-gap: 0.4rem;
    }

    .app-header-meta {
        display: none;
    }

    .app-header-actions {
        margin-left: auto;
        gap: 0.55rem;
    }

    .app-leave {
        order: 5;
        flex: 1 0 100%;
        display: flex;
        justify-content: flex-end;
    }

    .app-leave button {
        width: 100%;
        min-height: 2.5rem;
    }

    .app-content .flex.items-end.justify-between,
    .app-content .mb-6.flex,
    .app-content .flex.items-start.justify-between {
        flex-wrap: wrap;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .page-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .page-toolbar > a,
    .page-toolbar > button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 2.75rem;
        text-align: center;
    }

    .app-content .grid {
        grid-template-columns: 1fr !important;
    }

    .app-content .flex.gap-3:not(form) {
        flex-wrap: wrap;
    }

    .app-content form.flex,
    .app-content form.flex.gap-3 {
        flex-wrap: wrap;
    }

    .app-content form.flex.gap-3 > input,
    .app-content form.flex.gap-3 > button,
    .app-content form.flex.gap-3 > select {
        flex: 1 1 8rem;
        min-height: 2.75rem;
    }

    .app-content input,
    .app-content select,
    .app-content textarea {
        font-size: 16px !important;
    }

    .app-content nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-content li.flex.justify-between,
    .app-content .flex.justify-between {
        flex-wrap: wrap;
        gap: 0.35rem 0.75rem;
    }

    .app-content .flex.justify-between > span:first-child {
        overflow-wrap: anywhere;
        min-width: 0;
    }

    .app-content header.flex {
        flex-wrap: wrap;
        gap: 0.35rem 0.75rem;
    }

    .app-content .rounded-md.bg-ink,
    .app-content button.bg-ink,
    .app-content a.bg-ink {
        min-height: 2.75rem;
    }

    /* List and report tables become stacked cards */
    .mobile-cards thead {
        display: none;
    }

    .mobile-cards,
    .mobile-cards tbody,
    .mobile-cards tfoot {
        display: block;
        width: 100%;
        min-width: 0 !important;
    }

    .mobile-cards tr {
        display: block;
        padding: 0.9rem 1rem;
        border-bottom: 1px solid #e2e8f0;
    }

    .mobile-cards tbody tr:last-child {
        border-bottom: 0;
    }

    .mobile-cards td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 0.75rem;
        padding: 0.22rem 0 !important;
        text-align: right;
        overflow-wrap: anywhere;
    }

    .mobile-cards td::before {
        content: attr(data-label);
        flex: 0 1 38%;
        max-width: 9.5rem;
        text-align: left;
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #64748b;
    }

    .mobile-cards td:first-child {
        display: block;
        text-align: left;
        font-weight: 600;
        font-size: 0.98rem;
        padding-bottom: 0.4rem !important;
    }

    .mobile-cards td:first-child::before,
    .mobile-cards td:not([data-label])::before,
    .mobile-cards td[data-label=""]::before,
    .mobile-cards td[colspan]::before {
        content: none;
    }

    .mobile-cards td[colspan] {
        display: block;
        text-align: left !important;
        font-weight: 400;
        font-size: 0.9rem;
        color: #64748b;
    }

    .mobile-cards td.action-cell {
        display: block;
        margin-top: 0.55rem;
        text-align: left;
    }

    .mobile-cards td.action-cell::before {
        content: none;
    }

    .mobile-cards td.action-cell a,
    .mobile-cards td.action-cell button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 2.75rem;
        margin: 0.2rem 0;
    }

    .mobile-cards tfoot tr,
    .mobile-cards tr.totals-row {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: baseline;
        gap: 0.35rem 1rem;
        background: #f8fafc;
    }

    .mobile-cards tfoot td[colspan],
    .mobile-cards tr.totals-row td[colspan] {
        flex: 1 1 auto;
        color: #0f172a;
        font-weight: 600;
    }

    .mobile-cards tfoot td:last-child,
    .mobile-cards tr.totals-row td:last-child {
        display: block;
        text-align: right;
        font-variant-numeric: tabular-nums;
        font-weight: 600;
    }

    .mobile-cards tfoot td:last-child::before,
    .mobile-cards tr.totals-row td:last-child::before {
        content: none;
    }

    /* Invoice / journal line editors: one field per row */
    .line-editor {
        overflow-x: visible;
    }

    .line-editor thead {
        display: none;
    }

    .line-editor table,
    .line-editor tbody {
        display: block;
        width: 100%;
        min-width: 0 !important;
    }

    .line-editor tr {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid #e2e8f0;
    }

    .line-editor td {
        display: block;
        width: 100%;
        padding: 0.4rem 0 !important;
    }

    .line-editor td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.25rem;
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: #64748b;
    }

    .line-editor input,
    .line-editor select {
        width: 100% !important;
        min-height: 2.75rem;
        box-sizing: border-box;
    }

    .login-page {
        min-height: 100dvh;
        padding: max(1rem, env(safe-area-inset-top)) 12px max(1rem, env(safe-area-inset-bottom));
        align-items: start;
        place-items: start center;
        box-sizing: border-box;
    }

    .login-panel,
    .login-panel.narrow {
        width: 100% !important;
        max-width: 100% !important;
        padding: 1.25rem 1rem 1.1rem !important;
        border-radius: 1.1rem !important;
        box-sizing: border-box;
    }

    .login-panel h1 {
        font-size: 1.75rem !important;
        margin: 0.25rem 0 0.5rem !important;
    }

    .login-panel input,
    .login-panel select,
    .login-panel textarea {
        font-size: 16px !important;
        min-height: 46px;
        width: 100%;
        box-sizing: border-box;
    }

    .login-panel .btn,
    .login-panel button[type="submit"] {
        min-height: 48px;
        width: 100%;
    }

    .login-row,
    .login-row label {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start;
        gap: 8px;
        white-space: normal;
    }

    .login-row input[type="checkbox"] {
        width: 16px !important;
        height: 16px !important;
        min-height: 16px !important;
        flex-shrink: 0;
    }

    .login-foot {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.6rem;
    }

    .login-panel fieldset label,
    .login-panel label {
        white-space: normal;
    }

    .login-panel fieldset label {
        display: flex;
        align-items: flex-start;
        gap: 8px;
    }

    .login-panel input.otp {
        letter-spacing: 0.28em;
        text-align: center;
        font-size: 1.2rem !important;
    }
}

@media (min-width: 768px) {
    .app-nav-backdrop {
        display: none !important;
    }

    .app-menu-btn,
    .app-close-btn {
        display: none !important;
    }

    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100dvh;
        max-height: 100dvh;
        transform: none !important;
    }

    .app-user {
        max-width: none;
    }
}
