:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #dfe7ef;
    --text: #1f2a37;
    --muted: #6b7280;
    --primary: #245b8f;
    --primary-dark: #1c456d;
    --accent: #2f8f83;
    --warning: #b7791f;
    --danger: #b42318;
    --shadow: 0 14px 34px rgba(31, 42, 55, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100%;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    background: var(--bg);
    font-family: "Prompt", system-ui, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

@supports (min-height: 100dvh) {
    html,
    body {
        min-height: 100dvh;
    }
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.page-fade {
    animation: fade-in 220ms ease-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
    background:
        linear-gradient(135deg, rgba(36, 91, 143, 0.12), rgba(47, 143, 131, 0.1)),
        var(--bg);
}

.auth-shell {
    width: min(100%, 430px);
}

.auth-page {
    display: grid;
    gap: 16px;
    width: min(100%, 430px);
}

.login-card,
.panel,
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-card {
    padding: 28px;
}

.login-brand {
    display: block;
    margin-bottom: 26px;
}

.stat-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
}

.login-brand h1,
.topbar h1,
.panel h2,
.empty-state h3 {
    margin: 0;
}

.login-brand p,
.panel-header p,
.muted,
.empty-state p,
.login-hint,
small {
    color: var(--muted);
}

.category-limit-hint {
    margin-top: 6px;
    font-size: 0.92rem;
    font-weight: 600;
    color: #dc3545;
}

.login-brand p,
.panel-header p,
.muted {
    margin: 4px 0 0;
}

.form-stack,
.expense-form {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 8px;
    color: #344054;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text);
    background: #fff;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(36, 91, 143, 0.12);
}

.primary-button,
.secondary-button,
.icon-button,
.danger-button,
.success-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease;
}

.primary-button {
    gap: 10px;
    padding: 0 18px;
    color: #fff;
    background: var(--primary);
    font-weight: 600;
}

.primary-button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.secondary-button {
    gap: 10px;
    padding: 0 16px;
    color: var(--primary);
    background: #eaf2f9;
    font-weight: 600;
}

.compact {
    min-height: 40px;
    padding-inline: 14px;
}

.login-hint {
    margin: 18px 0 0;
    font-size: 13px;
    text-align: center;
}

.app-shell {
    display: grid;
    width: 100%;
    min-height: 100vh;
    overflow-x: clip;
}

@supports (min-height: 100dvh) {
    .auth-body,
    .app-shell {
        min-height: 100dvh;
    }
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 48;
    background: rgba(15, 23, 42, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 49;
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: min(280px, 85vw);
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    background: #fff;
    border-right: 1px solid var(--line);
    box-shadow: 18px 0 40px rgba(31, 42, 55, 0.16);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    transition: transform 200ms ease;
}

body.drawer-open {
    overflow: hidden;
}

body.drawer-open .sidebar {
    transform: translateX(0);
}

body.drawer-open .drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.brand,
.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    font-size: 18px;
    font-weight: 700;
}

.brand {
    justify-content: space-between;
}

.brand-link span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.drawer-close {
    width: 40px;
}

.side-nav {
    display: grid;
    gap: 6px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 0 12px;
    color: var(--muted);
    border-radius: 8px;
    font-weight: 600;
}

.side-nav a.is-active,
.side-nav a:hover {
    color: var(--primary);
    background: #eaf2f9;
}

.main-area {
    min-width: 0;
    overflow-x: clip;
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: calc(18px + env(safe-area-inset-top)) 16px 18px;
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-title > div {
    min-width: 0;
}

.topbar-title h1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar h1 {
    font-size: 22px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.user-summary {
    display: grid;
    min-width: 0;
    max-width: 130px;
    text-align: right;
}

.user-summary strong,
.user-summary small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.icon-button {
    width: 40px;
    color: var(--muted);
    background: var(--surface-soft);
}

.content {
    display: grid;
    gap: 18px;
    min-width: 0;
    padding: 18px 16px;
}

.content > * {
    min-width: 0;
}

.app-footer {
    padding: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.7;
}

.auth-footer {
    padding-inline: 0;
}

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

.stat-card {
    padding: 16px;
}

.stat-card p {
    margin: 14px 0 4px;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: clamp(20px, 6vw, 24px);
    line-height: 1.2;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
}

.stat-icon.pending {
    color: var(--warning);
    background: #fff4de;
}

.stat-icon.approved,
.stat-icon.paid {
    color: var(--accent);
    background: #e8f7f4;
}

.stat-icon.total {
    color: var(--primary);
    background: #eaf2f9;
}

.panel {
    min-width: 0;
    padding: 18px;
}

.danger-panel {
    border-color: #fecdca;
    background: #fffafa;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.panel-header h2 {
    font-size: 18px;
}

.empty-state {
    display: grid;
    place-items: center;
    gap: 10px;
    padding: 34px 12px;
    color: var(--muted);
    text-align: center;
}

.empty-state i {
    color: var(--primary);
    font-size: 34px;
}

.empty-state h2,
.empty-state h3 {
    color: var(--text);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    background: var(--surface-soft);
    font-weight: 600;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    color: var(--primary);
    background: #eaf2f9;
    font-size: 13px;
}

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

.expense-form .full {
    grid-column: 1 / -1;
}

.bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    gap: 2px;
    padding: 8px 10px max(8px, env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 26px rgba(31, 42, 55, 0.08);
}

.bottom-nav a {
    display: grid;
    place-items: center;
    gap: 4px;
    min-height: 50px;
    color: var(--muted);
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.15;
}

.bottom-nav i {
    font-size: 17px;
}

.bottom-nav a.is-active {
    color: var(--primary);
    background: #eaf2f9;
}

@media (max-width: 767px) {
    .app-footer {
        padding-bottom: calc(88px + env(safe-area-inset-bottom));
    }

    .auth-footer {
        padding-bottom: 16px;
    }
}

label b {
    color: var(--danger);
}

.danger-button,
.success-button {
    gap: 10px;
    padding: 0 16px;
    color: #fff;
    font-weight: 600;
}

.danger-button {
    background: var(--danger);
}

.success-button {
    background: var(--accent);
}

button:disabled,
.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled,
.success-button:disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.form-actions,
.action-grid {
    display: grid;
    gap: 10px;
}

.filter-bar {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
    padding: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.filter-bar label {
    gap: 6px;
}

.filter-bar span {
    font-size: 13px;
}

.expense-filter > .secondary-button,
.admin-expense-filter > .secondary-button {
    width: 100%;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-line input {
    width: auto;
}

.admin-expense-filter > * {
    min-width: 0;
}

.admin-expense-filter {
    grid-template-columns: 1fr;
}

.admin-expense-filter label {
    min-width: 0;
}

.admin-expense-filter .filter-field {
    align-self: end;
}

.admin-expense-filter input,
.admin-expense-filter select {
    width: 100%;
    min-width: 0;
}

.admin-expense-filter .filter-field input:not([type="checkbox"]),
.admin-expense-filter .filter-field select {
    height: 48px;
}

.admin-expense-filter .filter-checkbox {
    display: flex;
    height: 48px;
    min-height: 48px;
    align-items: center;
    justify-content: flex-start;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    min-width: 0;
}

.admin-expense-filter .filter-checkbox input {
    flex: 0 0 auto;
    margin: 0;
}

.admin-expense-filter .filter-checkbox span {
    display: block;
    min-width: 0;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: normal;
    word-break: keep-all;
}

.admin-expense-filter .filter-actions {
    height: 48px;
    min-height: 48px;
}

.admin-expense-filter .admin-expense-filter-top,
.admin-expense-filter .admin-expense-filter-bottom,
.admin-expense-filter .admin-expense-filter-keyword,
.admin-expense-filter .admin-expense-filter-deleted-wrap,
.admin-expense-filter .admin-expense-filter-submit {
    min-width: 0;
}

.admin-expense-filter .admin-expense-filter-top {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
}

.admin-expense-filter .admin-expense-filter-bottom {
    display: grid;
    grid-template-columns: minmax(420px, 1fr) 260px 120px;
    gap: 12px;
    align-items: end;
    margin-top: 12px;
}

.admin-expense-filter .admin-expense-filter-keyword input {
    width: 100%;
}

.admin-expense-filter .admin-expense-filter-deleted-wrap {
    display: flex;
    align-items: end;
}

.admin-expense-filter .admin-expense-filter-deleted {
    width: 100%;
    min-width: 0;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    white-space: nowrap;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.admin-expense-filter .admin-expense-filter-deleted input {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
}

.admin-expense-filter .admin-expense-filter-deleted span {
    min-width: 0;
    line-height: 1.2;
    white-space: nowrap;
}

.admin-expense-filter .admin-expense-filter-submit {
    display: flex;
    align-items: end;
}

.admin-expense-filter .admin-expense-filter-submit .secondary-button {
    display: inline-flex;
    width: 100%;
    height: 46px;
    min-height: 46px;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
}

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

.claim-list {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
    color: var(--muted);
}

.claim-card {
    display: grid;
    gap: 14px;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.claim-card h3 {
    margin: 6px 0 4px;
    font-size: 16px;
}

.claim-card p,
.timeline-item p,
.detail-item p {
    margin: 0;
    color: var(--muted);
}

.claim-no {
    color: var(--primary);
    font-weight: 700;
}

.claim-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-claim-card {
    align-items: start;
}

.admin-claim-card > div:first-child {
    min-width: 0;
}

.admin-claim-card h3,
.admin-claim-card p {
    overflow-wrap: anywhere;
}

.admin-claim-meta {
    justify-content: flex-start;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.admin-claim-meta > strong {
    margin-right: auto;
    color: var(--text);
    font-size: 18px;
    line-height: 1.2;
}

.admin-claim-meta .inline-form {
    display: inline-flex;
}

.admin-claim-meta .secondary-button,
.admin-claim-meta .danger-button,
.admin-action-button {
    min-height: 36px;
    padding: 0 10px;
    gap: 6px;
    white-space: nowrap;
}

.sync-badge {
    min-height: 22px;
    padding: 0 8px;
    font-size: 12px;
}

@media (max-width: 767px) {
    .main-area {
        padding-bottom: calc(116px + env(safe-area-inset-bottom));
    }

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

    .attachment-preview-card {
        max-width: none;
    }

    .attachment-thumb {
        height: 160px;
        max-height: 160px;
    }

    .attachment-preview-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .attachment-modal {
        padding: 16px;
    }

    .attachment-modal-content {
        width: 92vw;
        max-height: 85vh;
        padding: 14px;
    }

    .admin-expense-filter {
        gap: 12px;
        padding: 12px;
    }

    .admin-expense-filter .admin-expense-filter-top,
    .admin-expense-filter .admin-expense-filter-bottom {
        grid-template-columns: 1fr;
        gap: 12px;
        width: 100%;
    }

    .admin-expense-filter .filter-field {
        width: 100%;
        align-self: stretch;
    }

    .admin-expense-filter .filter-field input:not([type="checkbox"]),
    .admin-expense-filter .filter-field select,
    .admin-expense-filter input[type="month"] {
        height: 48px;
        min-height: 48px;
        max-height: 48px;
        line-height: normal;
        padding-block: 0;
    }

    .admin-expense-filter input[type="month"] {
        display: block;
        -webkit-appearance: none;
        appearance: none;
        overflow: hidden;
        text-align: left;
    }

    .admin-expense-filter input[type="month"]::-webkit-date-and-time-value {
        min-height: 0;
        margin: 0;
        text-align: left;
    }

    .admin-expense-filter .admin-expense-filter-deleted {
        width: 100%;
        min-height: 46px;
        height: auto;
        padding: 12px 14px;
    }

    .admin-expense-filter .admin-expense-filter-deleted input {
        width: 20px;
        height: 20px;
        margin: 0;
    }

    .admin-expense-filter .admin-expense-filter-deleted span {
        flex: 1 1 auto;
        min-width: 0;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    .admin-expense-filter .admin-expense-filter-submit .secondary-button {
        display: inline-flex;
        width: 100%;
        height: 50px;
        min-height: 50px;
        justify-content: center;
        align-items: center;
    }

    .admin-claim-card {
        gap: 12px;
        padding: 16px;
    }

    .admin-claim-card > div:first-child {
        padding-bottom: 12px;
        border-bottom: 1px solid var(--line);
    }

    .admin-claim-meta {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        align-items: stretch;
        padding-top: 0;
        border-top: 0;
    }

    .admin-claim-meta > strong {
        grid-column: 1 / 2;
        justify-content: flex-start;
        margin: 0;
        font-size: 20px;
    }

    .admin-claim-meta .status-badge {
        justify-content: center;
        width: 100%;
        min-height: 38px;
    }

    .admin-claim-meta .inline-form,
    .admin-claim-meta .secondary-button,
    .admin-claim-meta .danger-button {
        width: 100%;
    }

    .admin-claim-meta .secondary-button,
    .admin-claim-meta .danger-button {
        justify-content: center;
        min-height: 44px;
    }

    .admin-claim-meta .danger-button {
        background: var(--danger);
    }
}

.status-draft {
    color: #475467;
    background: #eef2f6;
}

.status-pending {
    color: var(--warning);
    background: #fff4de;
}

.status-approved {
    color: var(--primary);
    background: #eaf2f9;
}

.status-revision {
    color: #8a4b05;
    background: #fff1d6;
}

.status-rejected,
.status-cancelled {
    color: var(--danger);
    background: #fee4e2;
}

.status-paid {
    color: var(--accent);
    background: #e8f7f4;
}

.sync-synced {
    color: #047857;
    background: #d1fae5;
}

.sync-failed {
    color: var(--danger);
    background: #fee4e2;
}

.sync-pending,
.sync-not_synced {
    color: #2563eb;
    background: #eff6ff;
}

.sync-skipped {
    color: var(--muted);
    background: #eef2f6;
}

.settings-note {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.settings-note h3 {
    margin: 0 0 10px;
}

.settings-note ol {
    margin: 0;
    padding-left: 22px;
}

.settings-note li + li {
    margin-top: 6px;
}

.settings-toggle {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.settings-menu-grid {
    display: grid;
    gap: 14px;
}

.settings-menu-card {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.settings-menu-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--primary);
    background: #eaf2f9;
}

.settings-menu-content h3 {
    margin: 0 0 4px;
}

.settings-menu-content p {
    margin: 0;
    color: var(--muted);
}

.settings-contact-badge {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    margin-top: 10px;
    padding: 0 12px;
    border-radius: 999px;
    color: var(--primary);
    background: #eaf2f9;
    font-weight: 600;
    font-size: 0.95rem;
}

.settings-actions {
    margin-top: 14px;
}

.settings-form > .form-actions {
    display: none;
}

.settings-action-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.settings-action-row .inline-form,
.settings-action-row .secondary-button,
.settings-action-row .primary-button {
    width: 100%;
}

.settings-action-row .inline-form button {
    width: 100%;
}

.settings-divider {
    height: 1px;
    margin: 22px 0;
    background: var(--line);
}

.settings-subheader {
    margin-bottom: 12px;
}

.category-rule-form {
    margin-top: 0;
}

.category-rule-list {
    display: grid;
    gap: 12px;
}

.category-rule-item {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.category-rule-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.category-rule-name strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.category-rule-name small {
    flex-basis: 100%;
    color: var(--muted);
}

.category-create-form {
    margin-bottom: 16px;
    align-items: start;
}

.category-create-form > label {
    min-width: 0;
}

.category-create-form > label:nth-of-type(4),
.category-create-form > label:nth-of-type(5) {
    align-self: start;
}

.category-create-form > label:nth-of-type(4) small {
    display: block;
    margin-top: 8px;
    line-height: 1.4;
}

.category-visibility-field,
.category-user-picker {
    min-width: 0;
}

.category-user-picker {
    display: grid;
    gap: 8px;
}

.category-user-picker > span {
    font-weight: 700;
    color: var(--text);
}

.category-user-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.category-user-option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    cursor: pointer;
}

.category-user-option input {
    width: auto;
    min-height: 0;
    margin: 0;
}

.category-user-option span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.category-manage-card {
    align-content: start;
}

.category-card-form {
    display: grid;
    gap: 12px;
}

.category-card-actions,
.category-card-secondary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.category-card-form > .category-card-actions {
    display: none;
}

.category-card-secondary-actions {
    margin-top: 12px;
}

.category-card-actions .inline-form,
.category-card-actions button {
    width: auto;
}

.detail-grid {
    display: grid;
    gap: 12px;
}

.detail-item {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.detail-item span {
    color: var(--muted);
    font-size: 13px;
}

.detail-item.full,
.admin-action-form .full {
    grid-column: 1 / -1;
}

.attachment-list,
.timeline {
    display: grid;
    gap: 10px;
}

.attachment-item,
.timeline-item {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.attachment-item {
    grid-template-columns: auto 1fr auto;
    align-items: center;
}

.attachment-item i {
    color: var(--primary);
}

.attachment-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 220px));
    justify-content: start;
    gap: 12px;
}

.attachment-preview-card {
    display: grid;
    gap: 10px;
    width: 100%;
    max-width: 240px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.attachment-thumb {
    width: 100%;
    height: 190px;
    max-height: 190px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    cursor: pointer;
}

.attachment-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 190px;
    object-fit: contain;
}

.attachment-preview-meta {
    display: grid;
    gap: 4px;
}

.attachment-preview-meta strong {
    overflow-wrap: anywhere;
}

.attachment-preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 24px;
}

.attachment-modal[hidden] {
    display: none;
}

.attachment-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
}

.attachment-modal-content {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 12px;
    width: min(960px, 92vw);
    max-height: 85vh;
    padding: 18px;
    border-radius: 12px;
    background: rgba(17, 24, 39, 0.96);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.38);
}

.attachment-modal-content img {
    display: block;
    width: auto;
    max-width: 92vw;
    max-height: 85vh;
    margin: 0 auto;
    border-radius: 8px;
    object-fit: contain;
}

.attachment-modal-caption {
    margin: 0;
    color: #f8fafc;
    text-align: center;
    overflow-wrap: anywhere;
}

.attachment-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    cursor: pointer;
}

.admin-action-form {
    display: grid;
    gap: 14px;
}

.compact-empty {
    padding: 18px 12px;
}

.report-grid {
    display: grid;
    gap: 18px;
}

.report-filter-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.report-filter-panel summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.report-filter-panel summary::-webkit-details-marker {
    display: none;
}

.report-filter-panel summary::after {
    content: "\f107";
    color: var(--primary);
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    transition: transform 0.18s ease;
}

.report-filter-panel[open] summary::after {
    transform: rotate(180deg);
}

.report-filter-panel summary span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.filter-toggle-text {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.report-filter-panel .filter-bar {
    margin: 0;
    border-width: 1px 0 0;
    border-radius: 0 0 8px 8px;
    background: #fff;
}

.mini-table {
    display: grid;
    gap: 10px;
}

.mini-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.mini-row small {
    grid-column: 1 / -1;
}

.filter-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 8px;
}

.filter-actions .secondary-button {
    width: 100%;
}

.report-export-button {
    grid-column: 1 / -1;
}

.report-table-wrap {
    display: none;
}

.report-card-list {
    display: grid;
    gap: 12px;
}

.report-claim-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.report-claim-head {
    display: grid;
    gap: 10px;
}

.report-claim-head h3 {
    margin: 4px 0 0;
    font-size: 16px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.claim-no {
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
}

.report-claim-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.report-claim-meta div {
    min-width: 0;
}

.report-claim-meta dt {
    margin-bottom: 2px;
    color: var(--muted);
    font-size: 12px;
}

.report-claim-meta dd {
    margin: 0;
    color: var(--text);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.report-claim-card .secondary-button {
    width: 100%;
}

@media (max-width: 379px) {
    .stats-grid,
    .report-claim-meta {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 1024px) {
    .app-shell {
        display: block;
        overflow-x: hidden;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        top: 0;
        display: flex;
        flex-direction: column;
        gap: 24px;
        width: 260px;
        min-width: 260px;
        max-width: 260px;
        height: 100vh;
        max-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        padding: 22px 16px;
        background: #fff;
        border-right: 1px solid var(--line);
        box-shadow: none;
        transform: none !important;
        transition: none;
        z-index: 30;
    }

    body.drawer-open {
        overflow: auto;
        overflow-x: hidden;
    }

    @supports (height: 100dvh) {
        .sidebar {
            height: 100dvh;
            max-height: 100dvh;
        }
    }

    .drawer-backdrop,
    .drawer-close,
    .menu-button {
        display: none;
    }

    .brand {
        justify-content: flex-start;
    }

    .main-area {
        width: calc(100% - 260px);
        min-width: 0;
        min-height: 100vh;
        margin-left: 260px;
        overflow-x: hidden;
        padding-bottom: 0;
    }

    @supports (min-height: 100dvh) {
        .main-area {
            min-height: 100dvh;
        }
    }

    .content {
        padding: 24px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .user-summary {
        display: grid;
        max-width: 180px;
    }

    .user-summary small {
        display: block;
    }

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

    .category-create-form {
        column-gap: 18px;
        row-gap: 12px;
    }

    .category-create-form > label:nth-of-type(4) {
        grid-column: 1;
    }

    .category-create-form > label:nth-of-type(5) {
        grid-column: 2;
        grid-row: 4;
    }

    .form-actions,
    .action-grid {
        display: flex;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .settings-action-row .inline-form,
    .settings-action-row .inline-form button,
    .settings-action-row .secondary-button,
    .settings-action-row .primary-button {
        width: auto;
    }

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

    .settings-menu-card {
        grid-template-columns: 48px minmax(0, 1fr) auto;
        align-items: center;
    }

    .category-rule-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .category-card-actions .inline-form,
    .category-card-actions button {
        width: auto;
    }

    .filter-bar {
        gap: 14px;
        align-items: end;
    }

    .expense-filter {
        grid-template-columns: 180px 190px 140px minmax(240px, 1fr) 104px;
    }

    .expense-filter > .secondary-button {
        width: 100%;
        align-self: end;
        white-space: nowrap;
    }

    .admin-expense-filter {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .admin-expense-filter .admin-expense-filter-top {
        grid-template-columns: repeat(4, minmax(180px, 1fr));
    }

    .admin-expense-filter .admin-expense-filter-bottom {
        grid-template-columns: minmax(420px, 1fr) 260px 120px;
    }

    .users-filter {
        grid-template-columns: 160px minmax(220px, 1fr) auto;
    }

    .reports-filter {
        grid-template-columns: 140px 120px 180px 180px 160px 140px minmax(220px, 1fr) auto;
        align-items: end;
    }

    .filter-actions {
        display: flex;
        flex-wrap: nowrap;
    }

    .filter-actions .secondary-button {
        width: auto;
    }

    .report-export-button {
        grid-column: auto;
    }

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

    .report-table-wrap {
        display: block;
    }

    .report-card-list {
        display: none;
    }

    .claim-card {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .claim-meta {
        justify-content: flex-end;
    }

    .admin-claim-card {
        grid-template-columns: minmax(0, 1fr) minmax(280px, auto);
        align-items: center;
    }

    .admin-claim-meta {
        justify-content: flex-end;
        padding-top: 0;
        border-top: 0;
    }

    .admin-claim-meta > strong {
        width: 100%;
        margin-right: 0;
        text-align: right;
    }

    .detail-grid,
    .admin-action-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .bottom-nav {
        display: none;
    }
}

@media (min-width: 1024px) and (max-width: 1320px) {
    .admin-expense-filter {
        grid-template-columns: 1fr;
    }

    .admin-expense-filter .admin-expense-filter-top {
        grid-template-columns: repeat(4, minmax(160px, 1fr));
    }

    .admin-expense-filter .admin-expense-filter-bottom {
        grid-template-columns: minmax(260px, 1fr) 260px 120px;
    }
}
