:root {
    color-scheme: light;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: #f6f8f7;
    color: #1e2422;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
}

button,
input,
select {
    font: inherit;
}

button,
input,
select {
    min-height: 44px;
}

.app {
    min-height: 100vh;
}

.topbar {
    background: #17352c;
    color: #ffffff;
    padding: 14px clamp(16px, 4vw, 40px);
}

.topbar__inner {
    max-width: 1600px;
    margin: 0 auto;
}

.topbar__content {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: clamp(1.45rem, 3vw, 2.3rem);
    line-height: 1;
    letter-spacing: 0;
}

.auth-status {
    display: grid;
    justify-items: end;
    gap: 8px;
    color: #d6e6df;
    font-size: 0.9rem;
    line-height: 1.35;
    min-width: 180px;
    text-align: right;
}

.auth-button {
    border: 0;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    height: 30px;
    padding: 0 10px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.auth-button:hover {
    background: rgba(255, 255, 255, 0.25);
}

.auth-user {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    align-items: center;
}

.auth-user span {
    color: #ffffff;
    font-weight: 700;
}

.auth-user__skeleton {
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.24);
    flex: 0 0 auto;
}

.auth-user__skeleton-name {
    width: 128px;
    height: 1.215rem;
}

.auth-user__skeleton-button {
    width: 52px;
    min-height: 44px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.sync-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.18);
    flex: 0 0 auto;
}

.sync-dot--synced {
    background: #4ade80;
}

.sync-dot--syncing {
    background: #facc15;
}

.sync-dot--error {
    background: #f87171;
}

.auth-meta {
    color: #b7cbc2;
    font-size: 0.82rem;
}

.auth-error {
    color: #ffd9d9;
}

main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 48px;
}

.layout {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.input-area {
    grid-column: 1;
    grid-row: 1;
}

.admin-area {
    grid-column: 1;
    grid-row: 2;
}

.content-stack {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.panel {
    background: #ffffff;
    border: 1px solid #dce4e0;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(20, 34, 30, 0.06);
}

.panel {
    padding: 18px;
}

.movement-panel {
    border-color: #a8c8bc;
    box-shadow: 0 10px 26px rgba(20, 34, 30, 0.1);
}

.section-title {
    font-size: 1rem;
    margin-bottom: 14px;
}

.movement-title {
    color: #17352c;
    font-size: 1.25rem;
}

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

label {
    display: grid;
    gap: 6px;
    color: #46524e;
    font-size: 0.9rem;
}

input,
select {
    width: 100%;
    border: 1px solid #bfcbc6;
    border-radius: 6px;
    padding: 10px 11px;
    color: #1e2422;
    background: #ffffff;
}

input:focus,
select:focus {
    outline: 2px solid #2f806c;
    outline-offset: 1px;
    border-color: #2f806c;
}

.amount-input {
    font-size: 1.25rem;
    font-weight: 400;
}

.description-field {
    color: #68756f;
    font-size: 0.84rem;
}

.description-field__input {
    min-height: 40px;
    border-color: #d4ddd9;
    color: #33413c;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.movement-type {
    display: flex;
    border: 1px solid #d4ddd9;
    border-radius: 6px;
    overflow: hidden;
}

.movement-type__label {
    display: flex;
    align-items: center;
    padding: 0 8px;
    color: #68756f;
    font-size: 0.84rem;
    background: #f8faf9;
    border-right: 1px solid #d4ddd9;
}

.movement-type__option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px;
    cursor: pointer;
    color: #46524e;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.movement-type__option input {
    display: none;
}

.movement-type__option--active {
    background: #eef5f2;
    font-weight: 700;
}

.movement-type__option:not(.movement-type__option--active):hover {
    background: #f3f8f6;
}

.conversion {
    background: #eef5f2;
    border-radius: 6px;
    padding: 12px;
    color: #29443c;
    line-height: 1.4;
}

.rate-status {
    border: 1px solid #d7e4df;
    border-radius: 6px;
    background: #f8faf9;
    color: #46524e;
    font-size: 0.9rem;
    line-height: 1.4;
    padding: 10px 12px;
}

.rate-status strong {
    color: #17352c;
    font-weight: 800;
}

.rate-status__meta {
    margin-top: 4px;
    color: #68756f;
}

.error {
    color: #9f2e2e;
    min-height: 1.3em;
}

.primary {
    border: 0;
    border-radius: 6px;
    background: #17352c;
    color: #ffffff;
    padding: 11px 14px;
    cursor: pointer;
    font-weight: 800;
}

.primary:hover {
    background: #0e2b23;
}

.primary--movement {
    min-height: 50px;
    width: 100%;
    font-size: 1rem;
}

.cancel-button {
    background: #ffffff;
    border: 1px solid #cfe0d9;
    border-radius: 8px;
    color: #2f3d38;
    cursor: pointer;
    font-size: 0.95rem;
    min-height: 44px;
    padding: 10px 18px;
    width: 100%;
}

.cancel-button:hover {
    background: #f5f8f7;
}

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

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

.admin-disclosure__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 14px 18px;
    color: #33413c;
    cursor: pointer;
    list-style-position: inside;
}

.admin-disclosure__summary strong {
    color: #17352c;
    font-size: 0.95rem;
}

.admin-disclosure__content {
    display: grid;
    gap: 18px;
    border-top: 1px solid #d7e4df;
    padding: 18px;
}

.admin-section {
    display: grid;
    gap: 12px;
}

.admin-section + .admin-section {
    border-top: 1px solid #e4ebe7;
    padding-top: 18px;
}

.ledger-panel {
    display: grid;
    gap: 12px;
}

.ledger-context {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

.ledger-context__title {
    margin-bottom: 4px;
}

.ledger-context__name {
    color: #17352c;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.accounts-disclosure,
.ledger-disclosure,
.members-disclosure {
    border: 1px solid #d7e4df;
    border-radius: 6px;
    background: #f8faf9;
}

.accounts-disclosure__summary,
.ledger-disclosure__summary,
.members-disclosure__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 9px 11px;
    color: #33413c;
    cursor: pointer;
    list-style-position: inside;
}

.accounts-disclosure__summary strong,
.ledger-disclosure__summary strong,
.members-disclosure__summary strong {
    color: #17352c;
    font-size: 0.84rem;
}

.accounts-disclosure__content,
.ledger-disclosure__content,
.members-disclosure__content {
    display: grid;
    gap: 12px;
    border-top: 1px solid #d7e4df;
    padding: 12px;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) auto;
    gap: 10px;
}

.member-list,
.account-list {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.member-list__item,
.account-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid #e0e8e4;
    border-radius: 6px;
    padding: 9px 10px;
}

.member-list__item div,
.account-list__item div {
    display: grid;
    gap: 2px;
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.member-role {
    color: #697771;
    font-size: 0.78rem;
    font-weight: 700;
}

.danger-button {
    border: 1px solid #d7a7a7;
    border-radius: 6px;
    background: #fff7f7;
    color: #8a2525;
    cursor: pointer;
    padding: 7px 9px;
}

.danger-button:hover {
    background: #ffecec;
}

.filters-toggle {
    display: contents;
}

.filters-toggle__input {
    display: none;
}

.filters-toggle__button {
    display: none;
}

.filters-toggle__content {
    display: contents;
}

@media (max-width: 820px) {
    .filters-toggle {
        display: block;
    }

    .filters-toggle__button {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 10px 14px;
        border: 1px solid #c8d4cf;
        border-radius: 6px;
        background: #ffffff;
        color: #33413c;
        cursor: pointer;
        font-size: 0.9rem;
        font-weight: 700;
    }

    .filters-toggle__button:hover {
        border-color: #2f806c;
    }

    .filters-toggle__arrow {
        transition: transform 0.2s;
        font-size: 0.75rem;
    }

    .filters-toggle__input:checked ~ .filters-toggle__button .filters-toggle__arrow {
        transform: rotate(180deg);
    }

    .filters-toggle__content {
        display: none;
        margin-top: 12px;
    }

    .filters-toggle__input:checked ~ .filters-toggle__content {
        display: block;
    }
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
}

.table-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.expense-table-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.segmented-control {
    display: flex;
    border: 1px solid #c8d4cf;
    border-radius: 6px;
    overflow: hidden;
}

.segmented-control__option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px;
    cursor: pointer;
    color: #46524e;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: background 0.15s;
    border-right: 1px solid #c8d4cf;
}

.segmented-control__option:last-child {
    border-right: 0;
}

.segmented-control__option input {
    display: none;
}

.segmented-control__option--active {
    background: #e7f2ee;
    font-weight: 700;
    color: #17352c;
}

.segmented-control__option:not(.segmented-control__option--active):hover {
    background: #f3f8f6;
}

.segmented-control__label {
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: #5e6b66;
    font-size: 0.84rem;
    font-weight: 700;
    background: #f8faf9;
    border-right: 1px solid #c8d4cf;
    white-space: nowrap;
}

.report-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
}

.report-options p {
    color: #5e6b66;
    font-size: 0.9rem;
    font-weight: 700;
}

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

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

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid #e4ebe7;
    text-align: left;
    vertical-align: top;
}

th {
    color: #4c5b55;
    font-size: 0.82rem;
    font-weight: 700;
}

@media (min-width: 521px) {
    .table-wrap {
        border: 1px solid #d4ddd9;
        border-radius: 6px;
    }

    .expense-table th,
    .expense-table td {
        border-right: 1px dotted #d4ddd9;
    }

    .expense-table th:last-child,
    .expense-table td:last-child {
        border-right: none;
    }
}

.sort-button {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    font-weight: inherit;
    line-height: inherit;
    padding: 0;
    text-align: inherit;
    white-space: nowrap;
}

.non-sort-button {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: default;
    font: inherit;
    font-weight: inherit;
    line-height: inherit;
    padding: 0;
    text-align: inherit;
    white-space: nowrap;
}

.sort-button:hover,
.sort-button--active {
    color: #17352c;
    text-decoration: underline;
    text-underline-offset: 3px;
}

td.action-cell {
    text-align: center;
    vertical-align: middle;
}

.action-buttons {
    display: inline-flex;
    border: 1px solid #c8d4cf;
    border-radius: 6px;
    overflow: hidden;
}

.action-buttons .edit-button,
.action-buttons .delete-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 3px 10px;
    min-width: 30px;
    min-height: 30px;
    transition: background 0.15s;
}

.action-buttons .edit-button {
    color: #2f806c;
    border-right: 1px solid #c8d4cf;
}

.action-buttons .delete-button {
    color: #b91c1c;
}

.action-buttons .edit-button:hover {
    background: #e7f2ee;
}

.action-buttons .delete-button:hover {
    background: #fde8e8;
}

td.numeric,
th.numeric {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

td:first-child,
th:first-child {
    white-space: nowrap;
}

.subtotal td {
    background: #f8faf9;
    color: #2f3d38;
    font-weight: 700;
}

.grand-total td {
    background: #eef5f2;
    border-top: 2px solid #2f806c;
    color: #17352c;
    font-weight: 800;
}

td.is-negative,
.subtotal td.is-negative,
.grand-total td.is-negative {
    color: #b91c1c;
}

.empty {
    color: #697771;
    padding: 22px 0;
}

.empty--compact {
    padding: 4px 0;
}

@media (min-width: 1080px) {
    .layout {
        grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
        gap: 22px;
    }

    .movement-panel {
        position: sticky;
        top: 24px;
    }

    .content-stack {
        align-content: start;
    }

    .content-stack > .panel:first-child {
        min-width: 0;
    }
}

@media (max-width: 820px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .input-area,
    .admin-area,
    .content-stack {
        grid-column: auto;
        grid-row: auto;
    }

    .admin-area {
        order: 99;
    }

    .content-stack {
        order: 2;
        gap: 14px;
    }
}

@media (max-width: 520px) {
    body {
        background: #ffffff;
    }

    .topbar {
        padding: 12px 16px;
    }

    .topbar__content {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }

    h1 {
        font-size: 1.55rem;
        line-height: 1;
    }

    .auth-status {
        justify-items: end;
        text-align: right;
        min-width: auto;
    }

    .sync-dot,
    .auth-user__name {
        display: none;
    }

    main {
        padding: 12px 0 32px;
    }

    .layout,
    .content-stack {
        gap: 10px;
    }

    .panel {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 16px;
    }

    .admin-panel {
        padding: 0;
    }

    .admin-disclosure__summary {
        padding: 14px 16px;
    }

    .admin-disclosure__content {
        padding: 16px;
    }

    .movement-panel {
        border-bottom: 1px solid #cfe0d9;
        box-shadow: none;
        padding-top: 18px;
    }

    .section-title {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .movement-title {
        font-size: 1.35rem;
    }

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

    .form-grid {
        gap: 12px;
    }

    .primary {
        width: 100%;
        min-height: 48px;
    }

    .table-controls {
        display: grid;
        gap: 12px;
        margin: 12px 0 0;
        order: 2;
    }

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

    .segmented-control__option {
        justify-content: center;
        padding: 8px 6px;
    }

    .report-options {
        display: grid;
        gap: 8px;
    }

    .table-wrap {
        overflow: visible;
        order: 1;
        border: none;
        border-radius: 0;
    }

    .empty {
        order: 1;
    }

    .expense-table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .expense-table thead {
        display: none;
    }

    .expense-table tr {
        display: grid;
        gap: 8px;
        border: 1px solid #dde7e2;
        border-radius: 8px;
        padding: 12px;
    }

    .expense-table td {
        display: grid;
        grid-template-columns: minmax(86px, 0.42fr) 1fr;
        gap: 12px;
        align-items: baseline;
        border: 0;
        padding: 0;
        text-align: left;
        white-space: normal;
    }

    .expense-table td::before {
        content: attr(data-label);
        color: #68756f;
        font-size: 0.78rem;
        font-weight: 800;
        text-transform: uppercase;
    }

    .expense-table td.numeric {
        text-align: left;
    }

    td.action-cell {
        display: flex;
        justify-content: center;
        padding: 8px 0 0;
        width: auto;
    }

    .expense-table .subtotal,
    .expense-table .grand-total {
        background: #f8faf9;
    }

    .expense-table .subtotal td,
    .expense-table .grand-total td {
        background: transparent;
    }
}
