/* Theme: default dark matches existing Tailwind slate palette */
html[data-theme='dark'],
html:not([data-theme]) {
    color-scheme: dark;
}

html[data-theme='light'] {
    color-scheme: light;
}

html[data-theme='light'] body {
    background-color: #f1f5f9 !important;
    color: #0f172a;
}

/* Light mode: readable text on surfaces (cards, panels) */
html[data-theme='light'] .bg-slate-950 { background-color: #f1f5f9 !important; }
html[data-theme='light'] .bg-slate-900 { background-color: #ffffff !important; }
html[data-theme='light'] .bg-slate-800 { background-color: #f8fafc !important; }
html[data-theme='light'] .bg-slate-800\/40 { background-color: rgb(248 250 252 / 0.85) !important; }
html[data-theme='light'] .border-slate-800 { border-color: #e2e8f0 !important; }
html[data-theme='light'] .border-slate-700 { border-color: #cbd5e1 !important; }

html[data-theme='light'] .text-white { color: #0f172a !important; }
html[data-theme='light'] .text-slate-200 { color: #1e293b !important; }
html[data-theme='light'] .text-slate-300 { color: #334155 !important; }
html[data-theme='light'] .text-slate-400 { color: #475569 !important; }
html[data-theme='light'] .text-slate-500 { color: #64748b !important; }

html[data-theme='light'] .text-cyan-300 { color: #0e7490 !important; }
html[data-theme='light'] .text-cyan-400 { color: #0e7490 !important; }
html[data-theme='light'] .text-emerald-400 { color: #047857 !important; }
html[data-theme='light'] .text-violet-400 { color: #6d28d9 !important; }
html[data-theme='light'] .text-amber-300 { color: #b45309 !important; }
html[data-theme='light'] .text-amber-400 { color: #b45309 !important; }
html[data-theme='light'] .text-red-400 { color: #b91c1c !important; }

html[data-theme='light'] .hover\:bg-slate-800:hover { background-color: #e2e8f0 !important; }
html[data-theme='light'] .divide-slate-800 > :not([hidden]) ~ :not([hidden]) {
    border-color: #e2e8f0 !important;
}

/* Keep white text on colored action buttons & active nav */
html[data-theme='light'] .bg-cyan-600,
html[data-theme='light'] .bg-cyan-700,
html[data-theme='light'] .bg-emerald-700,
html[data-theme='light'] .bg-violet-600,
html[data-theme='light'] .bg-violet-700,
html[data-theme='light'] .bg-red-800,
html[data-theme='light'] .bg-red-700,
html[data-theme='light'] .bg-amber-700,
html[data-theme='light'] .bg-amber-600 {
    color: #ffffff !important;
}

html[data-theme='light'] .bg-cyan-600 .text-white,
html[data-theme='light'] .bg-cyan-700 .text-white,
html[data-theme='light'] .bg-emerald-700 .text-white,
html[data-theme='light'] .bg-violet-600 .text-white,
html[data-theme='light'] .bg-violet-700 .text-white,
html[data-theme='light'] .bg-red-800 .text-white,
html[data-theme='light'] .bg-red-700 .text-white,
html[data-theme='light'] .bg-amber-700 .text-white,
html[data-theme='light'] .bg-amber-600 .text-white,
html[data-theme='light'] a.bg-cyan-600,
html[data-theme='light'] a.bg-cyan-600.text-white {
    color: #ffffff !important;
}

html[data-theme='light'] .bg-emerald-950\/50 { background-color: rgb(236 253 245 / 0.9) !important; }
html[data-theme='light'] .border-emerald-800 { border-color: #6ee7b7 !important; }
html[data-theme='light'] .text-emerald-200,
html[data-theme='light'] .text-emerald-300 { color: #047857 !important; }

html[data-theme='light'] .bg-red-950\/50 { background-color: rgb(254 242 242 / 0.9) !important; }
html[data-theme='light'] .border-red-800 { border-color: #fca5a5 !important; }
html[data-theme='light'] .text-red-200,
html[data-theme='light'] .text-red-300 { color: #b91c1c !important; }

html[data-theme='light'] input,
html[data-theme='light'] select,
html[data-theme='light'] textarea {
    color: #0f172a !important;
}

/* Scrollable list: toolbar + sticky thead + body scroll; footer stays outside */
.list-panel {
    display: flex;
    flex-direction: column;
    max-height: min(calc(100vh - var(--app-chrome-offset, 11rem)), 900px);
    overflow: hidden;
}

@media (max-width: 1279px) {
    .list-panel {
        max-height: min(calc(100vh - var(--app-chrome-offset, 11rem)), 640px);
    }
}

.list-panel__toolbar {
    flex-shrink: 0;
}

.list-panel__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.list-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.list-table thead th {
    background-color: rgb(30 41 59);
    box-shadow: 0 1px 0 0 rgb(51 65 85);
}

.notes-panel {
    max-height: min(calc(100vh - var(--app-chrome-offset, 11rem)), 900px);
    overflow-y: auto;
}

@media (max-width: 1279px) {
    .notes-panel {
        max-height: none;
    }
}

html[data-theme='light'] footer {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
}

html[data-theme='light'] footer span {
    color: #64748b !important;
}

html[data-theme='light'] .bg-amber-950\/30 {
    background-color: rgb(255 251 235 / 0.9) !important;
}

html[data-theme='light'] .text-amber-200 {
    color: #b45309 !important;
}

html[data-theme='light'] .border-amber-800\/50 {
    border-color: #fcd34d !important;
}

html[data-theme='light'] .bg-slate-950.border {
    background-color: #f8fafc !important;
}

html[data-theme='light'] code.text-cyan-300,
html[data-theme='light'] code.text-slate-300 {
    color: #0e7490 !important;
}

html[data-theme='light'] .bg-emerald-950 .text-emerald-300,
html[data-theme='light'] .bg-emerald-950.border .text-emerald-300 {
    color: #047857 !important;
}

html[data-theme='light'] .bg-red-950 .text-red-300,
html[data-theme='light'] .bg-red-950.border .text-red-300 {
    color: #b91c1c !important;
}

html[data-theme='light'] .bg-cyan-950 .text-cyan-300,
html[data-theme='light'] .bg-cyan-950.border .text-cyan-300 {
    color: #0e7490 !important;
}

html[data-theme='light'] input::placeholder,
html[data-theme='light'] textarea::placeholder {
    color: #94a3b8 !important;
}

html[data-theme='light'] .list-table thead th {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
    box-shadow: 0 1px 0 0 #cbd5e1;
}

html[data-theme='light'] .list-table thead th a {
    color: #0f172a !important;
}

html[data-theme='light'] .list-table thead th a:hover {
    color: #0e7490 !important;
}

/* Theme segmented toggle */
.theme-toggle__track {
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    padding: 3px;
    border-radius: 0.625rem;
    border: 1px solid rgb(51 65 85);
    background-color: rgb(15 23 42);
    min-width: 9.5rem;
}

html[data-theme='light'] .theme-toggle__track {
    border-color: #cbd5e1;
    background-color: #e2e8f0;
}

.theme-toggle__indicator {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc((100% - 6px) / 3);
    height: calc(100% - 6px);
    border-radius: 0.45rem;
    background-color: rgb(8 145 178);
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
    transition: transform 0.2s ease;
    pointer-events: none;
    z-index: 0;
}

html[data-theme='light'] .theme-toggle__indicator {
    background-color: #0891b2;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.12);
}

.theme-toggle__btn {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 0.35rem 0.5rem;
    border: none;
    border-radius: 0.45rem;
    background: transparent;
    color: rgb(148 163 184);
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: color 0.15s ease;
    min-width: 0;
}

.theme-toggle__btn:hover {
    color: rgb(226 232 240);
}

html[data-theme='light'] .theme-toggle__btn {
    color: #64748b;
}

html[data-theme='light'] .theme-toggle__btn:hover {
    color: #334155;
}

.theme-toggle__btn.is-active {
    color: #ffffff;
}

html[data-theme='light'] .theme-toggle__btn.is-active {
    color: #ffffff;
}

.theme-toggle__icon {
    width: 0.95rem;
    height: 0.95rem;
    flex-shrink: 0;
}

.theme-toggle__label {
    white-space: nowrap;
}

@media (max-width: 480px) {
    .theme-toggle__track {
        min-width: 7.5rem;
    }

    .theme-toggle__label {
        display: none;
    }

    .theme-toggle__btn {
        padding: 0.45rem 0.35rem;
    }

    .theme-toggle__icon {
        width: 1.1rem;
        height: 1.1rem;
    }
}

/* PWA install prompt */
.pwa-install {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 60;
    padding: 0.75rem;
    pointer-events: none;
}

.pwa-install__card {
    pointer-events: auto;
    max-width: 36rem;
    margin: 0 auto;
    display: flex;
    gap: 0.875rem;
    align-items: flex-start;
    padding: 1rem 1.125rem;
    border-radius: 1rem;
    border: 1px solid rgb(51 65 85);
    background: rgb(15 23 42 / 0.96);
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 45px rgb(0 0 0 / 0.35);
}

html[data-theme='light'] .pwa-install__card {
    background: rgb(255 255 255 / 0.98);
    border-color: #e2e8f0;
}

.pwa-install__icon img {
    display: block;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.65rem;
}

.pwa-install__body {
    flex: 1;
    min-width: 0;
}

.pwa-install__title {
    margin: 0 0 0.25rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #f8fafc;
}

html[data-theme='light'] .pwa-install__title {
    color: #0f172a;
}

.pwa-install__text {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    line-height: 1.45;
    color: #94a3b8;
}

html[data-theme='light'] .pwa-install__text {
    color: #64748b;
}

.pwa-install__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pwa-install__btn {
    appearance: none;
    border: none;
    border-radius: 0.65rem;
    padding: 0.55rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.pwa-install__btn--primary {
    background: #0891b2;
    color: #fff;
}

.pwa-install__btn--primary:hover {
    background: #06b6d4;
}

.pwa-install__btn--ghost {
    background: transparent;
    color: #94a3b8;
    border: 1px solid rgb(51 65 85);
}

html[data-theme='light'] .pwa-install__btn--ghost {
    color: #475569;
    border-color: #cbd5e1;
}

.pwa-install__btn--full {
    width: 100%;
}

.pwa-install__ios-hint {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #cbd5e1;
}

html[data-theme='light'] .pwa-install__ios-hint {
    color: #475569;
}

.pwa-install__ios-icon {
    display: inline-block;
    margin: 0 0.15rem;
}

.pwa-shell-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    padding: 0.35rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fcd34d;
    background: rgb(120 53 15 / 0.35);
    border: 1px solid rgb(180 83 9 / 0.5);
}

html[data-theme='light'] .pwa-shell-badge {
    color: #b45309;
    background: #fffbeb;
    border-color: #fcd34d;
}

@media (min-width: 640px) {
    .pwa-install {
        padding: 1rem 1.25rem 1.25rem;
    }
}

/* UI feedback: loading overlay + result dialog */
body.ui-is-loading {
    overflow: hidden;
}

.ui-loading {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgb(2 6 23 / 0.72);
    backdrop-filter: blur(4px);
}

.ui-loading__panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-width: 16rem;
    max-width: 22rem;
    padding: 1.5rem 1.75rem;
    border-radius: 1rem;
    border: 1px solid rgb(51 65 85);
    background: rgb(15 23 42 / 0.98);
    box-shadow: 0 25px 50px rgb(0 0 0 / 0.35);
}

html[data-theme='light'] .ui-loading__panel {
    background: rgb(255 255 255 / 0.98);
    border-color: #e2e8f0;
}

.ui-loading__spinner {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    border: 3px solid rgb(51 65 85);
    border-top-color: #06b6d4;
    animation: ui-spin 0.75s linear infinite;
}

.ui-loading__text {
    margin: 0;
    text-align: center;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #e2e8f0;
}

html[data-theme='light'] .ui-loading__text {
    color: #334155;
}

@keyframes ui-spin {
    to { transform: rotate(360deg); }
}

.ui-dialog {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.ui-dialog__backdrop {
    position: absolute;
    inset: 0;
    background: rgb(2 6 23 / 0.65);
}

.ui-dialog__card {
    position: relative;
    width: 100%;
    max-width: 24rem;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgb(51 65 85);
    background: rgb(15 23 42);
    box-shadow: 0 25px 50px rgb(0 0 0 / 0.4);
    text-align: center;
}

html[data-theme='light'] .ui-dialog__card {
    background: #ffffff;
    border-color: #e2e8f0;
}

.ui-dialog__icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.75rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 700;
}

.ui-dialog__icon.is-success {
    background: rgb(6 78 59 / 0.35);
    color: #6ee7b7;
    border: 1px solid rgb(6 95 70);
}

.ui-dialog__icon.is-error {
    background: rgb(127 29 29 / 0.35);
    color: #fca5a5;
    border: 1px solid rgb(153 27 27);
}

.ui-dialog__icon.is-info {
    background: rgb(22 78 99 / 0.35);
    color: #67e8f9;
    border: 1px solid rgb(14 116 144);
}

.ui-dialog__title {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
}

html[data-theme='light'] .ui-dialog__title {
    color: #0f172a;
}

.ui-dialog__body {
    margin: 0 0 1.25rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #cbd5e1;
    white-space: pre-wrap;
}

html[data-theme='light'] .ui-dialog__body {
    color: #475569;
}

.ui-dialog__btn {
    appearance: none;
    border: none;
    border-radius: 0.75rem;
    padding: 0.65rem 1.25rem;
    min-width: 6rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    background: #0891b2;
    color: #fff;
}

.ui-dialog__btn:hover {
    background: #06b6d4;
}

.ui-btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.ui-btn.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1rem;
    height: 1rem;
    border-radius: 9999px;
    border: 2px solid rgb(255 255 255 / 0.35);
    border-top-color: #fff;
    animation: ui-spin 0.65s linear infinite;
}

/* App shell navigation (desktop sidebar + mobile bottom nav) */
.has-app-shell {
    --app-header-h: 3.5rem;
    --app-bottom-h: 4.25rem;
    --app-sidebar-w: 17rem;
    --app-sidebar-w-collapsed: 4.75rem;
    --app-chrome-offset: 11rem;
}

@media (max-width: 1023px) {
    .has-app-shell {
        --app-chrome-offset: 13.5rem;
    }
}

.app-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: var(--app-header-h) 1fr;
    grid-template-areas:
        'header'
        'content';
}

@media (min-width: 1024px) {
    .app-shell {
        grid-template-columns: var(--app-sidebar-w) 1fr;
        grid-template-rows: var(--app-header-h) 1fr;
        grid-template-areas:
            'sidebar header'
            'sidebar content';
        transition: grid-template-columns 0.22s ease;
    }

    .app-shell.is-sidebar-collapsed {
        grid-template-columns: var(--app-sidebar-w-collapsed) 1fr;
    }
}

.app-shell__sidebar {
    grid-area: sidebar;
    display: none;
    flex-direction: column;
    border-right: 1px solid rgb(30 41 59);
    background: rgb(15 23 42);
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    overflow: hidden;
}

@media (min-width: 1024px) {
    .app-shell__sidebar {
        display: flex;
    }
}

.app-shell__sidebar-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 0.75rem;
    border-bottom: 1px solid rgb(30 41 59);
    min-height: var(--app-header-h);
}

.app-shell__brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 1;
    text-decoration: none;
    color: #f8fafc;
    font-weight: 700;
    font-size: 0.95rem;
}

.app-shell__brand-icon {
    flex-shrink: 0;
    border-radius: 0.55rem;
}

.app-shell__brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease, width 0.2s ease;
}

.app-shell.is-sidebar-collapsed .app-shell__brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.app-shell__sidebar-toggle {
    appearance: none;
    border: 1px solid rgb(51 65 85);
    background: rgb(30 41 59);
    color: #94a3b8;
    width: 2rem;
    height: 2rem;
    border-radius: 0.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease, transform 0.2s ease;
}

.app-shell__sidebar-toggle:hover {
    background: rgb(51 65 85);
    color: #e2e8f0;
}

.app-shell__sidebar-toggle svg {
    width: 1rem;
    height: 1rem;
}

.app-shell.is-sidebar-collapsed .app-shell__sidebar-toggle {
    transform: rotate(180deg);
}

.app-shell__nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.65rem 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.app-shell__group {
    margin-bottom: 0.35rem;
}

.app-shell__group-btn {
    appearance: none;
    width: 100%;
    border: none;
    background: transparent;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-shell__group-btn:hover {
    background: rgb(30 41 59);
    color: #e2e8f0;
}

.app-shell__group-icon svg,
.app-shell__link-icon svg,
.app-shell__bottom-icon svg,
.app-shell__sheet-link-icon svg {
    width: 1.15rem;
    height: 1.15rem;
    display: block;
}

.app-shell__group-icon {
    flex-shrink: 0;
    display: inline-flex;
}

.app-shell__group-label {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

.app-shell.is-sidebar-collapsed .app-shell__group-label,
.app-shell.is-sidebar-collapsed .app-shell__group-chevron,
.app-shell.is-sidebar-collapsed .app-shell__link-label,
.app-shell.is-sidebar-collapsed .app-shell__user-name {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.app-shell__group-chevron {
    display: inline-flex;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.app-shell__group-chevron svg {
    width: 0.9rem;
    height: 0.9rem;
}

.app-shell__group[data-open] .app-shell__group-chevron {
    transform: rotate(90deg);
}

.app-shell__group-items {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.22s ease;
}

.app-shell__group[data-open] .app-shell__group-items {
    grid-template-rows: 1fr;
}

.app-shell.is-sidebar-collapsed .app-shell__group-btn {
    display: none;
}

.app-shell.is-sidebar-collapsed .app-shell__group-items {
    grid-template-rows: 1fr !important;
}

.app-shell__group-items > * {
    overflow: hidden;
}

.app-shell__link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0.15rem 0 0.15rem 0.35rem;
    padding: 0.55rem 0.7rem;
    border-radius: 0.75rem;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.app-shell.is-sidebar-collapsed .app-shell__link {
    margin-left: 0;
    justify-content: center;
    padding-left: 0.55rem;
    padding-right: 0.55rem;
}

.app-shell__link:hover {
    background: rgb(30 41 59);
    color: #f8fafc;
}

.app-shell__link.is-active {
    background: linear-gradient(135deg, rgb(8 145 178), rgb(6 182 212));
    color: #fff;
    box-shadow: inset 3px 0 0 #a5f3fc, 0 8px 20px rgb(8 145 178 / 0.25);
}

.app-shell__bottom-item.is-active {
    color: #22d3ee;
    background: rgb(8 145 178 / 0.15);
    box-shadow: inset 0 -2px 0 #22d3ee;
}

.app-shell__sheet-link.is-active {
    border-color: rgb(34 211 238 / 0.55);
    background: rgb(8 145 178 / 0.22);
    color: #67e8f9;
    box-shadow: inset 3px 0 0 #22d3ee;
}

.app-shell__link--logout {
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.app-shell__sidebar-foot {
    border-top: 1px solid rgb(30 41 59);
    padding: 0.65rem 0.5rem 0.85rem;
}

.app-shell__user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.65rem 0.65rem;
    min-width: 0;
}

.app-shell__user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background: rgb(8 145 178);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.app-shell__user-name {
    font-size: 0.8rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

.app-shell__header {
    grid-area: header;
    position: sticky;
    top: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: var(--app-header-h);
    padding: 0 1rem;
    border-bottom: 1px solid rgb(30 41 59);
    background: rgb(2 6 23 / 0.92);
    backdrop-filter: blur(10px);
}

.app-shell__header-start,
.app-shell__header-end {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.app-shell__header-end {
    flex-shrink: 0;
}

.app-shell__header-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #f8fafc;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
}

@media (min-width: 1024px) {
    .app-shell__header-brand {
        display: none;
    }
}

.app-shell__header-user {
    display: none;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.8rem;
    color: #94a3b8;
}

@media (min-width: 768px) {
    .app-shell__header-user {
        display: inline;
    }
}

.app-shell__icon-btn {
    appearance: none;
    border: 1px solid rgb(51 65 85);
    background: rgb(15 23 42);
    color: #cbd5e1;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-shell__icon-btn:hover {
    background: rgb(30 41 59);
    color: #fff;
}

.app-shell__icon-btn svg {
    width: 1.15rem;
    height: 1.15rem;
}

@media (min-width: 1024px) {
    .app-shell__menu-btn {
        display: none;
    }
}

.app-shell__content {
    grid-area: content;
    min-width: 0;
    padding-bottom: calc(var(--app-bottom-h) + 0.5rem);
}

@media (min-width: 1024px) {
    .app-shell__content {
        padding-bottom: 0;
    }
}

.app-shell__bottom {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: stretch;
    min-height: var(--app-bottom-h);
    padding: 0.35rem 0.5rem calc(0.35rem + env(safe-area-inset-bottom));
    border-top: 1px solid rgb(30 41 59);
    background: rgb(15 23 42 / 0.97);
    backdrop-filter: blur(12px);
    box-shadow: 0 -8px 30px rgb(0 0 0 / 0.22);
}

@media (min-width: 1024px) {
    .app-shell__bottom {
        display: none;
    }
}

.app-shell__bottom-item {
    appearance: none;
    border: none;
    background: transparent;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.35rem 0.25rem;
    border-radius: 0.85rem;
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.app-shell__bottom-item:active {
    transform: scale(0.96);
}

.app-shell__bottom-icon svg {
    width: 1.35rem;
    height: 1.35rem;
}

.app-shell__bottom-label {
    line-height: 1;
}

.app-shell__backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgb(2 6 23 / 0.55);
    backdrop-filter: blur(2px);
}

.app-shell__sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    max-height: min(85vh, 640px);
    border-radius: 1.25rem 1.25rem 0 0;
    border: 1px solid rgb(51 65 85);
    border-bottom: none;
    background: rgb(15 23 42);
    box-shadow: 0 -20px 50px rgb(0 0 0 / 0.35);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    padding-bottom: env(safe-area-inset-bottom);
}

.app-shell.is-nav-open .app-shell__sheet {
    transform: translateY(0);
}

.app-shell__sheet-handle {
    width: 2.5rem;
    height: 0.28rem;
    border-radius: 9999px;
    background: rgb(71 85 105);
    margin: 0.55rem auto 0;
}

.app-shell__sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 1rem 0.85rem;
    border-bottom: 1px solid rgb(30 41 59);
}

.app-shell__sheet-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #f8fafc;
}

.app-shell__sheet-body {
    overflow-y: auto;
    padding: 0.85rem 1rem 1.25rem;
    -webkit-overflow-scrolling: touch;
}

.app-shell__sheet-group + .app-shell__sheet-group {
    margin-top: 1rem;
}

.app-shell__sheet-group-title {
    margin: 0 0 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.app-shell__sheet-links {
    display: grid;
    gap: 0.35rem;
}

.app-shell__sheet-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.8rem 0.9rem;
    border-radius: 0.9rem;
    background: rgb(30 41 59);
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.app-shell__sheet-link:active {
    transform: scale(0.99);
}

.app-shell__sheet-link.is-active {
    border-color: rgb(34 211 238 / 0.45);
    background: rgb(8 145 178 / 0.18);
    color: #67e8f9;
}

.app-shell__sheet-link--button {
    appearance: none;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

body.app-nav-open {
    overflow: hidden;
}

.has-app-shell footer {
    margin-left: 0;
}

@media (min-width: 1024px) {
    .has-app-shell footer {
        margin-left: var(--app-sidebar-w);
        transition: margin-left 0.22s ease;
    }

    .app-shell.is-sidebar-collapsed ~ footer,
    .has-app-shell:has(.app-shell.is-sidebar-collapsed) footer {
        margin-left: var(--app-sidebar-w-collapsed);
    }
}

html[data-theme='light'] .app-shell__sidebar,
html[data-theme='light'] .app-shell__header,
html[data-theme='light'] .app-shell__bottom,
html[data-theme='light'] .app-shell__sheet {
    background: rgb(255 255 255 / 0.98);
    border-color: #e2e8f0;
}

html[data-theme='light'] .app-shell__brand,
html[data-theme='light'] .app-shell__header-brand,
html[data-theme='light'] .app-shell__sheet-title {
    color: #0f172a !important;
}

html[data-theme='light'] .app-shell__group-btn,
html[data-theme='light'] .app-shell__user-name,
html[data-theme='light'] .app-shell__header-user {
    color: #64748b;
}

html[data-theme='light'] .app-shell__link {
    color: #334155;
}

html[data-theme='light'] .app-shell__link:hover,
html[data-theme='light'] .app-shell__group-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

html[data-theme='light'] .app-shell__sheet-link {
    background: #f8fafc;
    color: #1e293b;
    border-color: #e2e8f0;
}

html[data-theme='light'] .app-shell__bottom-item {
    color: #64748b;
}

html[data-theme='light'] .app-shell__bottom-item.is-active {
    color: #0891b2;
    background: rgb(8 145 178 / 0.1);
}

html[data-theme='light'] .app-shell__icon-btn,
html[data-theme='light'] .app-shell__sidebar-toggle {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

@media (min-width: 1024px) {
    .has-app-shell .pwa-install {
        padding-left: calc(var(--app-sidebar-w) + 0.75rem);
        transition: padding-left 0.22s ease;
    }

    .has-app-shell:has(.app-shell.is-sidebar-collapsed) .pwa-install {
        padding-left: calc(var(--app-sidebar-w-collapsed) + 0.75rem);
    }
}

/* List table: tap row → action sheet on mobile/tablet */
.list-col-row-hint {
    display: none;
}

@media (max-width: 1023px) {
    .list-table--row-actions .list-col-actions {
        display: none !important;
    }

    .list-table--row-actions thead .list-col-actions {
        display: none !important;
    }

    .list-table--row-actions .list-col-row-hint {
        display: table-cell;
    }

    .list-table--row-actions tbody tr[data-has-actions] {
        cursor: pointer;
        -webkit-tap-highlight-color: rgb(8 145 178 / 0.15);
    }

    .list-table--row-actions tbody tr[data-has-actions]:active {
        background: rgb(30 41 59 / 0.55);
    }

    .list-row-hint-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.75rem;
        height: 1.75rem;
        border-radius: 9999px;
        background: rgb(30 41 59);
        color: #94a3b8;
        font-size: 1.1rem;
        line-height: 1;
        font-weight: 700;
        letter-spacing: 0.05em;
    }
}

.list-actions-sheet {
    position: fixed;
    inset: 0;
    z-index: 70;
    pointer-events: none;
}

.list-actions-sheet:not([hidden]) {
    pointer-events: auto;
}

.list-actions-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgb(2 6 23 / 0.55);
    backdrop-filter: blur(2px);
}

.list-actions-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: min(80vh, 520px);
    display: flex;
    flex-direction: column;
    border-radius: 1.25rem 1.25rem 0 0;
    border: 1px solid rgb(51 65 85);
    border-bottom: none;
    background: rgb(15 23 42);
    box-shadow: 0 -20px 50px rgb(0 0 0 / 0.35);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    padding-bottom: env(safe-area-inset-bottom);
}

.list-actions-sheet:not([hidden]) .list-actions-sheet__panel {
    transform: translateY(0);
}

.list-actions-sheet__handle {
    width: 2.5rem;
    height: 0.28rem;
    border-radius: 9999px;
    background: rgb(71 85 105);
    margin: 0.55rem auto 0;
    flex-shrink: 0;
}

.list-actions-sheet__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 1rem 0.85rem;
    border-bottom: 1px solid rgb(30 41 59);
    flex-shrink: 0;
}

.list-actions-sheet__eyebrow {
    margin: 0 0 0.2rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}

.list-actions-sheet__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1.3;
    word-break: break-word;
}

.list-actions-sheet__subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: #94a3b8;
    line-height: 1.35;
}

.list-actions-sheet__close {
    appearance: none;
    border: 1px solid rgb(51 65 85);
    background: rgb(30 41 59);
    color: #cbd5e1;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.list-actions-sheet__close svg {
    width: 1rem;
    height: 1rem;
}

.list-actions-sheet__body {
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    -webkit-overflow-scrolling: touch;
}

.list-actions-sheet__body a,
.list-actions-sheet__body button[type="submit"],
.list-actions-sheet__body button:not([type]) {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 2.75rem;
    padding: 0.7rem 1rem;
    border-radius: 0.85rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

.list-actions-sheet__body a:active,
.list-actions-sheet__body button:active {
    transform: scale(0.99);
}

.list-actions-sheet__body .flex,
.list-actions-sheet__body div[class*="flex"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.55rem !important;
    width: 100%;
}

.list-actions-sheet__body form {
    width: 100%;
}

.list-actions-sheet__body .text-xs.text-slate-500 {
    text-align: center;
    padding: 0.35rem 0;
}

body.list-actions-open {
    overflow: hidden;
}

html[data-theme='light'] .list-actions-sheet__panel {
    background: #ffffff;
    border-color: #e2e8f0;
}

html[data-theme='light'] .list-actions-sheet__title {
    color: #0f172a;
}

html[data-theme='light'] .list-actions-sheet__subtitle,
html[data-theme='light'] .list-actions-sheet__eyebrow {
    color: #64748b;
}

html[data-theme='light'] .list-row-hint-icon {
    background: #e2e8f0;
    color: #475569;
}

html[data-theme='light'] .list-actions-sheet__close {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

/* SPA content frame (Turbo) */
.app-shell__content {
    position: relative;
}

.app-content-frame {
    display: block;
    min-height: calc(100vh - var(--app-header-h) - 4rem);
    min-height: calc(100dvh - var(--app-header-h) - 4rem);
}

@media (min-width: 1024px) {
    .app-content-frame {
        min-height: calc(100vh - var(--app-header-h) - 2rem);
    }
}

.app-content-frame.is-loading {
    opacity: 0.72;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.app-content-frame:not(.is-loading) {
    animation: app-content-in 0.18s ease-out;
}

@keyframes app-content-in {
    from {
        opacity: 0.35;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-content-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 12;
    overflow: hidden;
    background: rgb(30 41 59 / 0.5);
}

.app-content-progress.is-active::after {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 35%;
    background: linear-gradient(90deg, #0891b2, #22d3ee);
    animation: app-content-progress 0.9s ease-in-out infinite;
}

@keyframes app-content-progress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(320%); }
}

/* Project Search chat */
.ps-chat__messages {
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

.ps-chat__msg {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: 92%;
}

.ps-chat__msg--user {
    align-self: flex-end;
    align-items: flex-end;
}

.ps-chat__msg--assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.ps-chat__msg-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

.ps-chat__bubble {
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    line-height: 1.55;
}

.ps-chat__msg--user .ps-chat__bubble {
    background: #0e7490;
    color: #ecfeff;
    border-bottom-right-radius: 0.25rem;
}

.ps-chat__msg--assistant .ps-chat__bubble {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-bottom-left-radius: 0.25rem;
}

html[data-theme='light'] .ps-chat__msg--assistant .ps-chat__bubble {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

.ps-chat__status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ps-chat__typing {
    display: inline-flex;
    gap: 0.2rem;
}

.ps-chat__typing span {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: #22d3ee;
    animation: ps-chat-typing 1.2s ease-in-out infinite;
}

.ps-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.ps-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ps-chat-typing {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}
