/* SMKK shared desktop/mobile product foundation. Theme-neutral and progressive. */
:root {
    --smkk-content-max: 1600px;
    --smkk-reading-max: 860px;
    --smkk-page-gutter: clamp(14px, 2vw, 28px);
    --smkk-control-height: 42px;
    --smkk-touch-height: 48px;
    --smkk-workspace-gap: clamp(12px, 1.5vw, 22px);
}

body.kk-brand.app-mode :is(main.app-main, #main-content) {
    min-width: 0;
}

body.kk-brand.app-mode :is(.app-main, .app-shell) > :is(.container, .page-container, .workspace-container) {
    width: min(100%, var(--smkk-content-max));
    margin-inline: auto;
}

body.kk-brand.app-mode :is(input, select, textarea, button, .btn, .app-btn) {
    font: inherit;
}

body.kk-brand.app-mode :is(input:not([type="checkbox"]):not([type="radio"]), select, .form-control, .form-select) {
    min-height: var(--smkk-control-height);
}

body.kk-brand.app-mode textarea {
    min-height: 96px;
    resize: vertical;
}

body.kk-brand.app-mode :is(img, video, canvas, svg) {
    max-width: 100%;
}

/* Reusable product-layout primitives for systematic page conversion. */
.smkk-page {
    width: min(100%, var(--smkk-content-max));
    display: grid;
    gap: var(--smkk-workspace-gap);
    margin-inline: auto;
    padding: var(--smkk-page-gutter);
}

.smkk-page__header {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.smkk-page__title {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.smkk-page__title :is(h1, p) {
    margin: 0;
}

.smkk-page__actions,
.smkk-toolbar,
.smkk-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.smkk-workspace {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(280px, 0.34fr) minmax(0, 1fr);
    gap: var(--smkk-workspace-gap);
    align-items: start;
}

.smkk-workspace__list,
.smkk-workspace__detail {
    min-width: 0;
}

.smkk-workspace__list {
    position: sticky;
    top: calc(var(--app-header-height, 64px) + 12px);
    max-height: calc(100dvh - var(--app-header-height, 64px) - 24px);
    overflow: auto;
}

.smkk-data-region {
    min-width: 0;
    overflow: auto;
    overscroll-behavior-inline: contain;
}

.smkk-data-region > table {
    min-width: 720px;
}

.smkk-mobile-only {
    display: none !important;
}

@media (min-width: 1100px) {
    body.kk-brand.app-mode :is(.dashboard-grid, .kpi-grid, .metric-grid) {
        align-items: stretch;
    }

    body.kk-brand.app-mode :is(.page-subtitle, .app-subtitle, .lead) {
        max-width: 82ch;
    }
}

@media (max-width: 760px) {
    :root {
        --smkk-page-gutter: 12px;
        --smkk-workspace-gap: 12px;
    }

    body.device-phone.app-mode {
        overflow-x: hidden;
    }

    body.device-phone.app-mode :is(main.app-main, #main-content) {
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
    }

    body.device-phone.app-mode :is(
        .app-grid,
        .dashboard-grid,
        .kpi-grid,
        .metric-grid,
        .summary-grid,
        .form-grid,
        .detail-grid,
        .installer-grid
    ) {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    body.device-phone.app-mode :is(.app-card, .card, .panel, .form-card, .workspace-card) {
        min-width: 0;
        max-width: 100%;
    }

    body.device-phone.app-mode :is(
        .page-header,
        .app-page-header,
        .app-hero,
        .page-hero,
        .dashboard-hero,
        .smkk-page__header
    ) {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    body.device-phone.app-mode :is(
        .page-actions,
        .header-actions,
        .hero-actions,
        .card-actions,
        .form-actions,
        .smkk-page__actions,
        .smkk-toolbar,
        .smkk-form-actions
    ) {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    body.device-phone.app-mode :is(
        .page-actions,
        .header-actions,
        .hero-actions,
        .card-actions,
        .form-actions,
        .smkk-page__actions,
        .smkk-toolbar,
        .smkk-form-actions
    ) > :is(button, .btn, .app-btn, a) {
        min-width: 0;
        min-height: var(--smkk-touch-height);
        justify-content: center;
        white-space: normal;
    }

    body.device-phone.app-mode :is(.table-wrap, .table-shell, .table-responsive, .smkk-data-region) {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    body.device-phone.app-mode :is(.table-wrap, .table-shell, .table-responsive, .smkk-data-region) table {
        min-width: 680px;
    }

    body.device-phone.app-mode :is(dialog, .modal-dialog, .smkk-sheet__panel) {
        max-width: calc(100vw - 16px) !important;
        max-height: calc(100dvh - 16px) !important;
    }

    body.device-phone.app-mode dialog[open] {
        margin: auto;
    }

    body.device-phone.app-mode :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea, .form-control, .form-select) {
        width: 100%;
        max-width: 100%;
        min-height: var(--smkk-touch-height);
        font-size: 16px;
    }

    body.device-phone.app-mode :is(button, [role="button"], .btn, .app-btn) {
        min-height: var(--smkk-touch-height);
    }

    .smkk-page {
        padding: var(--smkk-page-gutter);
    }

    .smkk-workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .smkk-workspace__list {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .smkk-desktop-only {
        display: none !important;
    }

    .smkk-mobile-only {
        display: initial !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.kk-brand.app-mode *,
    body.kk-brand.app-mode *::before,
    body.kk-brand.app-mode *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
