:root {
    --te-color-primary: #1e3a52;
    --te-color-accent: #0a7fa5;
    --te-color-surface: #f4f6f9;
    --te-color-card: #ffffff;
    --te-color-border: rgba(0, 0, 0, 0.08);
    --te-color-text: #1f2933;
    --te-color-muted: #6b7280;
    --te-color-danger: #e53e3e;

    --te-font-size-base: 13px;
    --te-sidebar-width: 220px;
    --te-topbar-height: 48px;
}

html,
body.te-app-page {
    margin: 0;
    min-height: 100%;
}

body.te-app-page {
    background: var(--te-color-surface);
    color: var(--te-color-text);
    font-size: var(--te-font-size-base);
}

body.te-app-page * {
    box-sizing: border-box;
}

.te-app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--te-sidebar-width) 1fr;
    grid-template-rows: var(--te-topbar-height) 1fr;
    background: var(--te-color-surface);
    color: var(--te-color-text);
}

.te-topbar {
    grid-column: 1 / 3;
    grid-row: 1;
    min-height: var(--te-topbar-height);
    display: grid;
    grid-template-columns: var(--te-sidebar-width) auto minmax(240px, 420px) auto;
    align-items: center;
    border-bottom: 1px solid var(--te-color-border);
    background: var(--te-color-card);
}

.te-topbar__brand {
    height: var(--te-topbar-height);
    display: flex;
    align-items: center;
    border-right: 1px solid var(--te-color-border);
}

.te-topbar__logo {
    display: inline-flex;
    align-items: center;
    height: var(--te-topbar-height);
    padding: 0 16px;
    color: var(--te-color-primary);
    font-weight: 700;
    text-decoration: none;
}

.te-topbar__nav {
    display: flex;
    align-items: center;
    height: var(--te-topbar-height);
}

.te-topbar__link {
    display: inline-flex;
    align-items: center;
    height: var(--te-topbar-height);
    padding: 0 14px;
    color: var(--te-color-text);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.te-topbar__link.is-active {
    color: var(--te-color-accent);
    border-bottom-color: var(--te-color-accent);
}

.te-topbar__search {
    display: flex;
    align-items: center;
    height: var(--te-topbar-height);
    padding: 0 12px;
}

.te-global-search {
    width: 100%;
    height: 32px;
    border: 1px solid var(--te-color-border);
    background: #ffffff;
    color: var(--te-color-text);
    font-size: var(--te-font-size-base);
    padding: 0 10px;
}

.te-topbar__user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: var(--te-topbar-height);
    padding: 0 16px;
    color: var(--te-color-muted);
    white-space: nowrap;
}

.te-sidebar {
    grid-column: 1;
    grid-row: 2;
    min-height: calc(100vh - var(--te-topbar-height));
    border-right: 1px solid var(--te-color-border);
    background: var(--te-color-card);
}

.te-sidebar__nav {
    padding: 12px 0;
}

.te-sidebar__group {
    margin: 0 0 12px;
}

.te-sidebar__group-title {
    margin: 0;
    padding: 8px 16px;
    color: var(--te-color-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.te-sidebar__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.te-sidebar__item {
    margin: 0;
    padding: 0;
}

.te-sidebar__link {
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 0 16px;
    color: var(--te-color-text);
    text-decoration: none;
    border-left: 3px solid transparent;
}

.te-sidebar__link.is-active {
    color: var(--te-color-accent);
    border-left-color: var(--te-color-accent);
    background: rgba(10, 127, 165, 0.06);
}

.te-main {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    min-height: calc(100vh - var(--te-topbar-height));
}

.te-content {
    min-width: 0;
}

.te-page {
    padding: 24px;
}

.te-page__header {
    margin: 0 0 16px;
}

.te-page__title {
    margin: 0;
    color: var(--te-color-primary);
    font-size: 22px;
    font-weight: 700;
}

.te-page__body {
    background: var(--te-color-card);
    border: 1px solid var(--te-color-border);
    padding: 16px;
}

.te-app-message {
    padding: 16px;
    border: 1px solid var(--te-color-border);
    background: var(--te-color-card);
    color: var(--te-color-text);
}

.te-app-message--error {
    border-color: var(--te-color-danger);
    color: var(--te-color-danger);
}

@media (max-width: 768px) {
    .te-app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: var(--te-topbar-height) auto 1fr;
    }

    .te-topbar {
        grid-column: 1;
        grid-template-columns: 1fr;
        height: auto;
    }

    .te-topbar__brand,
    .te-topbar__nav,
    .te-topbar__search,
    .te-topbar__user {
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--te-color-border);
    }

    .te-topbar__nav {
        overflow-x: auto;
    }

    .te-sidebar {
        grid-column: 1;
        grid-row: 2;
        min-height: 0;
        border-right: 0;
        border-bottom: 1px solid var(--te-color-border);
    }

    .te-main {
        grid-column: 1;
        grid-row: 3;
        min-height: auto;
    }

    .te-page {
        padding: 16px;
    }
}