.app-shell {
    width: 100%;
    min-height: 100vh;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(230px, 290px) minmax(0, 1fr);
    position: relative;
    z-index: 1;
    gap: 0;
}

.app-header {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.75rem;
    padding: 2rem 1.75rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.42));
    border-right: 1px solid var(--border);
    box-shadow: 12px 0 28px rgba(21, 17, 11, 0.08);
    backdrop-filter: blur(12px);
    z-index: 2;
    overflow: visible;
}

.app-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 12%, rgba(27, 47, 138, 0.16), transparent 45%);
    pointer-events: none;
    z-index: 0;
}

.app-header > * {
    position: relative;
    z-index: 1;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    justify-content: flex-start;
    position: relative;
    z-index: 1;
}

.brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: linear-gradient(140deg, var(--accent), var(--accent-alt));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    letter-spacing: 0.08em;
    box-shadow: 0 12px 22px rgba(27, 47, 138, 0.25);
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-name {
    font-size: 1.35rem;
    font-weight: 700;
}

.brand-tag {
    font-size: 0.9rem;
    color: var(--muted);
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.25rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(31, 28, 24, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
    position: relative;
    z-index: 1;
}

.user-profile-button-container {
    position: relative;
    margin-top: auto;
    z-index: 2;
}

#user_profile_button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    white-space: nowrap;
    position: relative;
    z-index: 2;
    border-radius: 16px;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border);
    color: var(--ink);
    box-shadow: 0 10px 18px rgba(21, 17, 11, 0.08);
}

#user_profile_button img {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid rgba(31, 28, 24, 0.16);
}

.profile-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% - 0.35rem);
    padding-bottom: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease;
    z-index: 4;
}

.user-profile-button-container.is-open .profile-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.profile-menu-card {
    min-width: 230px;
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid rgba(31, 28, 24, 0.12);
    background: var(--surface-strong);
    box-shadow: 0 18px 28px rgba(21, 17, 11, 0.18);
    display: grid;
    gap: 0.75rem;
}

.profile-menu-avatar {
    display: flex;
    justify-content: center;
}

.profile-menu-avatar img {
    width: 128px;
    height: 128px;
    border-radius: 16px;
    object-fit: cover;
    border: 1px solid var(--border);
    background: #ffffff;
}

.profile-menu-actions {
    display: grid;
    gap: 0.5rem;
}

.profile-menu-actions button {
    width: 100%;
    justify-content: center;
}

.app-nav a {
    padding: 0.7rem 1rem;
    border-radius: 14px;
    color: var(--muted);
    font-weight: 600;
    letter-spacing: 0.01em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.app-nav a:hover {
    color: var(--ink);
    background: rgba(27, 47, 138, 0.12);
    transform: translateX(2px);
}

.app-nav a.is-active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent), var(--accent-alt));
    box-shadow: 0 10px 18px rgba(27, 47, 138, 0.28);
}

.app-main {
    flex: 1;
    width: 100%;
    background: var(--surface);
    border-left: 1px solid rgba(255, 255, 255, 0.6);
    padding: 2.75rem 3rem;
    min-height: 100vh;
}

.app-main.page-enter .page {
    animation: pageFade 0.62s ease-out;
}

.app-main.page-enter-prep .page {
    opacity: 0;
    transform: translateY(10px);
}

.page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.page.narrow {
    max-width: 460px;
    margin: 0 auto;
    width: 100%;
}

.page-header h1 {
    margin: 0;
    font-size: 2.1rem;
}
.page-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.78));
    padding: 1.5rem 1.75rem 1.5rem 1.9rem;
    border-radius: 18px;
    border: 1px solid rgba(31, 28, 24, 0.1);
    position: relative;
    box-shadow: 0 14px 28px rgba(21, 17, 11, 0.08);
}

.page-header p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    text-shadow: 0 1px 12px rgba(255, 255, 255, 0.6);
}

.page-header::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1rem;
    bottom: 1rem;
    width: 6px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--accent), rgba(42, 107, 181, 0.8));
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.card {
    background: linear-gradient(180deg, #ffffff, #fdfbf6);
    border: 1px solid rgba(31, 28, 24, 0.1);
    border-radius: 18px;
    padding: 1.2rem 1.4rem;
    box-shadow: 0 18px 32px rgba(21, 17, 11, 0.1);
    position: relative;
    overflow: hidden;
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-top: 4px solid rgba(27, 47, 138, 0.18);
    pointer-events: none;
}

.card h2 {
    margin: 0 0 0.5rem;
    font-size: 1.6rem;
}

.value {
    font-size: 1.6rem;
    font-weight: 600;
    font-family: var(--font-display);
    margin: 0;
}

.meta {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.data-row {
    display: grid;
    gap: 0.35rem;
    padding: 0.65rem 0;
}

.data-row--columns {
    grid-auto-flow: column;
    grid-auto-columns: minmax(16rem, max-content);
    gap: 0;
    align-items: stretch;
    width: max-content;
    min-width: 100%;
}

.data-row-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.25rem;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.data-row--columns .data-column {
    min-width: 0;
    padding: 0 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.data-row--columns .data-column > .value {
    display: block;
}

.data-row--columns p,
.data-row--columns a {
    margin: 0;
    white-space: nowrap;
}

.data-row--columns .data-column:first-child {
    padding-left: 0;
}

.data-row--columns .data-column:last-child {
    padding-right: 0;
}

.data-row--columns .data-column + .data-column {
    border-left: 1px dashed rgba(31, 28, 24, 0.18);
}

.data-row + .data-row {
    border-top: 1px solid rgba(31, 28, 24, 0.12);
}

.data-row .value {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0;
    font-size: 1.05rem;
}

.span-label {
    flex: 1;
    min-width: 0;
}

.span-actions {
    display: inline-flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.data-row .meta {
    margin: 0;
    font-size: 0.8rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field.password-field {
    position: relative;
}

.password_validation_popup {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.2rem);
    z-index: 3;
    padding: 0.75rem 0.9rem;
    border-radius: 14px;
    border: 1px solid rgba(31, 28, 24, 0.14);
    background: var(--surface-strong);
    box-shadow: 0 16px 24px rgba(21, 17, 11, 0.14);
}

.password_validation_popup h2 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.password_validation_popup ul {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.password_validation_popup li.valid {
    text-decoration: line-through;
    color: var(--accent-strong);
}

input,
select,
textarea {
    padding: 0.65rem 0.8rem;
    border-radius: 12px;
    border: 1px solid rgba(31, 28, 24, 0.16);
    background: rgba(255, 255, 255, 0.96);
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(27, 47, 138, 0.65);
    box-shadow: 0 0 0 3px rgba(27, 47, 138, 0.18);
}

.input-with-suggestions {
    position: relative;
    width: 100%;
}

.suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 6;
    background: var(--surface-strong);
    border: 1px solid rgba(31, 28, 24, 0.14);
    border-radius: 12px;
    box-shadow: 0 14px 22px rgba(21, 17, 11, 0.16);
    padding: 0.35rem;
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.suggestions.is-visible {
    display: block;
}

button.suggestion-item {
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: var(--ink);
    padding: 0.45rem 0.6rem;
    border-radius: 10px;
    box-shadow: none;
    transform: none;
}

button.suggestion-item:hover {
    background: rgba(27, 47, 138, 0.12);
    box-shadow: none;
    transform: none;
}

button.suggestion-item.is-active {
    background: rgba(27, 47, 138, 0.18);
    color: var(--accent-strong);
}

button {
    padding: 0.65rem 1.2rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, var(--accent), var(--accent-alt));
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition:
        transform 0.15s ease,
        box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 20px rgba(27, 47, 138, 0.25);
}

button.button-secondary {
    background: rgba(27, 47, 138, 0.08);
    color: var(--accent-strong);
    border-color: rgba(27, 47, 138, 0.18);
    box-shadow: none;
}

button.button-secondary:hover {
    background: rgba(27, 47, 138, 0.14);
    box-shadow: none;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button.button-small,
.button-small button {
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(27, 47, 138, 0.12);
    color: var(--accent-strong);
    font-size: 0.8rem;
    font-weight: 600;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-strong);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(31, 28, 24, 0.12);
    /* box-shadow: 0 12px 24px rgba(21, 17, 11, 0.08); */
}

.table th,
.table td {
    padding: 0.85rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid rgba(31, 28, 24, 0.1);
    font-size: 0.92rem;
}

.table th {
    background: rgba(27, 47, 138, 0.1);
    color: var(--accent-strong);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 1px 0 rgba(31, 28, 24, 0.12);
}

.table tr:last-child td {
    border-bottom: none;
}

.table-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    /* padding-bottom: 0.25rem; */
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.table-scroll-y {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-strong);
    border-radius: 16px;
    overflow-y: auto;
    max-height: 30em;
    scrollbar-gutter: hide;
    overflow-x: hidden;
    border: 1px solid rgba(31, 28, 24, 0.12);
    position: relative;
}

.table-scroll-y .table {
    overflow: visible;
    border-collapse: separate;
    border-spacing: 0;
}

.table-scroll-y thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: linear-gradient(0deg, rgba(27, 47, 138, 0.1), rgba(27, 47, 138, 0.1)), var(--surface-strong);
    box-shadow: 0 2px 0 rgba(31, 28, 24, 0.12);
}

.table-scroll-y .table td {
    position: relative;
    z-index: 1;
}

.table--wide {
    width: max-content;
    min-width: 100%;
}

.table--wide th,
.table--wide td {
    white-space: nowrap;
}

.inline-status {
    font-size: 0.9rem;
    color: var(--muted);
    margin-left: 0.75rem;
}

.hide-scrollbar {
  -ms-overflow-style: none;  /* Internet Explorer and Edge */
  scrollbar-width: none;     /* Firefox */
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;             /* Chrome, Safari, Opera, and newer Edge */
}

.notice {
    padding: 0.75rem 1rem;
    background: rgba(27, 47, 138, 0.1);
    border-radius: 10px;
    color: var(--accent);
}

#loading_overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    gap: 0.75rem;
    background: rgba(31, 28, 24, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
    color: #ffffff;
    font-weight: 600;
}

#loading_overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.loading-spinner {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.08) inset;
    animation: spinnerSpin 0.9s linear infinite;
}

#loading_overlay[aria-hidden="true"] .loading-spinner {
    animation-play-state: paused;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: grid;
    place-items: center;
    padding: 1.5rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 900;
    overflow-y: scroll;
}

.modal.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.modal .modal-content {
    background: var(--surface-strong);
    border: 1px solid rgba(31, 28, 24, 0.14);
    border-radius: 20px;
    box-shadow: 0 18px 28px rgba(21, 17, 11, 0.16);
    width: 100%;
    max-width: 760px;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.modal-header h2 {
    margin: 0;
}

.modal-header .meta {
    margin-top: 0.35rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.25rem;
}

.modal .field input,
.modal .field select,
.modal .field textarea {
    width: 100%;
}

.close-button {
    font-size: larger;
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 0.35rem 0.6rem;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: none;
}

.close-button:hover {
    background: rgba(31, 28, 24, 0.08);
    color: var(--ink);
    transform: none;
    box-shadow: none;
}

textarea {
    resize: vertical;
}

.profile-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    padding: 1rem;
    border-radius: 18px;
    border: 1px dashed rgba(31, 28, 24, 0.16);
    background: rgba(27, 47, 138, 0.06);
}

.profile-image-container img {
    width: min(220px, 100%);
    aspect-ratio: 1;
    border-radius: 20px;
    object-fit: cover;
    background: #ffffff;
    border: 1px solid rgba(31, 28, 24, 0.14);
    box-shadow: 0 12px 24px rgba(21, 17, 11, 0.1);
}

#accounts_table td[data-long-text] {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-navigation {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 1.2rem;
    padding-top: 1.5rem;
}

[data-accounts-page-btn] {
    cursor: pointer;
    user-select: none;
    padding: 0.2rem 0.5rem;
}

@keyframes spinnerSpin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pageFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    #loading_overlay {
        transition: none;
    }

    .loading-spinner {
        animation-duration: 1.6s;
    }
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-header {
        height: auto;
        position: sticky;
        flex-direction: row;
        align-items: center;
        padding: 1rem 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border);
        box-shadow: 0 12px 24px rgba(21, 17, 11, 0.08);
    }

    .brand {
        flex: 1;
    }

    .app-nav {
        flex-direction: row;
        flex-wrap: wrap;
        border-radius: 999px;
        padding: 0.35rem;
    }

    .app-nav a {
        border-radius: 999px;
        padding: 0.45rem 0.85rem;
    }

    .user-profile-button-container {
        margin-top: 0;
    }

    #user_profile_button {
        width: auto;
        padding: 0.55rem 0.9rem;
    }

    .profile-menu {
        bottom: auto;
        top: 100%;
        padding-top: 0.75rem;
        padding-bottom: 0;
        transform: translateY(-6px);
    }

    .app-main {
        border-left: none;
        min-height: auto;
    }
}

@media (max-width: 720px) {
    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 1rem 1.25rem;
    }

    .app-nav {
        width: 100%;
    }

    #user_profile_button {
        width: 100%;
    }

    .app-main {
        padding: 1.5rem 1.25rem 2.5rem;
    }
}
.hidden {
    display: none;
}

.overflow-scroll-horizontal {
    overflow-x: scroll;
    -webkit-overflow-scrolling: touch;
}
