:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #607080;
    --line: #d9e0e6;
    --accent: #1f6fb2;
    --accent-strong: #185b93;
    --danger: #a93232;
    --soft: #eef6ff;
    --button-secondary-border: #c5ced8;
    --button-secondary-text: #263238;
    --danger-soft: #fff1f1;
    --shadow: 0 8px 22px rgba(15, 23, 42, 0.12);
    --mobile-vh: 100vh;
    --mobile-viewport-offset-top: 0px;
    --mobile-safe-top: max(env(safe-area-inset-top), var(--mobile-viewport-offset-top));
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

body {
    min-height: var(--mobile-vh);
    -webkit-text-size-adjust: 100%;
}

.mobile-ios.mobile-standalone {
    --mobile-safe-top: max(env(safe-area-inset-top), 14px);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    touch-action: manipulation;
}

.mobile-login,
.mobile-shell {
    min-height: var(--mobile-vh);
}

.mobile-login {
    display: grid;
    place-items: center;
    padding: 16px;
}

.mobile-login-panel,
.mobile-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.mobile-login-panel {
    width: min(420px, 100%);
    box-shadow: var(--shadow);
    padding: 16px;
}

.mobile-login-title,
.mobile-title {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}

.mobile-subtitle {
    margin: 4px 0 12px;
    color: var(--muted);
}

.mobile-field {
    display: grid;
    gap: 4px;
    margin-bottom: 10px;
}

.mobile-field span,
.mobile-check span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.mobile-input,
.mobile-select,
.mobile-textarea {
    width: 100%;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 6px 8px;
}

.mobile-textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.45;
}

.mobile-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    padding: 6px 10px;
    font-weight: 700;
    text-decoration: none;
}

.mobile-button.secondary {
    background: #fff;
    border-color: var(--button-secondary-border);
    color: var(--button-secondary-text);
}

.mobile-button.danger {
    border-color: var(--danger);
    background: var(--danger);
}

.mobile-button:disabled {
    opacity: 0.55;
}

.mobile-passkey-login {
    width: 100%;
    margin-top: 8px;
}

.mobile-error {
    min-height: 20px;
    color: var(--danger);
    font-size: 14px;
}

.mobile-setup {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.mobile-qr {
    display: block;
    width: 180px;
    height: 180px;
    margin: 0 auto 12px;
}

.mobile-secret {
    width: 100%;
    overflow-wrap: anywhere;
    background: var(--soft);
    border-radius: 6px;
    padding: 10px;
    font-family: Consolas, monospace;
}

.mobile-shell {
    display: grid;
    grid-template-rows: auto auto 1fr;
}

.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: minmax(86px, 1fr) auto minmax(112px, 1fr);
    gap: 8px;
    align-items: center;
    padding: calc(6px + var(--mobile-safe-top)) 8px 6px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.mobile-topbar-left,
.mobile-topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.mobile-topbar-actions {
    justify-content: flex-end;
}

.mobile-topbar-center {
    text-align: center;
    min-width: 0;
}

.mobile-logo {
    display: block;
    width: auto;
    height: 30px;
    max-width: 86px;
    object-fit: contain;
}

.mobile-user {
    color: var(--muted);
    font-size: 12px;
}

.mobile-logout {
    min-width: 0;
}

.mobile-user-button {
    font-size: 13px;
    font-weight: 700;
    color: var(--button-secondary-text);
}

.mobile-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 7px 8px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.mobile-tab {
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--text);
    padding: 6px 11px;
    white-space: nowrap;
}

.mobile-tab.active {
    border-color: var(--accent);
    background: var(--soft);
    color: var(--accent-strong);
    font-weight: 700;
}

.mobile-content {
    min-width: 0;
}

.mobile-pane {
    display: none;
    padding: 8px;
}

.mobile-pane.active {
    display: block;
}

.mobile-toolbar,
.mobile-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.mobile-search {
    flex: 1 1 180px;
}

.mobile-list {
    display: grid;
    gap: 4px;
}

.mobile-card {
    width: 100%;
    text-align: left;
    border: 1px solid var(--line);
    border-left: 5px solid #8a96a3;
    border-radius: 6px;
    background: var(--panel);
    padding: 7px 8px;
}

.mobile-card.active {
    border-color: var(--accent);
    border-left-color: var(--accent);
    background: var(--soft);
}

.mobile-card.prio-0 {
    border-left-color: #138a36;
}

.mobile-card.prio-2 {
    border-left-color: #d97706;
}

.mobile-card.prio-3 {
    border-left-color: #b42318;
}

.mobile-card-title {
    display: block;
    font-weight: 700;
    line-height: 1.2;
}

.mobile-card-meta {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.mobile-section {
    padding: 8px;
    margin-bottom: 6px;
}

.mobile-section-title {
    margin: 0 0 6px;
    font-size: 14px;
}

#pane-detail .mobile-section-title {
    margin-bottom: 10px;
}

#pane-detail .mobile-actions {
    margin-top: 10px;
    margin-bottom: 8px;
}

#pane-detail .mobile-item-head {
    margin-bottom: 8px;
}

#pane-detail #item-search {
    margin-bottom: 10px;
}

.mobile-empty {
    color: var(--muted);
    padding: 16px 0;
}

.mobile-item,
.mobile-file {
    border-top: 1px solid var(--line);
    padding: 7px 0;
}

.mobile-item:first-child,
.mobile-file:first-child {
    border-top: 0;
    padding-top: 0;
}

.mobile-item-head {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    justify-content: space-between;
}

.mobile-item-title {
    font-weight: 700;
}

.mobile-item-meta,
.mobile-file-meta {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.mobile-item-text {
    margin-top: 6px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.mobile-detail-table {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 6px;
}

.mobile-detail-row {
    display: grid;
    grid-template-columns: minmax(92px, 28%) 1fr;
    border-top: 1px solid var(--line);
    background: #fff;
}

.mobile-detail-row:first-child {
    border-top: 0;
}

.mobile-detail-label,
.mobile-detail-value {
    min-width: 0;
    padding: 5px 7px;
    line-height: 1.28;
}

.mobile-detail-label {
    background: #f7f9fa;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    border-right: 1px solid var(--line);
}

.mobile-detail-value {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.mobile-detail-row.multiline .mobile-detail-value {
    max-height: 132px;
    overflow: auto;
}

.mobile-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
}

.mobile-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--accent-strong);
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 700;
}

.mobile-icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-size: 17px;
    line-height: 1;
    font-weight: 700;
}

.mobile-icon-action.danger {
    border-color: var(--danger);
    background: var(--danger-soft);
    color: var(--danger);
}

.mobile-icon-action:disabled {
    opacity: 0.5;
}

.mobile-check {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.mobile-check input {
    width: 22px;
    height: 22px;
}

.mobile-modal-root {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.mobile-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
}

.mobile-modal {
    position: absolute;
    inset: auto 0 0;
    max-height: 92vh;
    overflow: auto;
    background: var(--panel);
    border-radius: 8px 8px 0 0;
    padding: 10px;
    box-shadow: var(--shadow);
}

.mobile-confirm-modal {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(360px, calc(100vw - 32px));
    transform: translate(-50%, -50%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    box-shadow: var(--shadow);
}

.mobile-selfcare-modal {
    position: absolute;
    left: 50%;
    top: calc(16px + var(--mobile-safe-top));
    width: min(780px, calc(100vw - 20px));
    max-height: calc(var(--mobile-vh) - var(--mobile-safe-top) - 32px);
    transform: translateX(-50%);
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    box-shadow: var(--shadow);
}

.mobile-selfcare-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin-bottom: 8px;
    padding-bottom: 2px;
}

.mobile-selfcare-body {
    min-width: 0;
}

.mobile-selfcare-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.mobile-selfcare-form .wide {
    grid-column: 1 / -1;
}

.mobile-selfcare-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
}

.mobile-selfcare-summary-card {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
    padding: 7px 8px;
}

.mobile-selfcare-summary-card span,
.mobile-selfcare-row span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.mobile-selfcare-summary-card strong {
    display: block;
    margin-top: 2px;
    font-size: 16px;
}

.mobile-selfcare-title {
    margin: 8px 0 6px;
    font-size: 13px;
}

.mobile-selfcare-list {
    display: grid;
    gap: 6px;
}

.mobile-selfcare-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 8px;
}

.mobile-selfcare-row strong {
    display: block;
    margin-bottom: 2px;
}

.mobile-passkey-head {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.mobile-error.is-ok {
    color: #176b2c;
}

.mobile-confirm-text {
    margin: 0 0 14px;
    color: var(--muted);
    line-height: 1.4;
}

.mobile-confirm-actions {
    justify-content: flex-end;
    margin-bottom: 0;
}

.mobile-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.mobile-icon-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-size: 24px;
}

.mobile-menu-button {
    display: grid;
    align-content: center;
    gap: 4px;
    padding: 8px;
}

.mobile-menu-button span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
}

.mobile-menu {
    position: fixed;
    inset: 0;
    z-index: 45;
}

.mobile-menu-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.34);
}

.mobile-menu-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 84vw);
    background: var(--panel);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: calc(12px + var(--mobile-safe-top)) 10px 10px;
}

.mobile-menu-title {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.mobile-menu-items {
    display: grid;
    gap: 4px;
}

.mobile-menu-item {
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    padding: 8px 10px;
    text-align: left;
}

.mobile-menu-item.active {
    border-color: var(--accent);
    background: var(--soft);
    color: var(--accent-strong);
    font-weight: 700;
}

.mobile-time-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 6px;
    align-items: end;
    margin-bottom: 6px;
}

.mobile-time-filters .mobile-field {
    margin-bottom: 0;
}

.mobile-time-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin-bottom: 6px;
}

.mobile-stat-chip {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 5px 6px;
}

.mobile-stat-chip span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.mobile-stat-chip strong {
    display: block;
    margin-top: 1px;
    font-size: 13px;
}

.mobile-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.mobile-detail-head {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.mobile-time-actions {
    gap: 8px;
    margin: 8px 0 10px;
}

.mobile-time-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.mobile-time-form .mobile-field,
.mobile-time-form .mobile-check {
    margin-bottom: 0;
}

.mobile-time-form .wide {
    grid-column: 1 / -1;
}

.mobile-report-modal {
    width: min(460px, calc(100vw - 24px));
}

.mobile-loading {
    padding: 24px;
    color: var(--muted);
}

@media (min-width: 760px) {
    html,
    body {
        height: 100%;
        overflow: hidden;
    }

    .mobile-shell {
        height: var(--mobile-vh);
        min-height: 0;
        overflow: hidden;
    }

    .mobile-content {
        display: grid;
        grid-template-columns: minmax(280px, 38%) 1fr;
        gap: 8px;
        padding: 8px;
        min-height: 0;
        overflow: hidden;
    }

    .mobile-pane {
        display: block;
        padding: 0;
        min-height: 0;
        overflow: auto;
        overscroll-behavior: contain;
    }

    #pane-list {
        padding-right: 2px;
    }

    #pane-detail {
        padding-left: 2px;
    }

    .mobile-tabs {
        display: none;
    }

    .mobile-modal {
        top: 40px;
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translateX(-50%);
        width: min(680px, calc(100vw - 40px));
        max-height: calc(var(--mobile-vh) - 80px);
        border-radius: 8px;
    }
}

@media (max-width: 520px) {
    .mobile-topbar {
        grid-template-columns: auto 1fr auto;
    }

    .mobile-logo {
        display: none;
    }

    .mobile-title {
        font-size: 16px;
    }

    .mobile-logout {
        padding-inline: 8px;
    }

    .mobile-selfcare-form,
    .mobile-selfcare-summary {
        grid-template-columns: 1fr;
    }

    .mobile-passkey-head {
        display: grid;
    }

    .mobile-time-filters,
    .mobile-time-stats,
    .mobile-time-form {
        grid-template-columns: 1fr;
    }

    .mobile-time-filters {
        align-items: stretch;
    }
}
