/* Shared pages keep their existing composition. This stylesheet is loaded only with
   Shell.SpatialOperations; the document hook also covers Mud's portalled dialogs/menus. */
:root.ag-theme {
    --app-surface-solid: var(--mud-palette-surface);
    --app-surface-muted: var(--mud-palette-background-gray);
    --app-surface-border: var(--mud-palette-lines-default);
    --app-surface-border-strong: var(--mud-palette-lines-inputs);
    --app-surface-shadow: none;
    --app-surface-shadow-strong: none;
    --app-surface-topline: none;
    --app-text-muted: var(--mud-palette-text-secondary);
    --app-text-soft: var(--mud-palette-text-secondary);
    --app-embedded-map-radius: 0px;
    --ag-float-shadow: 0 12px 32px rgba(0, 0, 0, .16);
}

html.ag-theme, .ag-theme body {
    background-color: var(--mud-palette-background);
    color: var(--mud-palette-text-primary);
}

/* Frames are flat and square; detached surfaces retain a small corner and a useful shadow. */
.ag-theme :is(.app-surface-solid, .command-rail, .collection-surface, .detail-hero,
    .detail-section, .state-surface, .metric-card, .detail-address) {
    border-radius: 0;
    box-shadow: none;
}

.ag-theme :is(.mud-card, .mud-table, .mud-tabs-tabbar, .mud-expansion-panels, .mud-expansion-panel) {
    border-radius: 0;
    box-shadow: none;
}

.ag-theme .mud-paper:not(.mud-dialog, .mud-popover, .mud-picker-paper, .mud-tooltip, .mud-snackbar) {
    border-radius: 0;
    box-shadow: none;
}

.ag-theme :is(.metric-card, .detail-address) {
    border-color: var(--mud-palette-table-lines);
}

.ag-theme :is(.page-kicker, .detail-kicker, .detail-fact-label, .detail-address-title) {
    font-family: var(--app-font-data);
    font-weight: 500;
    letter-spacing: .035em;
}

.ag-theme :is(.page-title, .section-title, .mud-dialog-title) {
    font-family: var(--app-font-heading);
    font-weight: 500;
    letter-spacing: 0;
}

/* Keep table density, column sizing and responsive behavior; unify headers and dividers. */
.ag-theme .mud-table-head .mud-table-cell {
    background-color: var(--mud-palette-background-gray);
    color: var(--mud-palette-text-secondary);
    border-bottom-color: var(--mud-palette-lines-default);
    font-family: var(--app-font-data);
    font-size: .75rem;
    font-weight: 500;
    letter-spacing: .025em;
}

.ag-theme .mud-table-body .mud-table-cell {
    border-bottom-color: var(--mud-palette-table-lines);
}

.ag-theme .table-host .mud-table-row:hover {
    background-color: var(--mud-palette-table-hover);
}

/* Brand accents still come from the Operator; success/error/warning styles stay semantic. */
.ag-theme :is(.mud-button, .mud-button-group, .mud-chip, .mud-pagination-item,
    .mud-input-outlined, .mud-input-outlined-border, .ext-login-btn) {
    border-radius: 2px;
}

.ag-theme .mud-input-filled {
    border-start-start-radius: 2px;
    border-start-end-radius: 2px;
}

.ag-theme :is(.mud-button, .mud-tab) {
    text-transform: none;
    letter-spacing: .01em;
}

.ag-theme .mud-button:is(.mud-button-filled, .mud-button-filled:hover, .mud-button-filled:focus-visible) {
    box-shadow: none;
}

.ag-theme .mud-icon-button {
    border-radius: 2px;
}

.ag-theme .mud-tab {
    border-radius: 0;
    font-weight: 500;
}

.ag-theme .mud-tabs-tabbar {
    background-color: var(--mud-palette-surface);
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.ag-theme :is(.mud-dialog, .mud-popover) {
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 4px;
    background-color: var(--mud-palette-surface);
    box-shadow: var(--ag-float-shadow);
}

.ag-theme .mud-dialog-title {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.ag-theme .mud-dialog-actions {
    border-top: 1px solid var(--mud-palette-lines-default);
}

.ag-theme .mud-picker-paper {
    border-radius: 4px;
    box-shadow: none;
}

.ag-theme :is(.mud-alert, .mud-snackbar, .mud-tooltip) {
    border-radius: 2px;
}

.ag-theme :is(.mud-button-root, .mud-tab, .mud-list-item, .ext-login-btn):focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* Appbar and navigation use the same treatment as the page surfaces. */
.ag-theme .app-shell-appbar {
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.ag-theme .app-shell-drawer-surface {
    border-radius: 0 !important;
}

.ag-theme .app-shell-drawer-surface::before {
    border-radius: 0;
}
