/* Portal shell: layout, sidebar, toolbars and shared components.
   Moved from an inline <style> in header.php so browsers cache it
   instead of downloading ~27 KB again on every page. */
*,
*::before,
*::after { box-sizing: border-box; }
html { overflow-x: hidden; }
:root {
    --surface-soft: #f5f8f6;
    --surface-card: #ffffff;
    --line-soft: #e5ebe7;
    --text-soft: #6b7280;
    --sidebar-width: 16rem;
    --sidebar-compact-width: 5.5rem;
}
body {
    font-family: 'Barlow', system-ui, sans-serif;
    overflow-x: hidden;
}
img {
    max-width: 100%;
    height: auto;
}
.sidebar { transform: translateX(-100%); transition: transform 0.3s ease, width 0.28s ease, box-shadow 0.28s ease; }
.sidebar.open { transform: translateX(0); }
.content {
    margin-left: 0;
    min-width: 0;
    transition: margin 0.3s ease;
}
.content.shift { margin-left: 0; }
#menuToggle {
    transition: left 0.28s ease, transform 0.28s ease, opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.app-sidebar__top {
    position: relative;
    min-height: 5.75rem;
}
.app-sidebar__brand,
.app-sidebar__brand-copy,
.nav-link__label {
    min-width: 0;
    transition: opacity 0.2s ease, transform 0.2s ease, max-width 0.2s ease;
}
.app-sidebar__brand {
    flex: 1 1 auto;
    gap: 0.85rem;
}
.app-sidebar__brand-copy {
    max-width: 11rem;
    overflow: hidden;
}
.app-sidebar__logo {
    flex-shrink: 0;
}
.app-sidebar__pin {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    margin-left: 0.75rem;
    padding: 0;
    border-radius: 999px;
}
.app-sidebar__pin.is-active {
    border-color: #008060;
    color: #008060;
    background: rgba(0, 128, 96, 0.06);
}
.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 3rem;
    border-radius: 1rem;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
}
.nav-link__icon {
    display: inline-flex;
    width: 1.25rem;
    min-width: 1.25rem;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.nav-link__label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.nav-link__badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.32rem;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
}
.nav-link[aria-current="page"] {
    background: linear-gradient(135deg, rgba(0, 128, 96, 0.18), rgba(0, 128, 96, 0.08));
}
.page-content {
    padding: 0.5rem 1rem 1rem;
}
.page-shell { display: flex; flex-direction: column; gap: 1.5rem; }
.page-intro {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--line-soft);
    border-radius: 1.25rem;
    background: linear-gradient(135deg, #ffffff 0%, #f4faf7 100%);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}
.page-intro__eyebrow {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #7b8a83;
}
.page-intro__title {
    margin: 0.35rem 0 0;
    font-size: 1.9rem;
    font-weight: 700;
    color: #1f2937;
}
.page-intro__copy {
    margin: 0.5rem 0 0;
    max-width: 42rem;
    color: var(--text-soft);
    font-size: 0.95rem;
}
.page-stats {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat-card {
    padding: 1rem 1.1rem;
    border: 1px solid var(--line-soft);
    border-radius: 1rem;
    background: var(--surface-card);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}
.stat-card__label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8b948d;
}
.stat-card__value {
    margin: 0.45rem 0 0;
    font-size: 1.45rem;
    font-weight: 700;
    color: #1f2937;
}
.stat-card__meta {
    margin: 0.4rem 0 0;
    font-size: 0.85rem;
    color: var(--text-soft);
}
.toolbar-card {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    justify-content: space-between;
    padding: 1.25rem;
    border: 1px solid var(--line-soft);
    border-radius: 1rem;
    background: var(--surface-card);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}
.toolbar-card__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}
.toolbar-card__filters {
    min-width: 0;
}
.toolbar-card__group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    justify-content: space-between;
    width: 100%;
}
.ui-filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}
.toolbar-card__filters .ui-filter-grid {
    width: 100%;
}
.ui-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1 1 12rem;
    min-width: min(100%, 12rem);
    max-width: 100%;
    font-size: 0.875rem;
    font-weight: 600;
    color: #4b5563;
}
.ui-filter-field--wide {
    flex: 2 1 18rem;
    min-width: min(100%, 18rem);
}
.ui-filter-field--compact {
    flex: 0 0 auto;
    min-width: 7rem;
    max-width: 9rem;
}
.ui-filter-field input,
.ui-filter-field select {
    width: 100%;
    border: 1px solid #dbe4dd;
    border-radius: 0.85rem;
    padding: 0.7rem 0.9rem;
    font-size: 0.92rem;
    color: #1f2937;
    background: #fff;
}
.ui-filter-field input:focus,
.ui-filter-field select:focus {
    outline: none;
    border-color: #008060;
    box-shadow: 0 0 0 3px rgba(0, 128, 96, 0.12);
}
.ui-btn,
.ui-btn-secondary,
.ui-btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.7rem 1.1rem;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s ease;
    max-width: 100%;
}
.ui-btn {
    border: 1px solid #008060;
    background: #008060;
    color: #fff;
    box-shadow: 0 8px 18px rgba(0, 128, 96, 0.18);
}
.ui-btn:hover { background: #016d53; border-color: #016d53; }
.ui-btn-secondary {
    border: 1px solid #dbe4dd;
    background: #fff;
    color: #374151;
}
.ui-btn-secondary:hover,
.ui-btn-ghost:hover {
    border-color: #008060;
    color: #008060;
    background: #f3fbf7;
}
.ui-btn-ghost {
    border: 1px dashed #dbe4dd;
    background: transparent;
    color: #4b5563;
}
.ui-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    border: 1px solid #dbe4dd;
    color: #008060;
    background: #fff;
    transition: all 0.2s ease;
}
.ui-icon-btn:hover {
    background: #f3fbf7;
    border-color: #008060;
}
.mobile-data-card {
    margin-bottom: 1rem;
    padding: 1.1rem;
    border: 1px solid var(--line-soft);
    border-radius: 1rem;
    background: var(--surface-card);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}
.mobile-data-card__grid {
    display: grid;
    gap: 0.85rem;
    margin-top: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.mobile-data-card__label {
    margin: 0 0 0.15rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #98a29b;
}
.mobile-data-card__value {
    margin: 0;
    font-size: 0.94rem;
    color: #1f2937;
}
.data-table-shell {
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--line-soft);
    border-radius: 1rem;
    background: var(--surface-card);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
    -webkit-overflow-scrolling: touch;
}
.table-interactive {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.table-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.table-search {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.7rem;
    min-width: min(100%, 18rem);
    flex: 1 1 18rem;
    min-height: 3rem;
    padding: 0.72rem 0.95rem;
    border: 1px solid #dbe4dd;
    border-radius: 999px;
    background: #fff;
    color: #6b7280;
    box-sizing: border-box;
}
.table-search i {
    flex: 0 0 auto;
}
.table-search:focus-within {
    border-color: #008060;
    box-shadow: 0 0 0 3px rgba(0, 128, 96, 0.12);
}
.table-search__input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    border: 0;
    padding: 0;
    background: transparent;
    color: #1f2937;
    font-size: 0.92rem;
    outline: none;
}
.table-search__meta {
    font-size: 0.82rem;
    font-weight: 700;
    color: #7b8a83;
    white-space: nowrap;
}
.table-empty-state {
    display: none;
    padding: 1rem 1.1rem;
    border: 1px dashed #d7e2db;
    border-radius: 1rem;
    background: #fff;
    color: var(--text-soft);
    font-size: 0.9rem;
    text-align: center;
}
thead th.sortable {
    position: relative;
    cursor: pointer;
    user-select: none;
    padding-right: 2rem;
    transition: color 0.2s ease, background-color 0.2s ease;
}
thead th.sortable:hover,
thead th.sortable:focus-visible {
    color: #12715a;
    background: #f3fbf7;
    outline: none;
}
.sort-indicator {
    position: absolute;
    top: 50%;
    right: 0.8rem;
    transform: translateY(-50%);
    font-size: 0.75rem;
    line-height: 1;
    color: #9ca3af;
    pointer-events: none;
}
thead th.sortable.asc .sort-indicator,
thead th.sortable.desc .sort-indicator {
    color: #008060;
}
.empty-state {
    padding: 2.25rem 1.5rem;
    border: 1px dashed #d7e2db;
    border-radius: 1rem;
    background: #fff;
    text-align: center;
    color: var(--text-soft);
    font-size: 0.95rem;
}
.section-note {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    background: #eef7f3;
    color: #12715a;
    font-size: 0.82rem;
    font-weight: 700;
}
.document-actions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.document-actions__links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.document-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid #dfeae4;
    border-radius: 1rem;
    background: #ffffff;
}
.document-item__label {
    color: #1f2937;
    font-size: 0.82rem;
    font-weight: 700;
}
.document-item__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
}
.document-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid #b7d6cb;
    border-radius: 999px;
    background: #f3fbf7;
    color: #12715a;
    font-size: 0.77rem;
    font-weight: 700;
    transition: all 0.2s ease;
}
.document-link:hover {
    border-color: #008060;
    background: #e9f7f1;
}
.document-link--secondary {
    border-color: #d7e2db;
    background: #ffffff;
    color: #4b5563;
}
.document-link--secondary:hover {
    border-color: #9bb7ac;
    background: #f7faf8;
}
.document-link--disabled {
    border-style: dashed;
    border-color: #d7e2db;
    background: #f9fbfa;
    color: #98a29b;
    pointer-events: none;
}
.document-icon-actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}
.document-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    border: 1px solid #cfe0d8;
    border-radius: 999px;
    background: #f4faf7;
    color: #12715a;
    font-size: 0.92rem;
    transition: all 0.2s ease;
}
.document-icon-btn:hover {
    border-color: #008060;
    background: #e8f6ef;
    color: #0f5d4c;
    box-shadow: 0 8px 18px rgba(0, 128, 96, 0.12);
}
.app-header__brand,
.app-header__actions,
.app-header__action,
.page-shell,
.page-intro,
.toolbar-card,
.toolbar-card__form,
.toolbar-card__filters,
.toolbar-card__group,
.stat-card,
.mobile-data-card,
.data-table-shell {
    min-width: 0;
}
@media (min-width: 768px) {
    .toolbar-card__group {
        width: auto;
        justify-content: flex-end;
    }
}
@media (min-width: 1024px) {
    #sidebar.sidebar {
        transform: translateX(0);
        overflow: visible;
        box-shadow: 6px 0 18px rgba(15, 23, 42, 0.06);
    }
    body.has-sidebar.sidebar-desktop-hidden #sidebar.sidebar {
        transform: translateX(calc(-100% - 1.5rem));
        box-shadow: none;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar {
        width: var(--sidebar-compact-width);
        min-width: var(--sidebar-compact-width);
        max-width: var(--sidebar-compact-width);
    }
    body.has-sidebar.sidebar-desktop-expanded #sidebar.sidebar {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        max-width: var(--sidebar-width);
        box-shadow: 18px 0 42px rgba(15, 23, 42, 0.12);
    }
    body.has-sidebar.sidebar-desktop-compact .content {
        margin-left: var(--sidebar-compact-width);
    }
    body.has-sidebar.sidebar-desktop-expanded .content {
        margin-left: var(--sidebar-width);
    }
    body.has-sidebar #menuToggle {
        display: inline-flex;
        top: 1.15rem;
        left: 1rem;
    }
    body.has-sidebar.sidebar-desktop-compact #menuToggle {
        left: calc(var(--sidebar-compact-width) + 0.85rem);
    }
    body.has-sidebar.sidebar-desktop-expanded #menuToggle {
        left: calc(var(--sidebar-width) + 0.85rem);
    }
    body.has-sidebar.sidebar-desktop-hidden #menuToggle {
        left: 1rem;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .app-sidebar__top {
        padding-left: 1rem;
        padding-right: 1rem;
        padding-top: 0.85rem;
        padding-bottom: 2.35rem;
        min-height: 7rem;
        justify-content: center;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .app-sidebar__brand {
        justify-content: center;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .app-sidebar__logo {
        height: 2.25rem;
        width: auto;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .app-sidebar__brand-copy,
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .nav-link__label {
        opacity: 0;
        transform: translateX(-0.35rem);
        max-width: 0;
        pointer-events: none;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .app-sidebar__nav {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .app-sidebar__pin {
        position: absolute;
        top: auto;
        right: auto;
        bottom: 0.5rem;
        left: 50%;
        transform: translateX(-50%);
        margin: 0;
        width: 2.35rem;
        height: 2.35rem;
        padding: 0;
        border-radius: 999px;
        background: #fff;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
        z-index: 65;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .nav-link {
        justify-content: center;
        gap: 0;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .nav-link__badge {
        position: absolute;
        top: 0.4rem;
        right: 0.35rem;
        margin-left: 0;
        box-shadow: 0 0 0 2px #fff;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .nav-link::after {
        content: attr(data-nav-label);
        position: absolute;
        top: 50%;
        left: calc(100% + 0.75rem);
        transform: translateY(-50%) translateX(-0.45rem);
        padding: 0.5rem 0.75rem;
        border-radius: 0.8rem;
        background: #1f2937;
        color: #fff;
        font-size: 0.82rem;
        font-weight: 600;
        letter-spacing: 0.01em;
        white-space: nowrap;
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease, transform 0.18s ease;
        z-index: 80;
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .nav-link:hover::after,
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .nav-link:focus-visible::after {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
    body.has-sidebar.sidebar-desktop-compact #sidebar.sidebar .nav-link[aria-current="page"] {
        background: linear-gradient(135deg, rgba(0, 128, 96, 0.2), rgba(0, 128, 96, 0.1));
        box-shadow: inset 0 0 0 1px rgba(0, 128, 96, 0.16);
    }
    .toolbar-card__form {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }
    .toolbar-card__filters {
        flex: 1 1 auto;
    }
    .toolbar-card__group {
        flex: 0 0 auto;
        margin-left: auto;
    }
}
@media (max-width: 1023px) {
    .app-header {
        padding-left: 4.5rem;
    }
}
@media (max-width: 767px) {
    .app-header {
        padding: 0.85rem 1rem 0.85rem 4.5rem;
    }
    .app-main {
        padding: 1rem 1rem 1.25rem;
    }
    .app-header__actions {
        width: 100%;
        margin-left: 0;
    }
    .app-header__action {
        flex: 1 1 0;
    }
    .app-header__action span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .page-content {
        padding: 0.35rem 0 0.75rem;
    }
    .page-intro { padding: 1.15rem; }
    .page-intro__title { font-size: 1.55rem; }
    .toolbar-card { padding: 1rem; }
    .toolbar-card__group {
        justify-content: flex-start;
    }
    .table-search {
        min-width: 100%;
    }
    .table-search__meta {
        width: 100%;
        white-space: normal;
    }
    .ui-filter-field,
    .ui-filter-field--wide,
    .ui-filter-field--compact {
        min-width: 100%;
        max-width: none;
    }
    .mobile-data-card__grid {
        grid-template-columns: 1fr;
    }
    .document-item {
        flex-direction: column;
        align-items: stretch;
    }
    .document-item__actions {
        flex-direction: column;
        justify-content: flex-start;
    }
    .document-link,
    .document-link--disabled {
        width: 100%;
    }
    .document-icon-btn {
        width: 2.6rem;
        height: 2.6rem;
    }
}
/* Filter toolbars have their own responsive rules: they must not depend
   on utility classes being present in a prebuilt Tailwind bundle. */
.toolbar-card { padding: 0.85rem 1rem; }
.toolbar-card__form { gap: 0.75rem; }
.toolbar-filter-toggle {
    display: inline-flex;
    align-self: flex-start;
    flex: 0 0 auto;
    width: auto;
    min-height: 2.5rem;
    padding: 0.5rem 0.85rem;
    box-shadow: none;
}
.toolbar-card__filters.hidden { display: none; }
.toolbar-card__filters .ui-filter-grid { gap: 0.65rem; }
.toolbar-card__filters .ui-filter-field {
    flex: 0 1 11rem;
    min-width: 9rem;
    gap: 0.25rem;
    font-size: 0.8rem;
}
.toolbar-card__filters .ui-filter-field--wide { flex-basis: 22rem; min-width: 14rem; }
.toolbar-card .ui-filter-field input,
.toolbar-card .ui-filter-field select { height: 2.5rem; padding: 0.45rem 0.75rem; font-size: 0.85rem; }
.toolbar-card .ui-btn,
.toolbar-card .ui-btn-secondary { min-height: 2.5rem; padding: 0.5rem 0.85rem; font-size: 0.85rem; }
.toolbar-card__group { gap: 0.5rem; }
.toolbar-card__group .ui-filter-field--compact { min-width: 6rem; max-width: 7rem; gap: 0.25rem; font-size: 0.8rem; }
@media (min-width: 768px) {
    .toolbar-filter-toggle { display: none; }
    .toolbar-card__filters.hidden { display: block; }
    .toolbar-card__form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
    .toolbar-card__filters { flex: 1 1 40rem; }
    .toolbar-card__group { flex: 0 0 auto; width: auto; margin-left: auto; }
}
@media (max-width: 767px) {
    .toolbar-card__filters .ui-filter-field { flex: 1 1 8rem; min-width: min(100%, 8rem); max-width: none; }
    .toolbar-card__filters .ui-filter-field--wide { flex-basis: 100%; }
    .toolbar-card__group .ui-filter-field--compact { min-width: 6rem; max-width: 7rem; }
}

/* The fixed menu toggle sits at the content edge on every width; keep the
   page title clear of it on desktop too (it covered "Huverba"/the title). */
@media (min-width: 1024px) {
    body.has-sidebar .app-header {
        padding-left: 4.5rem;
    }
}

/* ------------------------------------------------------------------
   List pages: filter toolbar, chips and pagination (portal_list_support.php)
   ------------------------------------------------------------------ */
.portal-filters {
    display: block;
    padding: 0.85rem 1rem;
}
.portal-filters__form { width: 100%; }
.portal-filters__form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.portal-filters__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.portal-filters__search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 22rem;
    min-width: min(100%, 14rem);
}
.portal-filters__search > i {
    position: absolute;
    left: 0.9rem;
    color: #9ca3af;
    font-size: 0.85rem;
    pointer-events: none;
}
.portal-filters__search input {
    width: 100%;
    height: 2.75rem;
    padding: 0 6.25rem 0 2.4rem;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    background: #fff;
    font-size: 0.9rem;
    color: #1f2937;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.portal-filters__search input:focus {
    outline: none;
    border-color: #008060;
    box-shadow: 0 0 0 3px rgba(0, 128, 96, 0.15);
}
.portal-filters__search-submit {
    position: absolute;
    right: 0.3rem;
    height: 2.15rem;
    padding: 0 1rem;
    border: 0;
    border-radius: 999px;
    background: #008060;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}
.portal-filters__search-submit:hover { background: #016d53; }
.portal-filters__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}
.portal-filters .toolbar-filter-toggle {
    gap: 0.45rem;
    width: auto;
    min-height: 2.75rem;
}
.portal-filters__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #008060;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}
.portal-filters__reset {
    gap: 0.4rem;
    min-height: 2.5rem;
    color: #6b7280;
}
.portal-filters__fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.65rem 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line-soft);
}
.portal-filters__fields.hidden { display: none; }
.portal-filters .ui-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    max-width: none;
    margin: 0;
}
.ui-filter-field__label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #6b7280;
}
.portal-filters .ui-filter-field input,
.portal-filters .ui-filter-field select {
    width: 100%;
    height: 2.5rem;
    padding: 0 0.75rem;
    border: 1px solid var(--line-soft);
    border-radius: 0.75rem;
    background-color: #fff;
    font-size: 0.875rem;
    color: #1f2937;
}
.portal-filters__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.portal-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.25rem;
    padding: 0 0.85rem;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    background: #fff;
    color: #4b5563;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.portal-chip:hover { border-color: #008060; color: #008060; }
.portal-chip.is-active { border-color: #008060; background: #008060; color: #fff; }
.portal-chip__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    font-size: 0.7rem;
}
.portal-chip.is-active .portal-chip__count { background: rgba(255, 255, 255, 0.22); color: #fff; }
@media (min-width: 768px) {
    .portal-filters .toolbar-filter-toggle { display: none; }
    .portal-filters__fields,
    .portal-filters__fields.hidden {
        display: grid;
        padding-top: 0;
        border-top: 0;
    }
}
@media (max-width: 767px) {
    .portal-filters__search { flex-basis: 100%; }
    .portal-filters__fields { grid-template-columns: 1fr 1fr; }
    /* Toggle, reset and export share one row on a phone. */
    .portal-filters__reset span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .portal-filters__reset { min-width: 2.5rem; padding: 0 0.7rem; }
}

.portal-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.25rem 0;
}
.portal-pagination__summary {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}
.portal-pagination__summary span { font-weight: 400; color: #6b7280; }
.portal-pagination__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
.portal-pagination__pages {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.portal-pagination__step,
.portal-pagination__page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 2.35rem;
    height: 2.35rem;
    padding: 0 0.7rem;
    border: 1px solid var(--line-soft);
    border-radius: 0.7rem;
    background: #fff;
    color: #374151;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.portal-pagination__step:hover,
.portal-pagination__page:hover { border-color: #008060; color: #008060; }
.portal-pagination__page.is-current { border-color: #008060; background: #008060; color: #fff; }
.portal-pagination__step.is-disabled { opacity: 0.45; pointer-events: none; }
.portal-pagination__ellipsis { padding: 0 0.15rem; color: #9ca3af; }
.portal-pagination__size { margin: 0 0 0 0.5rem; }
.portal-pagination__size label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: #6b7280;
}
.portal-pagination__size select {
    height: 2.35rem;
    padding: 0 0.6rem;
    border: 1px solid var(--line-soft);
    border-radius: 0.7rem;
    background-color: #fff;
    font-size: 0.85rem;
}
@media (max-width: 639px) {
    .portal-pagination { justify-content: center; }
    .portal-pagination__summary { width: 100%; text-align: center; }
    .portal-pagination__step span { display: none; }
    .portal-pagination__size { margin-left: 0; }
}

/* Button variants: one small size for table rows, and a real danger button
   (a red text utility on .ui-btn-secondary lost to the shared colour). */
.ui-btn.ui-btn--sm,
.ui-btn-secondary.ui-btn--sm,
.ui-btn-ghost.ui-btn--sm,
.ui-btn-danger.ui-btn--sm {
    min-height: 2rem;
    padding: 0.35rem 0.8rem;
    font-size: 0.78rem;
    gap: 0.35rem;
}
.ui-btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.75rem;
    padding: 0.65rem 1.1rem;
    border: 1px solid #fecaca;
    border-radius: 999px;
    background: #fff;
    color: #dc2626;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.ui-btn-danger:hover { background: #fef2f2; border-color: #f87171; }
.ui-icon-btn.hidden { display: none; }
.ui-btn:focus-visible,
.ui-btn-secondary:focus-visible,
.ui-btn-ghost:focus-visible,
.ui-btn-danger:focus-visible,
.ui-icon-btn:focus-visible,
.portal-chip:focus-visible,
.portal-pagination__page:focus-visible,
.portal-pagination__step:focus-visible {
    outline: 2px solid #008060;
    outline-offset: 2px;
}
.portal-filters__reset { border-color: transparent; }

/* Status badges (portalListBadge): soft colours, one shape on every list. */
.portal-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.portal-badge--success { background: #dcfce7; color: #166534; }
.portal-badge--warning { background: #fef3c7; color: #92400e; }
.portal-badge--danger { background: #fee2e2; color: #b91c1c; }
.portal-badge--info { background: #dbeafe; color: #1e40af; }
.portal-badge--neutral { background: #f3f4f6; color: #374151; }
.portal-row-actions { display: flex; flex-wrap: nowrap; gap: 0.4rem; white-space: nowrap; }

/* Dates and amounts stay on one line in list tables. */
.portal-nowrap { white-space: nowrap; }

/* Sortable list headers (portalListSortHeader). */
.portal-sort-link { display: inline-flex; align-items: center; gap: 0.35rem; color: inherit; text-decoration: none; white-space: nowrap; }
.portal-sort-link i { font-size: 0.65rem; color: #c4ccc7; transition: color 0.15s ease; }
.portal-sort-link:hover, .portal-sort-link.is-active { color: #008060; }
.portal-sort-link:hover i, .portal-sort-link.is-active i { color: #008060; }

/* Phone sort select of the list toolbar; on wider screens the column headers sort. */
.portal-filters__sort {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 12rem;
    min-width: 0;
}
.portal-filters__sort > i {
    position: absolute;
    left: 0.85rem;
    color: #9ca3af;
    font-size: 0.8rem;
    pointer-events: none;
}
.portal-filters__sort select {
    width: 100%;
    height: 2.75rem;
    padding: 0 0.75rem 0 2.2rem;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    background-color: #fff;
    font-size: 0.875rem;
    color: #1f2937;
}
@media (min-width: 768px) {
    .portal-filters__sort { display: none; }
}

/* ------------------------------------------------------------------
   List tables (.portal-table): one markup for every screen. On a phone each
   row becomes a card with labelled fields, so pages no longer render a second
   copy of every record for small screens.
   ------------------------------------------------------------------ */
.portal-table .portal-cell--title { font-weight: 600; color: #1f2937; }
@media (max-width: 767px) {
    .portal-table-shell {
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }
    .portal-table-shell > .overflow-x-auto { overflow: visible; }
    .portal-table,
    .portal-table > tbody { display: block; width: 100%; min-width: 0; }
    .portal-table > thead { display: none; }
    .portal-table > tbody > tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.8rem 1rem;
        margin-bottom: 0.85rem;
        padding: 1rem 1.05rem;
        border: 1px solid var(--line-soft);
        border-radius: 1rem;
        background: var(--surface-card);
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
    }
    .portal-table > tbody > tr:hover { background: var(--surface-card); }
    .portal-table > tbody > tr > td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
        font-size: 0.92rem;
        overflow-wrap: anywhere;
    }
    .portal-table > tbody > tr > td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.15rem;
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: #98a29b;
    }
    .portal-table > tbody > tr > td:empty,
    .portal-table > tbody > tr > td.portal-cell--empty { display: none; }
    .portal-table > tbody > tr > td.portal-cell--title {
        grid-column: 1 / -1;
        order: -2;
        padding-bottom: 0.7rem;
        border-bottom: 1px solid var(--line-soft);
        font-size: 1.02rem;
    }
    .portal-table > tbody > tr > td.portal-cell--title::before { display: none; }
    .portal-table > tbody > tr > td.portal-cell--wide { grid-column: 1 / -1; }
    .portal-table > tbody > tr > td.portal-cell--detail,
    .portal-table > tbody > tr > td.portal-cell--actions,
    .portal-table > tbody > tr > td.portal-cell--docs { grid-column: 1 / -1; order: 10; }
    .portal-table > tbody > tr > td.portal-cell--actions { order: 11; }
    .portal-table > tbody > tr > td.portal-cell--docs { order: 12; }
    .portal-table .portal-cell--detail > .ui-btn,
    .portal-table .portal-cell--detail > .ui-btn-secondary { width: 100%; min-height: 2.75rem; justify-content: center; }
    .portal-table .portal-row-actions { flex-wrap: wrap; }
    .portal-table .portal-row-actions > .ui-btn,
    .portal-table .portal-row-actions > .ui-btn-secondary,
    .portal-table .portal-row-actions > .ui-btn-danger { flex: 1 1 8rem; min-height: 2.75rem; justify-content: center; }
    .portal-table .portal-nowrap { white-space: normal; }
}

/* ------------------------------------------------------------------
   Quick search in the header (portal_search.php): numbers, references and
   projects across invoices, orders, quotes and deliveries.
   ------------------------------------------------------------------ */
.portal-quicksearch {
    position: relative;
    flex: 1 1 18rem;
    max-width: 26rem;
    min-width: 0;
}
.portal-quicksearch__field {
    position: relative;
    display: flex;
    align-items: center;
}
.portal-quicksearch__field > i {
    position: absolute;
    left: 0.9rem;
    color: #9ca3af;
    font-size: 0.85rem;
    pointer-events: none;
}
.portal-quicksearch__field input {
    width: 100%;
    height: 2.5rem;
    padding: 0 2.6rem 0 2.35rem;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #f9fafb;
    font-size: 0.875rem;
    color: #1f2937;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.portal-quicksearch__field input:focus {
    outline: none;
    border-color: #008060;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 128, 96, 0.15);
}
.portal-quicksearch__key {
    position: absolute;
    right: 0.75rem;
    padding: 0.05rem 0.4rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.35rem;
    background: #fff;
    color: #9ca3af;
    font-size: 0.7rem;
    font-weight: 600;
    pointer-events: none;
}
.portal-quicksearch__field input:focus ~ .portal-quicksearch__key,
.portal-quicksearch__field input:not(:placeholder-shown) ~ .portal-quicksearch__key { display: none; }
.portal-quicksearch__results {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    width: max(100%, 32rem);
    z-index: 40;
    max-height: min(70vh, 32rem);
    overflow-y: auto;
    padding: 0.4rem;
    border: 1px solid var(--line-soft);
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
}
.portal-quicksearch__results[hidden] { display: none; }
.portal-quicksearch__group {
    margin: 0.35rem 0.5rem 0.2rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #98a29b;
}
.portal-quicksearch__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.6rem;
    border-radius: 0.7rem;
    color: #1f2937;
    text-decoration: none;
}
.portal-quicksearch__item i {
    flex: 0 0 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.6rem;
    background: #f0f7f3;
    color: #008060;
    font-size: 0.8rem;
}
.portal-quicksearch__item span { display: flex; flex-direction: column; min-width: 0; }
.portal-quicksearch__item strong { font-size: 0.875rem; font-weight: 600; }
.portal-quicksearch__item small {
    overflow: hidden;
    color: #6b7280;
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.portal-quicksearch__item:hover,
.portal-quicksearch__item.is-active { background: #f3fbf7; }
.portal-quicksearch__empty { margin: 0; padding: 0.75rem; color: #6b7280; font-size: 0.85rem; }
.portal-quicksearch__all {
    display: block;
    margin-top: 0.25rem;
    padding: 0.6rem;
    border-top: 1px solid var(--line-soft);
    color: #008060;
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}
@media (max-width: 767px) {
    .portal-quicksearch { order: 3; flex-basis: 100%; max-width: none; }
    .portal-quicksearch__results { width: 100%; }
    .portal-quicksearch__key { display: none; }
}

/* Search results page. */
.portal-search-groups { display: grid; gap: 1rem; }
@media (min-width: 1024px) {
    .portal-search-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.portal-search-group {
    padding: 1rem;
    border: 1px solid var(--line-soft);
    border-radius: 1rem;
    background: var(--surface-card);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}
.portal-search-group__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.portal-search-group__head h3 { margin: 0; font-size: 1rem; font-weight: 600; color: #1f2937; }
.portal-search-group__head a { color: #008060; font-size: 0.82rem; font-weight: 600; text-decoration: none; }
.portal-search-group .portal-quicksearch__item { padding-left: 0.35rem; padding-right: 0.35rem; }

/* Logout remains a labelled touch target throughout the shared portal shell. */
.app-header__logout { min-height: 44px; white-space: nowrap; }
