:root {
    --app-bg: #f4f6f8;
    --app-surface: #ffffff;
    --app-border: #d8e0e8;
    --app-text: #1f2933;
    --app-muted: #52606d;
    --app-primary: #2563eb;
    --app-primary-dark: #1d4ed8;
    --app-success: #2f6f4e;
    --app-danger: #b91c1c;
    --app-shadow: 0 2px 12px rgba(15, 23, 42, .12);
}

* {
    box-sizing: border-box;
}

body {
    min-width: 0;
}

body.has-app-shell {
    padding-top: var(--app-header-height, 68px);
}

.app-header {
    position: fixed !important;
    top: 0 !important;
    left: 0;
    right: 0;
    z-index: 5000;
    background: #243447;
    color: #fff;
    box-shadow: var(--app-shadow);
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
}

.app-header__inner {
    width: min(1600px, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

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

.app-brand__name {
    display: block;
    font-size: 18px;
    line-height: 1.15;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-brand__view {
    display: block;
    margin-top: 2px;
    color: #c9d6e2;
    font-size: 13px;
    font-weight: 700;
}

.app-menu-toggle {
    display: none;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 8px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
}

.app-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.app-nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 8px;
    color: #fff;
    text-decoration: none;
    font-size: 15px;
    font-weight: 800;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    white-space: nowrap;
}

.app-nav a:hover,
.app-nav a:focus-visible {
    background: rgba(255,255,255,.22);
    outline: none;
}

.app-nav a[aria-current="page"] {
    background: #fff;
    color: #243447;
}

.app-local-tools {
    width: min(1600px, calc(100% - 28px));
    margin: 12px auto;
    padding: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(18, 35, 48, .08);
}

.app-local-tools__field {
    flex: 1 1 260px;
    min-width: 0;
}

.app-local-tools__actions {
    display: flex;
    flex: 2 1 420px;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.app-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 48px;
    min-width: 48px;
    padding: 10px 14px;
    border: 0;
    border-radius: 8px;
    background: #e7eef6;
    color: #243447;
    font-size: 15px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    box-shadow: none;
    margin: 0;
    touch-action: manipulation;
}

.app-action:hover,
.app-action:focus-visible {
    filter: brightness(.97);
    outline: 3px solid rgba(37, 99, 235, .18);
}

.app-action--primary {
    background: var(--app-primary);
    color: #fff;
}

.app-action--success {
    background: var(--app-success);
    color: #fff;
}

.app-action--warning {
    background: #b45309;
    color: #fff;
}

.app-action--danger {
    background: var(--app-danger);
    color: #fff;
}

.app-action--muted {
    background: #eef2f6;
    color: #243447;
}

.app-page {
    width: min(1600px, 100%);
    margin: 0 auto;
}

.app-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.app-table-scroll table {
    min-width: 760px;
}

@media (max-width: 780px) {
    .app-header__inner {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .app-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .app-nav {
        grid-column: 1 / -1;
        display: none;
        justify-content: stretch;
    }

    .app-nav.is-open {
        display: grid;
        grid-template-columns: 1fr;
    }

    .app-nav a {
        width: 100%;
        justify-content: flex-start;
    }

    .app-local-tools {
        position: sticky;
        top: var(--app-header-height, 68px);
        z-index: 900;
        width: calc(100% - 20px);
        margin: 10px;
        padding: 10px;
        gap: 8px;
    }

    .app-local-tools__field,
    .app-local-tools__actions {
        flex: 1 1 100%;
    }

    .app-local-tools__actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .app-action {
        width: 100%;
        min-height: 48px;
        padding: 10px;
        font-size: 14px;
        white-space: normal;
    }
}

@media (max-width: 420px) {
    .app-brand__name {
        font-size: 16px;
    }

    .app-brand__view {
        font-size: 12px;
    }

    .app-menu-toggle {
        padding: 0 10px;
    }

    .app-local-tools__actions {
        grid-template-columns: 1fr;
    }
}

@media print {
    body.has-app-shell {
        padding-top: 0 !important;
    }

    .app-header,
    .app-local-tools {
        display: none !important;
    }
}
