:root {
    color-scheme: light;
    --page: #f6f7f9;
    --surface: #ffffff;
    --surface-subtle: #f9fafb;
    --text: #111827;
    --text-muted: #4b5563;
    --text-soft: #6b7280;
    --border: #d8dde3;
    --border-soft: #e5e7eb;
    --primary: #111827;
    --primary-hover: #000000;
    --primary-text: #ffffff;
    --danger: #991b1b;
    --danger-bg: #fef2f2;
    --danger-strong: #991b1b;
    --danger-strong-hover: #7f1d1d;
    --danger-strong-text: #ffffff;
    --success: #166534;
    --success-bg: #f0fdf4;
    --warning: #92400e;
    --warning-bg: #fffbeb;
    --shadow: none;
    --sidebar-bg: rgba(255, 255, 255, 0.94);
    --overlay-bg: rgba(17, 24, 39, 0.6);
    --overlay-bg-soft: rgba(17, 24, 39, 0.48);
    --focus-ring: rgba(17, 24, 39, 0.08);
    --status-neutral-bg: #f3f4f6;
    --status-neutral-text: #1f2937;
    --radius: 8px;
}

html[data-theme="dark"],
:root.app-dark {
    color-scheme: dark;
    --wh-bg: #111418;
    --wh-bg-subtle: #181c21;
    --wh-surface: #1d2127;
    --wh-surface-raised: #23282f;
    --wh-primary: #42c987;
    --page: var(--wh-bg);
    --surface: var(--wh-surface);
    --surface-subtle: var(--wh-surface-raised);
    --text: #f3f4f6;
    --text-muted: #cbd5e1;
    --text-soft: #94a3b8;
    --border: #3a424d;
    --border-soft: #2c333c;
    --primary: var(--wh-primary);
    --primary-hover: #35b978;
    --primary-text: #111418;
    --danger: #fca5a5;
    --danger-bg: #451a1a;
    --danger-strong: #b91c1c;
    --danger-strong-hover: #991b1b;
    --danger-strong-text: #ffffff;
    --success: #86efac;
    --success-bg: #143821;
    --warning: #fcd34d;
    --warning-bg: #3a2b0f;
    --shadow: none;
    --sidebar-bg: rgba(29, 33, 39, 0.94);
    --overlay-bg: rgba(0, 0, 0, 0.66);
    --overlay-bg-soft: rgba(0, 0, 0, 0.52);
    --focus-ring: rgba(66, 201, 135, 0.18);
    --status-neutral-bg: var(--wh-surface-raised);
    --status-neutral-text: #e5e7eb;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    overflow-x: hidden;
}

a {
    color: var(--text);
    font-weight: 650;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select {
    font: inherit;
}

img,
svg {
    max-width: 100%;
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 32px 16px;
}

.auth-panel {
    position: relative;
    width: min(100%, 430px);
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-panel-wide {
    width: min(100%, 520px);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    color: var(--text);
    font-weight: 750;
}

.brand-symbol {
    display: inline-grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-subtle);
    color: var(--text);
    font-size: 14px;
}

.page-title {
    margin: 0;
    color: var(--text);
    font-size: 26px;
    font-weight: 760;
    letter-spacing: 0;
}

.page-subtitle {
    margin: 6px 0 24px;
    color: var(--text-muted);
    font-size: 14px;
}

.field-group {
    margin-top: 16px;
}

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

.field-label {
    display: block;
    margin-bottom: 7px;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.field-input {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.readonly-field {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    background: var(--surface-subtle);
}

.password-field {
    position: relative;
}

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

.password-toggle {
    position: absolute;
    inset: 4px 4px 4px auto;
    display: inline-grid;
    width: 36px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
}

.password-toggle:hover {
    background: var(--surface-subtle);
    color: var(--text);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 7px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 720;
    text-decoration: none;
}

.btn-primary {
    width: 100%;
    margin-top: 22px;
    background: var(--primary);
    color: var(--primary-text);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--surface-subtle);
    text-decoration: none;
}

.message {
    padding: 11px 12px;
    border-radius: 7px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: 14px;
}

.message-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger-bg);
}

.message-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: var(--success-bg);
}

.field-error {
    display: block;
    margin-top: 5px;
    color: var(--danger);
    font-size: 13px;
}

.auth-footer {
    margin: 18px 0 0;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

.app-shell {
    min-height: 100vh;
    padding-left: 76px;
    transition: padding-left 0.2s ease;
}

body.sidebar-open .app-shell {
    padding-left: 280px;
}

.app-header {
    position: relative;
    z-index: 30;
}

.app-mobilebar {
    display: none;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    width: 76px;
    height: 100vh;
    flex-direction: column;
    gap: 20px;
    overflow-x: hidden;
    overflow-y: hidden;
    padding: 14px 12px 78px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-soft);
    box-shadow: none;
    backdrop-filter: blur(12px);
    transition: width 0.2s ease, transform 0.2s ease;
    z-index: 50;
}

body.sidebar-open .app-sidebar {
    width: 280px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--text);
    font-weight: 760;
}

.app-brand:hover {
    text-decoration: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 40px;
    flex-shrink: 0;
}

.sidebar-text {
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.12s ease;
}

body.sidebar-open .sidebar-text {
    opacity: 1;
}

body:not(.sidebar-open) .sidebar-text {
    display: none;
}

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 3px;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.sidebar-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.sidebar-toggle-inside {
    margin-left: auto;
}

body:not(.sidebar-open) .sidebar-header {
    justify-content: center;
}

body:not(.sidebar-open) .sidebar-toggle-inside {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    margin-inline: auto;
}

body:not(.sidebar-open) .sidebar-header .app-brand {
    display: none;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.app-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 11px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.app-nav a:hover {
    background: var(--surface-subtle);
    color: var(--text);
    text-decoration: none;
}

.app-nav a.active {
    background: var(--surface-subtle);
    color: var(--primary);
    box-shadow: inset 3px 0 0 var(--primary);
}

body:not(.sidebar-open) .app-nav a {
    justify-content: center;
    width: 42px;
    min-height: 42px;
    overflow: hidden;
    padding: 0;
}

body:not(.sidebar-open) .app-nav {
    align-items: center;
    gap: 10px;
}

body:not(.sidebar-open) .app-nav a.active {
    box-shadow: inset 0 -3px 0 var(--primary);
}

.nav-icon {
    display: inline-grid;
    width: 20px;
    min-width: 20px;
    height: 20px;
    place-items: center;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
}

.app-actions {
    display: grid;
    gap: 12px;
    min-height: 0;
    margin-top: 4px;
    overflow-y: auto;
    padding-top: 18px;
    border-top: 1px solid var(--border-soft);
}

.sidebar-section-title {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 760;
    text-transform: uppercase;
}

.navbar-subdomain {
    display: grid;
    gap: 7px;
}

.navbar-subdomain .field-label {
    margin-bottom: 0;
    white-space: nowrap;
}

.navbar-subdomain .field-input {
    width: 100%;
    min-width: 0;
    min-height: 38px;
}

body:not(.sidebar-open) .navbar-subdomain,
body:not(.sidebar-open) .sidebar-section-title {
    display: none;
}

body:not(.sidebar-open) .app-actions {
    justify-items: center;
    padding-top: 14px;
}

.sidebar-logout {
    position: absolute;
    right: 12px;
    bottom: 14px;
    left: 12px;
    margin-top: 0;
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
    flex-shrink: 0;
    background: var(--sidebar-bg);
}

.sidebar-logout .btn {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 11px;
    overflow: hidden;
}

body:not(.sidebar-open) .sidebar-logout .btn {
    width: 42px;
    min-height: 42px;
    margin-inline: auto;
    justify-content: center;
    overflow: hidden;
    padding: 0;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 42px;
    padding: 0 11px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 720;
}

.theme-toggle:hover {
    background: var(--surface-subtle);
}

.theme-toggle-icon {
    display: inline-grid;
    width: 20px;
    min-width: 20px;
    place-items: center;
    font-size: 14px;
    line-height: 1;
}

body:not(.sidebar-open) .theme-toggle {
    justify-content: center;
    width: 42px;
    min-height: 42px;
    margin-inline: auto;
    overflow: hidden;
    padding: 0;
}

.auth-theme-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20;
    width: 38px;
    min-height: 38px;
    padding: 0;
    box-shadow: var(--shadow);
}

.auth-theme-toggle .sidebar-text {
    display: none;
}

.sidebar-overlay {
    display: none;
}

.app-main {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 34px 24px;
}

.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-top: 34px;
}

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

.dashboard-charts-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 18px;
}

.chart-panel {
    min-height: 300px;
}

.chart-header {
    margin-bottom: 22px;
}

.chart-bars {
    display: grid;
    gap: 18px;
}

.chart-bar-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 720;
}

.chart-bar-label strong {
    color: var(--text-muted);
    font-size: 13px;
}

.chart-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-subtle);
    border: 1px solid var(--border-soft);
}

.chart-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
}

.chart-fill-success {
    background: var(--success);
}

.chart-fill-warning {
    background: var(--warning);
}

.chart-fill-danger {
    background: var(--danger-strong);
}

.finance-chart {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: end;
    min-height: 220px;
}

.finance-column {
    display: grid;
    gap: 8px;
    justify-items: center;
    min-width: 0;
}

.finance-bar {
    position: relative;
    width: min(100%, 74px);
    height: 150px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: var(--surface-subtle);
}

.finance-bar-fill {
    position: absolute;
    inset: auto 0 0;
}

.finance-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 720;
}

.finance-column strong {
    max-width: 100%;
    color: var(--text);
    font-size: 14px;
    text-align: center;
    overflow-wrap: anywhere;
}

.chart-empty {
    display: grid;
    min-height: 210px;
    place-items: center;
    padding: 18px;
    color: var(--text-muted);
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface-subtle);
}

.metric-card,
.content-panel {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}

.metric-card {
    padding: 18px;
}

.metric-label {
    margin: 0 0 10px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 700;
}

.metric-value {
    margin: 0;
    color: var(--text);
    font-size: 24px;
    font-weight: 780;
}

.content-panel {
    margin-top: 18px;
    padding: 22px;
}

.panel-title {
    margin: 0 0 6px;
    font-size: 18px;
}

.panel-text {
    margin: 0;
    color: var(--text-muted);
}

.invitation-check-button {
    position: relative;
    gap: 8px;
}

.invitation-button-icon {
    display: inline-grid;
    width: 18px;
    height: 18px;
    place-items: center;
}

.invitation-count {
    display: inline-grid;
    min-width: 20px;
    height: 20px;
    place-items: center;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--danger-strong);
    color: var(--danger-strong-text);
    font-size: 12px;
    font-weight: 780;
    line-height: 1;
}

.invitation-count[hidden] {
    display: none;
}

.invitation-panel {
    padding: 0;
    overflow: hidden;
}

.invitation-toolbar {
    border-bottom: 1px solid var(--border-soft);
}

.invitation-list {
    display: grid;
    gap: 0;
}

.invitation-item {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(160px, 0.7fr) minmax(180px, 0.6fr);
    gap: 14px;
    align-items: center;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-soft);
}

.invitation-item:last-child {
    border-bottom: 0;
}

.invitation-item .status-badge {
    justify-self: end;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.invitation-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.invitation-actions form {
    margin: 0;
}

.expense-form-panel {
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
}

.form-section + .form-section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-soft);
}

.checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-top: 12px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.checkbox-field input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
}

.btn-primary-inline {
    width: auto;
    margin-top: 0;
}

.list-panel {
    padding: 0;
    overflow: hidden;
}

.list-message {
    margin: 22px 22px 0;
}

.list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px;
    border-bottom: 1px solid var(--border-soft);
}

.list-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

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

.sort-form .field-label {
    margin-bottom: 0;
    white-space: nowrap;
}

.sort-select {
    width: auto;
    min-width: 180px;
    min-height: 38px;
    cursor: pointer;
}

.btn-sm {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
    gap: 6px;
}

.btn-icon {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 8px;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

.btn-icon-primary {
    background: var(--surface);
    color: var(--primary);
    border-color: var(--border);
}

.btn-icon-primary:hover {
    background: var(--surface-subtle);
    border-color: var(--primary);
    text-decoration: none;
}

.btn-icon-danger {
    background: var(--surface);
    color: var(--danger-strong);
    border-color: var(--border);
}

.btn-icon-danger:hover {
    background: var(--danger-bg);
    border-color: var(--danger-strong);
    text-decoration: none;
}

.btn-mark-paid {
    background: var(--surface);
    color: var(--success);
    border-color: var(--border);
    min-width: 74px;
    white-space: nowrap;
    overflow-wrap: normal;
}

.btn-mark-paid:hover {
    background: var(--success-bg);
    border-color: var(--success);
    text-decoration: none;
}

.btn-mark-paid svg {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
}

.btn-repeat-selected {
    min-height: 38px;
    padding: 0 12px;
    margin-top: 0;
}

.btn-danger {
    background: var(--danger-strong);
    color: var(--danger-strong-text);
    border-color: var(--danger-strong);
}

.btn-danger:hover {
    background: var(--danger-strong-hover);
    text-decoration: none;
}

.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.table-actions form {
    display: inline-flex;
}

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

.data-table {
    width: 100%;
    min-width: 1000px;
    border-collapse: collapse;
}

.subdomain-table {
    min-width: 620px;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.data-table th {
    color: var(--text-soft);
    background: var(--surface-subtle);
    font-size: 12px;
    font-weight: 760;
}

.data-table tbody tr:hover {
    background: var(--surface-subtle);
}

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

.table-title,
.table-meta {
    display: block;
}

.table-title {
    color: var(--text);
    font-weight: 740;
}

.table-meta {
    margin-top: 2px;
    color: var(--text-soft);
    font-size: 13px;
}

.amount-column {
    text-align: right;
    font-weight: 740;
}

.expense-mobile-summary {
    display: block;
}

.expense-details-button {
    display: none;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--status-neutral-bg);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 760;
}

.status-paid {
    background: var(--success-bg);
    color: var(--success);
}

.status-pending {
    background: var(--status-neutral-bg);
    color: var(--status-neutral-text);
}

.status-overdue {
    background: var(--danger-bg);
    color: var(--danger);
}

.status-canceled {
    background: var(--status-neutral-bg);
    color: var(--text-soft);
}

.subdomain-photo {
    width: 56px;
    height: 56px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface-subtle);
}

.image-source-group {
    gap: 10px;
}

.image-source-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 760;
    text-transform: uppercase;
}

.image-source-divider::before,
.image-source-divider::after {
    content: "";
    height: 1px;
    background: var(--border-soft);
}

.file-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 10px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface-subtle);
    color: var(--text);
    cursor: pointer;
}

.file-picker:hover {
    border-color: var(--text);
    background: var(--surface);
}

.file-picker-icon {
    display: inline-grid;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 18px;
    font-weight: 760;
}

.file-picker strong,
.file-picker small {
    display: block;
}

.file-picker strong {
    font-size: 14px;
}

.file-picker small {
    color: var(--text-soft);
    font-size: 12px;
}

.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.field-input:disabled,
.file-picker.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.image-preview {
    display: grid;
    min-height: 180px;
    place-items: center;
    margin-top: 12px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: var(--surface-subtle);
}

.image-preview img {
    width: 100%;
    max-height: 260px;
    object-fit: contain;
}

.image-preview-empty {
    color: var(--text-soft);
    font-size: 14px;
}

.empty-state {
    padding: 46px 22px;
    text-align: center;
}

.empty-state h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

.empty-state p {
    margin: 0 auto 18px;
    max-width: 420px;
    color: var(--text-muted);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    z-index: 1000;
}

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

.modal-container {
    width: min(100%, 420px);
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.modal-title {
    margin: 0;
    color: var(--text);
    font-size: 18px;
}

.modal-text {
    margin: 12px 0 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    min-height: 38px;
}

.modal-actions .btn-primary {
    width: auto;
    margin-top: 0;
}

.expense-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.expense-detail-header .modal-text {
    margin-bottom: 0;
}

.expense-detail-list {
    display: grid;
    grid-template-columns: minmax(96px, 0.45fr) minmax(0, 1fr);
    gap: 12px 16px;
    margin: 22px 0 0;
}

.expense-detail-list dt {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 760;
}

.expense-detail-list dd {
    margin: 0;
    color: var(--text);
    font-weight: 700;
    overflow-wrap: anywhere;
}

@media (max-width: 760px) {
    body {
        font-size: 14px;
    }

    .auth-page {
        align-items: start;
        padding: 18px 12px;
    }

    .auth-panel,
    .auth-panel-wide {
        padding: 22px 18px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .app-shell,
    body.sidebar-open .app-shell {
        padding-left: 0;
        padding-top: 64px;
    }

    .app-mobilebar {
        position: fixed;
        inset: 0 0 auto 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 64px;
        padding: 10px 12px;
        background: var(--sidebar-bg);
        border-bottom: 1px solid var(--border-soft);
        backdrop-filter: blur(12px);
        z-index: 45;
    }

    .app-mobile-brand {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        font-weight: 760;
    }

    .app-mobile-brand:hover {
        text-decoration: none;
    }

    .app-sidebar {
        width: min(86vw, 300px);
        transform: translateX(-102%);
        padding: 14px 14px 78px;
        box-shadow: var(--shadow);
    }

    body.sidebar-open .app-sidebar {
        width: min(86vw, 300px);
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        display: block;
        visibility: hidden;
        opacity: 0;
        border: 0;
        background: var(--overlay-bg-soft);
        backdrop-filter: blur(2px);
        transition: opacity 0.18s ease, visibility 0.18s ease;
        z-index: 35;
    }

    body.sidebar-open .sidebar-overlay {
        visibility: visible;
        opacity: 1;
    }

    .sidebar-text,
    body.sidebar-open .sidebar-text {
        opacity: 1;
    }

    body:not(.sidebar-open) .navbar-subdomain,
    body:not(.sidebar-open) .sidebar-section-title {
        display: grid;
    }

    body:not(.sidebar-open) .sidebar-section-title {
        display: block;
    }

    .sidebar-toggle-inside {
        display: inline-flex;
    }

    .app-brand {
        width: 100%;
        justify-content: space-between;
    }

    .app-nav {
        width: 100%;
    }

    .app-actions {
        width: 100%;
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .navbar-subdomain {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .navbar-subdomain .field-input {
        min-width: 0;
        width: 100%;
    }

    .app-actions form,
    .app-actions .btn {
        width: 100%;
    }

    .app-main {
        padding: 22px 12px;
    }

    .page-title {
        font-size: 23px;
    }

    .content-panel {
        margin-top: 14px;
        padding: 18px;
    }

    .dashboard-header {
        display: block;
        margin-bottom: 18px;
    }

    .dashboard-header form {
        margin-top: 16px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        margin-top: 24px;
    }

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

    .dashboard-charts-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-header .btn {
        width: 100%;
        margin-top: 16px;
    }

    .metric-card {
        padding: 16px;
    }

    .metric-value {
        font-size: 22px;
        overflow-wrap: anywhere;
    }

    .invitation-item {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 14px 18px;
    }

    .invitation-item .status-badge {
        justify-self: start;
    }

    .invitation-actions {
        display: flex;
        justify-content: flex-start;
    }

    .invitation-actions .btn-icon {
        width: 34px;
    }

    .list-panel {
        padding: 0;
    }

    .list-toolbar {
        align-items: stretch;
        flex-direction: column;
        padding: 18px;
    }

    .list-toolbar-actions {
        align-items: stretch;
        display: grid;
        grid-template-columns: 1fr;
        justify-content: stretch;
    }

    .sort-form {
        display: grid;
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .sort-form .field-label {
        margin-top: 4px;
    }

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

    .table-wrapper {
        overflow: visible;
    }

    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table th,
    .data-table td,
    .data-table tr {
        display: block;
    }

    .data-table {
        min-width: 0;
    }

    .data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .data-table tbody {
        display: grid;
        gap: 12px;
        padding: 12px;
        background: var(--page);
    }

    .data-table tbody tr {
        overflow: hidden;
        border: 1px solid var(--border-soft);
        border-radius: var(--radius);
        background: var(--surface);
    }

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

    .data-table td {
        display: grid;
        grid-template-columns: minmax(92px, 36%) minmax(0, 1fr);
        gap: 12px;
        align-items: center;
        padding: 11px 14px;
        border-bottom: 1px solid var(--border-soft);
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--text-soft);
        font-size: 12px;
        font-weight: 760;
    }

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

    .expense-table tbody {
        gap: 10px;
        padding: 10px;
    }

    .expense-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px 12px;
        padding: 14px;
    }

    .expense-table td {
        display: none;
        padding: 0;
        border-bottom: 0;
    }

    .expense-table td::before {
        display: none;
    }

    .expense-table td[data-label="Selecionar"] {
        display: flex;
        align-items: center;
        grid-column: 2;
        grid-row: 1;
        justify-content: flex-end;
    }

    .expense-table td[data-label="Despesa"] {
        display: block;
        grid-column: 1;
        grid-row: 1;
    }

    .expense-table td[data-label="Status"] {
        display: block;
        grid-column: 1;
        grid-row: 2;
    }

    .expense-table td[data-label="Valor"] {
        display: block;
        grid-column: 2;
        grid-row: 2;
        align-self: center;
        text-align: right;
        white-space: nowrap;
    }

    .expense-table td[data-label="Ações"] {
        display: block;
        grid-column: 1 / -1;
        grid-row: 3;
        padding-top: 2px;
    }

    .expense-mobile-summary {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 10px;
    }

    .expense-details-button {
        display: inline-flex;
        flex: 0 0 34px;
    }

    .expense-detail-modal {
        align-items: flex-end;
        padding: 0;
    }

    .expense-detail-modal .modal-container {
        width: 100%;
        max-height: 82vh;
        overflow-y: auto;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 14px 14px 0 0;
        padding: 20px;
    }

    .amount-column {
        text-align: left;
    }

    .table-actions {
        justify-content: flex-start;
    }

    .subdomain-photo {
        width: 48px;
        height: 48px;
    }

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

    .form-actions .btn {
        width: 100%;
    }

    .image-preview {
        min-height: 150px;
    }

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

    .modal-actions .btn,
    .modal-actions .btn-primary {
        width: 100%;
    }
}

@media (min-width: 761px) and (max-width: 1180px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 420px) {
    .navbar-subdomain {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .data-table td {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}
