
:root {
    color-scheme: dark;

    --bg: #121212;
    --surface: #1e1e1e;
    --surface-2: #252525;
    --surface-3: #2d2d2d;

    --border: #3a3a3a;
    --border-strong: #4a4a4a;

    --text: #e8e8e8;
    --text-muted: #9a9a9a;
    --text-soft: #bdbdbd;

    --primary: #4d63cc;
    --primary-hover: #596fd8;
    --link: #8ab4f8;

    --success: #75d58a;
    --success-bg: #173d24;
    --success-border: #3a8f52;

    --warning: #e8c76b;
    --warning-bg: #3a3018;
    --warning-border: #6b5928;

    --danger: #ff8f8f;
    --danger-bg: #3b2020;
    --danger-border: #693535;

    --radius: 10px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
}

/* =========================================================
   GLOBAL
   ========================================================= */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

.container {
    width: calc(100% - 40px);
    max-width: 1400px;
    margin: 40px auto;
}

.container.small {
    max-width: 560px;
}

h1,
h2,
h3 {
    color: #fff;
    line-height: 1.2;
}

h1 {
    margin: 0 0 8px;
}

h2 {
    margin-top: 0;
}

p {
    margin: 0 0 16px;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.username,
.muted {
    color: var(--text-muted);
    font-size: 14px;
}

.username {
    margin-top: 5px;
}

/* =========================================================
   HEADER AND TOOLBARS
   ========================================================= */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
}

.toolbar,
.toolbar-actions,
.toolbar-right,
.settings-links,
.user-actions,
.row-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar {
    margin-bottom: 26px;
}

.toolbar-actions {
    justify-content: space-between;
    gap: 20px;
}

.toolbar-right {
    justify-content: flex-end;
}

/* =========================================================
   CARDS
   ========================================================= */

.card {
    margin-top: 20px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.empty-state {
    text-align: center;
}

/* =========================================================
   FORMS
   ========================================================= */

form {
    width: 100%;
}

label {
    display: block;
    margin-bottom: 20px;
    color: #eee;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    margin-top: 8px;
    padding: 12px 13px;
    background: #292929;
    color: #fff;
    border: 1px solid #444;
    border-radius: 7px;
    font: inherit;
    font-size: 16px;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid transparent;
    border-color: var(--link);
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: #858585;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input,
.delete-field-label input {
    width: 19px;
    height: 19px;
    margin: 0;
}

.delete-field-label {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    color: var(--danger);
    font-size: 14px;
    font-weight: 400;
}

/* =========================================================
   BUTTONS
   ========================================================= */

button,
.button,
.action-button,
.nav-button,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 7px;
    font: inherit;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

button,
.button {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

button:hover,
.button:hover {
    background: var(--primary-hover);
    color: #fff;
    text-decoration: none;
}

.action-button,
.nav-button,
.secondary-button {
    background: var(--surface-3);
    color: #ddd;
    border-color: #444;
}

.action-button:hover,
.nav-button:hover,
.secondary-button:hover {
    background: #383838;
    color: #fff;
    border-color: #555;
    text-decoration: none;
}

.action-success {
    background: #193a24;
    color: var(--success);
    border-color: #2d643a;
}

.action-success:hover {
    background: #20492d;
}

.action-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-color: var(--warning-border);
}

.action-warning:hover {
    background: #493b1d;
}

.action-danger,
.danger-button {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
}

.action-danger:hover,
.danger-button:hover {
    background: #4b2727;
    color: #ffaaaa;
    border-color: #824040;
}

.inline-form {
    display: inline-flex;
    width: auto;
    margin: 0;
    padding: 0;
}

/* =========================================================
   FEEDBACK AND STATUS
   ========================================================= */

.error,
.success {
    margin: 0 0 20px;
    padding: 15px 17px;
    border-radius: 8px;
}

.error {
    background: #3b1919;
    color: #ffb4ab;
    border: 1px solid #6b3030;
}

.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
    font-size: 16px;
}

.status-approved {
    color: #66c97a;
}

.status-pending {
    color: #ff7770;
}

.warning-text {
    color: var(--warning);
}

/* =========================================================
   DASHBOARD
   ========================================================= */

.list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.list-card-shell {
    position: relative;
    min-width: 0;
}

.list-card {
    display: block;
    min-height: 100%;
    padding: 22px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    transition:
        transform 0.15s ease,
        border-color 0.15s ease,
        background-color 0.15s ease;
}

.list-card:hover {
    transform: translateY(-2px);
    background: #222;
    border-color: #555;
    text-decoration: none;
}

.list-card h2 {
    margin-bottom: 10px;
}

.list-card p {
    color: #aaa;
}

.list-meta {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    color: #888;
    font-size: 14px;
}

/* =========================================================
   SHOPPING LIST
   ========================================================= */

.shopping-layout,
.shopping-card {
    width: 100%;
}

.shopping-form {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
}

.shopping-form input[type="text"] {
    flex: 1;
    min-width: 0;
}

.shopping-form button {
    flex: 0 0 auto;
}

.shopping-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 18px;
    color: #b8b8b8;
    font-size: 14px;
}

.shopping-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shopping-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    width: 100%;
    min-height: 58px;
    padding: 0 12px 0 20px;
    background: #242424;
    border: 1px solid #3d3d3d;
    border-radius: 8px;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease;
}

.shopping-item:hover {
    background: #292929;
    border-color: #4a4a4a;
}

.shopping-toggle-form {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.shopping-item-name {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: #f0f0f0;
    font-size: 15px;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.shopping-item-name:hover {
    background: transparent;
    color: #fff;
}

.shopping-item-name:focus {
    outline: none;
}

.shopping-item.completed .shopping-item-name {
    color: #777;
    text-decoration: line-through;
}

.shopping-delete {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid #713137;
    border-radius: 6px;
    background: #351c1f;
    color: #ff6b73;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        color 0.15s ease;
}

.shopping-delete:hover {
    background: #4a2025;
    border-color: #9b3e47;
    color: #ff858b;
}

.shopping-empty {
    padding: 30px 10px;
    color: #888;
    text-align: center;
}

.shopping-item > .inline-form,
.shopping-summary > .inline-form {
    margin: 0;
}

.clear-completed,
.shopping-summary .action-danger {
    border: 1px solid #713137;
    background: #351c1f;
    color: #ff6b73;
}

/* =========================================================
   FIELD EDITORS
   ========================================================= */

.field-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(150px, 1fr) 46px;
    gap: 10px;
    margin-bottom: 10px;
}

.field-row input,
.field-row select {
    margin: 0;
}

.remove-field {
    min-width: 42px;
    padding: 0 12px;
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-border);
    font-size: 20px;
}

.form-actions {
    margin-top: 28px;
}

/* =========================================================
   TABLES
   ========================================================= */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.data-table th,
.data-table td {
    padding: 13px 15px;
    text-align: left;
    vertical-align: middle;
    border-right: 1px solid #333;
    border-bottom: 1px solid #333;
    white-space: nowrap;
}

.data-table th:last-child,
.data-table td:last-child {
    border-right: 0;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table th {
    background: var(--surface-2);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.data-table td {
    color: #ddd;
}

.data-table tbody tr:nth-child(even) {
    background: #222;
}

.data-table tbody tr:hover {
    background: #292929;
}

.row-actions,
.user-actions {
    gap: 8px;
}

/* =========================================================
   SORTING AND PLACE SEARCH
   ========================================================= */

.sort-row {
    display: flex;
    justify-content: flex-end;
    margin: 20px 0 10px;
}

.sort-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-control label {
    margin: 0;
    color: #aaa;
    font-weight: 400;
}

.sort-control select {
    width: auto;
    min-width: 190px;
    margin-top: 0;
}

.place-search {
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    margin-top: 8px;
}

.place-search input.place-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    margin: 0;
}

.place-search-button {
    flex: 0 0 auto;
    min-width: 90px;
    margin: 0;
}

.place-results {
    width: 100%;
    margin-top: 8px;
}

.place-result {
    display: block;
    width: 100%;
    margin-bottom: 6px;
    padding: 10px 12px;
    background: #242424;
    color: #eee;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: left;
}

.place-result:hover {
    background: #303030;
}

.place-message {
    padding: 8px 0;
    color: var(--text-muted);
    font-size: 14px;
}

/* =========================================================
   PASSWORD FIELDS
   ========================================================= */

.password-field {
    position: relative;
    width: 100%;
}

.password-field input {
    padding-right: 50px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    margin: 0;
    padding: 6px;
    background: transparent;
    color: #aaa;
    border: 0;
}

.password-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.password-toggle svg {
    display: block;
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.password-toggle .eye-slash {
    display: none;
}

.password-toggle.password-visible .eye-slash {
    display: block;
}

/* =========================================================
   SETTINGS
   ========================================================= */

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

.settings-grid .card {
    margin-top: 0;
}

.logout-card {
    border-color: #4b3030;
}

.language-form {
    max-width: 420px;
}

.bottom-link {
    margin: 18px 0 0;
}

.settings-links {
    gap: 10px;
}

.desktop-settings-link {
    display: inline-flex;
}

/* =========================================================
   GLOBAL APPLICATION NAVIGATION
   ========================================================= */

.app-nav {
    position: sticky;
    top: 0;
    z-index: 900;
    width: 100%;
    background: rgba(18, 18, 18, 0.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.app-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: calc(100% - 40px);
    max-width: 1400px;
    min-height: 62px;
    margin: 0 auto;
}

.app-nav-brand {
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.app-nav-brand:hover {
    color: #fff;
    text-decoration: none;
}

.app-nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
}

.app-nav-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 7px 12px;
    color: var(--text-muted);
    border-radius: 7px;
    text-decoration: none;
}

.app-nav-links a:hover {
    color: var(--text);
    background: #262626;
    text-decoration: none;
}

.app-nav-links a.active {
    color: #fff;
    background: #2d2d2d;
}

/* =========================================================
   MOBILE NAVIGATION
   ========================================================= */

.mobile-nav {
    display: none !important;
}

.mobile-nav svg {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    flex-shrink: 0;
}

/* =========================================================
   SECURITY AND RECOVERY
   ========================================================= */

.setup-key-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 18px 0 8px;
    padding: 14px;
    background: #171717;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.setup-key-box span {
    color: var(--text-muted);
    font-size: 14px;
}

.setup-key-box code {
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: 16px;
    letter-spacing: 0.08em;
}

.recovery-card {
    border-color: var(--warning-border);
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.recovery-codes code {
    padding: 9px 10px;
    text-align: center;
    background: #171717;
    border: 1px solid var(--border);
    border-radius: 6px;
    letter-spacing: 0.06em;
}

.trusted-device-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.trusted-device-item {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.trusted-device-item .muted {
    margin-top: 5px;
}

.trusted-device-actions {
    margin-top: 18px;
}

/* =========================================================
   CUSTOM DIALOGS
   ========================================================= */

.vault-dialog {
    width: min(460px, calc(100% - 32px));
    max-width: 460px;
    margin: auto;
    padding: 0;
    color: var(--text);
    background: transparent;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.vault-dialog::backdrop {
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(3px);
}

.vault-dialog-panel {
    padding: 24px;
    background: #202020;
    border: 1px solid #454545;
    border-radius: 12px;
}

.vault-dialog-title {
    margin: 0 0 10px;
    font-size: 20px;
    line-height: 1.3;
}

.vault-dialog-message {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.55;
    white-space: pre-line;
}

.vault-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.vault-dialog-actions button {
    min-width: 100px;
}

/* =========================================================
   FINANCE DASHBOARD
   ========================================================= */

.finance-page {
    padding-bottom: 36px;
}

.finance-summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin: 18px 0;
}

.finance-summary-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.finance-summary-card span {
    color: var(--text-muted);
    font-size: 13px;
}

.finance-summary-card strong {
    font-size: clamp(19px, 2.4vw, 28px);
    overflow-wrap: anywhere;
}

/* Summary card colors */
.finance-value-neutral {
    color: #fff;
}

.finance-value-expense {
    color: #dc2626;
}

.finance-value-positive {
    color: #16a34a;
}

.finance-form-card,
.finance-list-card {
    margin-top: 16px;
}

.finance-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.finance-form label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: var(--text);
    font-size: 13px;
}

.finance-form input,
.finance-form select {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.finance-form-actions {
    display: flex;
    align-items: end;
    gap: 10px;
}

.finance-help {
    margin: 14px 0 0;
    font-size: 13px;
}

.finance-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.finance-table {
    width: 100%;
    border-collapse: collapse;
}

.finance-table th,
.finance-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.finance-table th {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}

.finance-table td small {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
}

.finance-actions {
    white-space: nowrap;
}

.finance-actions form {
    display: inline-flex;
    margin-left: 5px;
}

/* =========================================================
   RESPONSIVE LAYOUT
   ========================================================= */

@media (max-width: 1000px) {
    .finance-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .finance-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    body {
        padding-bottom: calc(82px + env(safe-area-inset-bottom));
        font-size: 16px;
    }

    .container,
    .container.small {
        width: calc(100% - 24px);
        max-width: none;
        margin: 20px auto;
    }

    h1 {
        font-size: 26px;
    }

    h2 {
        font-size: 20px;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
        gap: 14px;
    }

    .topbar > .toolbar-right {
        justify-content: flex-start;
    }

    .card {
        padding: 18px;
        border-radius: 10px;
    }

    input,
    select,
    textarea {
        min-height: 48px;
        font-size: 16px;
    }

    button,
    .button,
    .action-button,
    .nav-button,
    .danger-button {
        min-height: 44px;
        padding: 10px 14px;
    }

    .toolbar-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-actions > div,
    .toolbar-actions > div:first-child,
    .toolbar-actions > div:first-child .button {
        width: 100%;
    }

    .toolbar-right {
        justify-content: flex-start;
    }

    .sort-row {
        justify-content: stretch;
        width: 100%;
    }

    .sort-control {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
        gap: 6px;
    }

    .sort-control select {
        width: 100%;
        min-width: 0;
    }

    .field-row {
        grid-template-columns: 1fr;
        padding: 12px;
        background: var(--surface);
        border: 1px solid #333;
        border-radius: 8px;
    }

    .place-search {
        display: grid;
        grid-template-columns: 1fr;
    }

    .place-search-button {
        width: 100%;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-links {
        align-items: stretch;
        flex-direction: column;
    }

    .settings-links .button,
    .settings-links .action-button,
    .settings-links .nav-button {
        width: 100%;
    }

    /* Data tables become readable cards on small screens. */
    .table-wrapper {
        overflow: visible;
        background: transparent;
        border: 0;
    }

    .data-table {
        display: block;
        min-width: 0;
        background: transparent;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody {
        display: block;
        width: 100%;
    }

    .data-table tbody tr {
        display: block;
        width: 100%;
        margin-bottom: 16px;
        overflow: hidden;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
    }

    .data-table tbody tr:nth-child(even),
    .data-table tbody tr:hover {
        background: var(--surface);
    }

    .data-table tbody td {
        display: grid;
        grid-template-columns: minmax(100px, 40%) minmax(0, 60%);
        gap: 12px;
        width: 100%;
        padding: 12px 14px;
        border-right: 0;
        border-bottom: 1px solid #333;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .data-table tbody td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 14px;
    }

    .data-table tbody td:last-child {
        border-bottom: 0;
    }

    .data-table tbody td.row-actions {
        display: flex;
        justify-content: flex-end;
        gap: 8px;
        padding: 12px 14px;
        background: #242424;
    }

    .data-table tbody td.row-actions::before {
        display: none;
    }

    .user-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .user-actions .inline-form,
    .user-actions .action-button {
        width: 100%;
    }

    .mobile-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
        display: grid !important;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        min-height: 68px;
        padding-bottom: env(safe-area-inset-bottom);
        background: #181818;
        border-top: 1px solid #333;
    }

    .mobile-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        min-height: 68px;
        color: #aaa;
        font-size: 12px;
        min-width: 0;
        padding: 0 4px;
        text-align: center;
        text-decoration: none;
    }

    .mobile-nav a:hover,
    .mobile-nav a:active {
        background: #222;
        color: #fff;
        text-decoration: none;
    }

    .mobile-nav a.active {
        color: var(--link);
    }

    .mobile-nav svg {
        width: 24px !important;
        height: 24px !important;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .desktop-settings-link,
    .app-nav {
        display: none !important;
    }

    .recovery-codes {
        grid-template-columns: 1fr;
    }

    .vault-dialog {
        width: calc(100% - 24px);
    }

    .vault-dialog-panel {
        padding: 20px;
    }

    .vault-dialog-actions {
        flex-direction: column-reverse;
    }

    .vault-dialog-actions button {
        width: 100%;
        min-height: 46px;
    }

    .finance-form {
        grid-template-columns: 1fr;
    }

    .finance-form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .finance-table thead {
        display: none;
    }

    .finance-table,
    .finance-table tbody,
    .finance-table tr,
    .finance-table td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .finance-table tr {
        padding: 10px 0;
        border-bottom: 1px solid var(--border);
    }

    .finance-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 6px 0;
        border: 0;
        text-align: right;
    }

    .finance-table td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 12px;
        text-align: left;
    }

    .finance-table td:first-child {
        display: block;
        text-align: left;
    }

    .finance-table td:first-child::before {
        display: none;
    }

    .finance-actions {
        justify-content: flex-end !important;
    }
}

@media (max-width: 600px) {
    .shopping-form {
        flex-direction: column;
    }

    .shopping-form input[type="text"],
    .shopping-form button {
        width: 100%;
    }

    .shopping-summary {
        align-items: stretch;
        flex-direction: column;
    }

    .shopping-item {
        min-height: 56px;
        padding-left: 16px;
        padding-right: 10px;
    }

    .shopping-item-name {
        font-size: 15px;
    }

    .shopping-delete {
        width: 36px;
        height: 36px;
    }

    .finance-summary-grid {
        grid-template-columns: 1fr;
    }
}


/* Finanzen: Kategorien in der Tabelle deutlicher hervorheben */
.finance-table tr.finance-category-row th {
    background: rgba(59, 130, 246, 0.14);
    border-top: 2px solid rgba(59, 130, 246, 0.45);
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
    padding: 14px 12px;
    font-weight: 700;
    vertical-align: middle;
}

/* Kategoriename */
.finance-table tr.finance-category-row th:first-child {
    text-align: left;
    border-left: 4px solid #3b82f6;
    font-size: 1rem;
    letter-spacing: 0.2px;
}

/* Kategoriesumme */
.finance-table tr.finance-category-row th:nth-child(2) {
    text-align: right;
    white-space: nowrap;
    font-size: 1rem;
    color: #60a5fa;
}

/* Einnahmen und Ausgaben als Gruppenhinweis */
.finance-table tr.finance-category-row th:last-child {
    text-align: left;
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Etwas mehr Luft zwischen den normalen Einträgen */
.finance-table tbody tr:not(.finance-category-row) td {
    padding-top: 12px;
    padding-bottom: 12px;
}

/* Kategorieüberschriften auch auf kleinen Bildschirmen lesbar halten */
@media (max-width: 600px) {
    .finance-table tr.finance-category-row th {
        padding: 12px 8px;
        font-size: 0.9rem;
    }

    .finance-table tr.finance-category-row th:first-child {
        font-size: 0.9rem;
    }

    .finance-table tr.finance-category-row th:nth-child(2) {
        font-size: 0.9rem;
    }
}




/* Finanztool: kompaktes Dropdown für mehrere Fälligkeitsmonate */
.finance-due-months {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.finance-due-months > legend {
    margin-bottom: 7px;
    padding: 0;
    font-weight: 600;
}

/* Dropdown als Overlay */
.finance-month-picker {
    position: relative;
}

.finance-month-picker > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid var(--border-color, #555);
    border-radius: 6px;
    background: var(--input-background, #292929);
    cursor: pointer;
    list-style: none;
}

.finance-month-picker > summary::-webkit-details-marker {
    display: none;
}

.finance-month-picker > summary::after {
    content: "▾";
    flex-shrink: 0;
}

.finance-month-picker[open] {
    z-index: 1000;
}

.finance-month-picker[open] > summary::after {
    content: "▴";
}

/* Monatsauswahl schwebt über dem restlichen Inhalt */
.finance-month-selection {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    z-index: 1001;

    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 8px;

    margin-top: 0;
    padding: 8px;
    border: 1px solid var(--border-color, #555);
    border-radius: 6px;
    background: var(--card-background, #202020);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.finance-month-selection label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 7px;
    min-width: 0;
    padding: 5px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.finance-month-selection label:hover {
    background: rgba(127, 127, 127, 0.14);
}

.finance-month-selection input {
    width: auto;
    margin: 0;
}

.finance-month-help {
    margin: 6px 0 0;
    font-size: 12px;
}

/* Darstellung auf kleinen Bildschirmen */
@media (max-width: 520px) {
    .finance-month-selection {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* =========================================================
   CALCULATED FIELDS AND TEMPLATE SHARING
   ========================================================= */

.field-editor-row {
    display: block;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.field-editor-main {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(150px, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.field-editor-main > input,
.field-editor-main > select {
    min-width: 0;
}

.calculation-editor {
    display: grid;
    grid-template-columns: repeat(4, minmax(130px, 1fr));
    gap: 10px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.calculation-editor[hidden],
.calculation-editor label[hidden] {
    display: none !important;
}

.calculation-editor label {
    min-width: 0;
    margin: 0;
    font-size: 13px;
}

.calculation-editor label > span {
    display: block;
    margin-bottom: 5px;
}

.calculation-editor input,
.calculation-editor select {
    margin-top: 0;
}

.calculation-help {
    grid-column: 1 / -1;
    margin: 0;
}

.field-marked-delete {
    opacity: 0.45;
}

.calculated-field {
    margin: 0 0 18px;
}

.calculated-field-label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-muted);
    font-weight: 600;
}

.calculated-value {
    display: block;
    min-height: 43px;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--surface-2);
    color: var(--text);
}

.template-share-form {
    display: inline-flex;
    align-items: center;
}

.template-share-checkbox {
    margin: 0;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
    white-space: nowrap;
}

.template-share-checkbox input {
    flex: 0 0 auto;
}

.template-shared-label {
    display: inline-block;
    margin-left: 7px;
    padding: 3px 7px;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-muted);
    font-size: 11px;
    vertical-align: middle;
}

.calculation-preview-table {
    margin: 20px 0;
}

.warning {
    margin: 0 0 20px;
    padding: 14px 16px;
    border: 1px solid var(--warning-border);
    border-radius: 8px;
    background: var(--warning-bg);
    color: var(--warning);
}

@media (max-width: 760px) {
    .field-editor-main {
        grid-template-columns: minmax(0, 1fr);
    }

    .calculation-editor {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .template-share-form {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .calculation-editor {
        grid-template-columns: minmax(0, 1fr);
    }
}


/* =========================================================
   LIST CARD SUMMARIES
   ========================================================= */

.list-summary {
    display: grid;
    gap: 7px;
    margin-top: 16px;
    padding-top: 13px;
    border-top: 1px solid var(--border);
}

.list-summary-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
}

.list-summary-item strong {
    color: var(--text);
    font-weight: 600;
    text-align: right;
    overflow-wrap: anywhere;
}

/* =========================================================
   SUMMARY CONFIGURATION
   ========================================================= */

.summary-config {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.summary-config-description,
.summary-config-help {
    color: var(--text-muted);
    font-size: 13px;
    margin: 6px 0 12px;
}

.summary-config-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.summary-config-item {
    margin-top: 0;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
}

.summary-config-item h3 {
    margin: 0 0 9px;
    font-size: 15px;
}

.summary-config-item .summary-enabled {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 9px;
}

.summary-config-item .summary-enabled input {
    width: auto;
    margin: 0;
}

.summary-config-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
}

.summary-config-fields label {
    min-width: 0;
    margin-bottom: 0;
}

.summary-config-help {
    margin-top: 10px;
}

@media (max-width: 700px) {
    .summary-config {
        margin-top: 20px;
        padding-top: 14px;
    }

    .summary-config-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 8px;
    }

    .summary-config-item {
        padding: 10px;
    }

    .summary-config-fields {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .summary-config-fields label {
        margin-bottom: 10px;
    }

    .summary-config-fields label:last-child {
        margin-bottom: 0;
    }
}

.archive-list-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.archive-list-card-link {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.archive-list-card .toolbar {
    position: relative;
    z-index: 2;
    margin-top: auto;
    padding-top: 16px;
    padding-bottom: 0;
}

.archive-list-card {
    padding-bottom: 1px;
}

/* =========================================================
   NUMBER INPUTS (frueher inline in head.php, von der CSP blockiert)
   ========================================================= */

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Passwort-Auge: auf dem Handy ausreichend grosses Touch-Ziel (44 px) */
@media (max-width: 700px) {
    .password-field input {
        padding-right: 58px;
    }

    .password-toggle {
        right: 4px;
        width: 44px;
        min-width: 44px;
        height: 44px;
        min-height: 44px;
    }
}
