:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --text: #142033;
    --muted: #6e7786;
    --line: rgba(20, 32, 51, 0.12);
    --card: #ffffff;
    --accent: #2f7df6;
    --danger: #c83d3d;
    --shadow: 0 16px 45px rgba(28, 40, 60, 0.12);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

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

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

button {
    cursor: pointer;
}

.app-shell {
    width: min(100%, 520px);
    min-height: 100vh;
    margin: 0 auto;
    padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 22px);
}

.top-bar,
.trip-top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: 48px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 0 10px;
    background: rgba(244, 246, 248, 0.92);
    backdrop-filter: blur(18px);
}

.top-bar h1,
.trip-top h1 {
    margin: 0;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    font-weight: 800;
}

.top-actions {
    display: flex;
    gap: 8px;
}

.icon-button {
    display: inline-grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: var(--card);
    color: var(--text);
    box-shadow: 0 5px 18px rgba(28, 40, 60, 0.08);
    font-weight: 800;
}

.icon-button.small {
    width: 34px;
    height: 34px;
    font-size: 16px;
}

.trip-list,
.day-stack,
.overview-section,
.currency-tool {
    display: grid;
    gap: 12px;
}

.day-stack {
    gap: 3px;
}

.trip-row {
    display: grid;
    grid-template-columns: 58px 1fr 18px;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 18px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.trip-row-body {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.trip-row-body strong,
.trip-row-body span,
.trip-row-body em {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trip-row-body strong {
    font-size: 16px;
}

.trip-row-body span,
.trip-row-body em,
.subtle {
    color: var(--muted);
    font-size: 13px;
    font-style: normal;
}

.chevron {
    color: var(--muted);
    font-size: 24px;
}

.image-circle {
    display: inline-grid;
    width: 48px;
    height: 48px;
    flex: 0 0 auto;
    place-items: center;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.52);
    color: rgba(20, 32, 51, 0.36);
    font-size: 22px;
    font-weight: 700;
}

.image-circle.large {
    width: 64px;
    height: 64px;
}

.image-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.trip-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0 12px;
}

.trip-profile div {
    display: grid;
    gap: 6px;
}

.badge {
    width: fit-content;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(47, 125, 246, 0.1);
    color: #1c62d1;
    font-size: 12px;
    font-weight: 700;
}

.tab-bar {
    position: sticky;
    top: 58px;
    z-index: 19;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    padding: 8px 0 10px;
    background: rgba(244, 246, 248, 0.94);
    backdrop-filter: blur(18px);
}

.tab-bar a {
    display: grid;
    min-width: 0;
    height: 38px;
    place-items: center;
    border-radius: 999px;
    color: var(--muted);
    font-size: 18px;
    font-weight: 800;
}

.tab-bar a.active {
    background: var(--text);
    color: #fff;
}

.tab-content {
    padding-top: 6px;
}

.timeline-strip {
    position: sticky;
    top: 114px;
    z-index: 18;
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 6px 0 10px;
    background: rgba(244, 246, 248, 0.94);
    backdrop-filter: blur(18px);
    scrollbar-width: none;
}

.timeline-strip::-webkit-scrollbar {
    display: none;
}

.timeline-strip a {
    position: relative;
    display: grid;
    min-width: 82px;
    height: 42px;
    place-items: center;
    overflow: hidden;
    border-radius: 14px;
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
}

.ghost-icon {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    opacity: 0.16;
    font-size: 27px;
}

.day-card {
    scroll-margin-top: 178px;
    overflow: hidden;
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.day-card-head {
    display: grid;
    grid-template-columns: 1fr 48px auto;
    align-items: center;
    gap: 10px;
    padding: 12px;
}

.day-card-head strong,
.day-card-head span {
    display: block;
}

.day-card-head strong {
    font-size: 14px;
}

.day-card-head span {
    color: rgba(20, 32, 51, 0.72);
    font-size: 13px;
    font-weight: 650;
}

.day-actions {
    display: flex;
    gap: 7px;
}

.day-body {
    display: grid;
    gap: 9px;
    padding: 0 12px 12px;
}

.day-card.collapsed .day-body {
    display: none;
}

.info-block,
.mini-row,
.overview-card,
.info-pill,
.empty-state,
.folder-card,
.document-row {
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.72);
}

.info-block {
    display: grid;
    gap: 3px;
    padding: 10px;
}

.info-block-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    align-items: center;
    gap: 8px;
}

.info-block-head strong {
    min-width: 0;
}

.info-block span,
.mini-row span,
.overview-card span {
    color: var(--muted);
    font-size: 13px;
}

.mini-row {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) max-content;
    gap: 8px;
    align-items: center;
    padding: 10px;
}

.mini-row div {
    display: grid;
    gap: 2px;
}

.mini-row > div:not(.compact-actions) {
    min-width: 0;
}

.mini-row a,
.info-block a {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
}

.mini-thumb {
    display: inline-grid;
    width: 28px;
    height: 28px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.54);
}

.mini-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mini-icon {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 999px;
    background: rgba(20, 32, 51, 0.08);
}

.tiny-button {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(20, 32, 51, 0.08);
    color: var(--muted);
}

.icon-action-row {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    padding-top: 2px;
}

.icon-action-row button {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
}

.touch-tooltip {
    position: fixed;
    z-index: 6500;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(20, 32, 51, 0.92);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.section-title h2,
.overview-section h2 {
    margin: 0;
    font-size: 18px;
}

.country-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.info-pill {
    display: grid;
    min-height: 74px;
    align-content: center;
    gap: 4px;
    padding: 10px;
    text-align: center;
}

.info-pill strong {
    overflow-wrap: anywhere;
    font-size: 13px;
}

.info-pill span {
    color: var(--muted);
    font-size: 11px;
}

.map-card {
    position: relative;
    z-index: 0;
    min-height: 180px;
    overflow: hidden;
    border-radius: 18px;
    background: #dbe3ec;
}

.leaflet-container,
.leaflet-pane,
.leaflet-map-pane,
.leaflet-tile-pane,
.leaflet-overlay-pane,
.leaflet-marker-pane,
.leaflet-shadow-pane,
.leaflet-popup-pane {
    z-index: 1 !important;
}

.leaflet-top,
.leaflet-bottom,
.leaflet-control-container {
    z-index: 2 !important;
}

.map-card.tall {
    min-height: 280px;
    margin-bottom: 12px;
}

.participant-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.participant {
    display: grid;
    justify-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: center;
    font-size: 12px;
    font-weight: 650;
}

.documents-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-weight: 800;
}

.info-divider {
    display: block;
    justify-self: stretch;
    width: 100%;
    min-width: 100%;
    height: 2px;
    border-radius: 999px;
    background: rgba(20, 32, 51, 0.18);
    margin: 14px 0 8px;
}

.folder-card {
    padding: 8px 0;
    background: transparent;
    border-left: 3px solid rgba(20, 32, 51, 0.16);
    border-radius: 0;
}

.folder-card summary {
    display: flex;
    justify-content: space-between;
    padding: 6px 0 6px 10px;
    list-style: none;
    font-weight: 800;
}

.document-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-left: 10px;
    padding: 9px 0;
    background: transparent;
}

.document-row a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.document-row a span:last-child {
    display: grid;
    min-width: 0;
}

.document-row small {
    color: var(--muted);
    font-size: 12px;
}

.folder-add-file {
    margin: 4px 0 0 10px;
    border: 0;
    background: transparent;
    color: var(--accent);
    padding: 8px 0;
    font-weight: 800;
    text-align: left;
}

.overview-card {
    display: grid;
    gap: 4px;
    padding: 13px;
    box-shadow: var(--shadow);
}

.settlement-card {
    width: 100%;
    border: 0;
    color: inherit;
    font: inherit;
    text-align: left;
}

.settlement-card small {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
}

.expense-card-regular {
    background: #fff0f0;
    border-color: rgba(200, 61, 61, 0.18);
}

.expense-card-settlement {
    background: #edf4ff;
    border-color: rgba(47, 125, 246, 0.18);
}

.tab-content > .overview-card + .overview-card,
.map-card + .overview-card,
.overview-card + .overview-card {
    margin-top: 10px;
}

.pinboard-list {
    display: grid;
    gap: 10px;
}

.action-card {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.overview-card a {
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 28px 18px;
    text-align: center;
}

.empty-state h2,
.empty-state p {
    margin: 0;
}

.empty-icon,
.app-mark {
    display: grid;
    width: 62px;
    height: 62px;
    place-items: center;
    border-radius: 22px;
    background: #e5eefc;
    color: var(--accent);
    font-size: 28px;
}

.footer-signature {
    position: fixed;
    right: 0;
    bottom: env(safe-area-inset-bottom);
    left: 0;
    padding: 12px;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
    pointer-events: none;
}

.sheet {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: none;
    align-items: flex-end;
    overflow-y: auto;
    padding-top: calc(env(safe-area-inset-top) + 18px);
    background: rgba(0, 0, 0, 0.28);
}

.sheet.open {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.sheet-card {
    display: grid;
    width: min(100%, 520px);
    max-height: min(88vh, 780px);
    gap: 12px;
    margin: 0 auto;
    overflow: auto;
    padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
    border-radius: 24px 24px 0 0;
    background: var(--bg);
    box-shadow: 0 -22px 50px rgba(0, 0, 0, 0.18);
}

.danger-card {
    width: min(100%, 520px);
    max-height: none;
    padding: 0 16px 10px;
    border-radius: 0;
    background: var(--bg);
    box-shadow: none;
}

.danger-card + .danger-card {
    padding-top: 0;
}

.inline-form-card {
    width: min(100%, 520px);
    max-height: none;
    padding-top: 0;
    border-radius: 0;
    background: var(--bg);
    box-shadow: none;
}

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

.sheet-header h2 {
    margin: 0;
    font-size: 19px;
}

label,
fieldset {
    display: grid;
    gap: 6px;
    margin: 0;
    border: 0;
    padding: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

legend {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
    padding: 11px 12px;
}

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

.sheet-form,
.sheet-inline-form {
    display: grid;
    gap: 12px;
    margin: 0;
}

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

.stack {
    display: grid;
    gap: 12px;
}

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

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
}

.user-row form {
    margin: 0;
}

.user-row strong {
    flex: 1;
}

.user-row span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.check-row input {
    width: auto;
}

.color-row {
    display: flex;
    gap: 8px;
    padding: 2px 0;
}

.color-row label {
    width: 30px;
    height: 30px;
    border: 2px solid transparent;
    border-radius: 999px;
}

.color-row input {
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
}

.color-row label:has(input:checked) {
    border-color: var(--text);
}

.primary-button,
.secondary-button,
.plain-button,
.menu-row,
.danger-row {
    border: 0;
    border-radius: 13px;
    padding: 12px 14px;
    font-weight: 800;
}

.compact-actions {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 7px;
    justify-content: flex-end;
    white-space: nowrap;
}

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

.mini-row > .compact-actions {
    display: grid;
    grid-template-columns: repeat(2, 28px);
    gap: 7px;
    justify-content: end;
}

button:disabled {
    cursor: default;
    opacity: 0.45;
}

.participant-select-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.participant-select {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: 10px 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
    color: var(--text);
    text-align: center;
}

.participant-select input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.participant-select:has(input:checked) {
    border-color: var(--accent);
    background: rgba(47, 125, 246, 0.1);
}

.participant-select strong {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.help-list {
    display: grid;
    gap: 10px;
}

.help-row {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 12px;
    padding: 13px;
    border-radius: 16px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.help-row.indented {
    margin-left: 28px;
    background: rgba(255, 255, 255, 0.68);
}

.help-icon {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 999px;
    background: rgba(47, 125, 246, 0.1);
    color: var(--accent);
    font-weight: 900;
}

.help-row strong,
.help-row p {
    margin: 0;
}

.help-row p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

body.exporting .trip-top,
body.exporting .tab-bar,
body.exporting .timeline-strip,
body.exporting .icon-action-row,
body.exporting .day-actions,
body.exporting .compact-actions,
body.exporting .tiny-button,
body.exporting .sheet,
body.exporting .footer-signature {
    display: none !important;
}

body.exporting .day-card.collapsed .day-body {
    display: grid;
}

body.exporting-costs .trip-top,
body.exporting-costs .tab-bar,
body.exporting-costs .icon-button,
body.exporting-costs .tiny-button,
body.exporting-costs .sheet,
body.exporting-costs .footer-signature {
    display: none !important;
}

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

.secondary-button,
.menu-row {
    background: var(--card);
    color: var(--text);
    text-align: left;
}

.plain-button {
    background: transparent;
    color: var(--accent);
    padding: 0;
}

.danger-row {
    width: 100%;
    background: rgba(200, 61, 61, 0.12);
    color: var(--danger);
    text-align: left;
}

.notice {
    margin: 8px 0;
    padding: 12px;
    border-radius: 14px;
    font-size: 14px;
}

.notice.success {
    background: #dff3df;
}

.notice.error {
    background: #ffd9d9;
}

.setup-screen {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 18px;
}

.setup-card {
    display: grid;
    width: min(100%, 420px);
    gap: 14px;
    padding: 24px;
    border-radius: 24px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.setup-card h1,
.setup-card p {
    margin: 0;
}

.currency-tool {
    padding: 4px 0;
}

.currency-title {
    margin-bottom: 10px;
}

.currency-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.currency-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.currency-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.currency-card input {
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 20px;
    font-weight: 850;
}

.currency-tool [data-rate-label] {
    margin: 0;
    text-align: left;
}

@media print {
    body {
        background: #fff;
    }

    .trip-top,
    .tab-bar,
    .timeline-strip,
    .icon-action-row,
    .day-actions,
    .compact-actions,
    .tiny-button,
    .sheet,
    .footer-signature {
        display: none !important;
    }

    .app-shell {
        width: 100%;
        padding: 0;
    }

    .day-card,
    .overview-card {
        break-inside: avoid;
        box-shadow: none;
    }
}
