/* ============================================================
   TOURENBEZOGENER KOSTEN-TRACKER
   ============================================================ */

#costs-view {
    display: none;
    color: #f5f7ff;
}

body.cost-workspace-active #costs-view {
    display: block;
    position: fixed;
    top: 96px;
    right: 24px;
    bottom: 24px;
    left: 378px;
    z-index: 140;
    box-sizing: border-box;
    overflow: hidden;
    border: 2px solid rgba(168, 85, 247, 0.48);
    border-radius: 20px;
    background:
        radial-gradient(circle at 88% 0%, rgba(62, 222, 232, 0.1), transparent 30%),
        radial-gradient(circle at 8% 4%, rgba(168, 85, 247, 0.16), transparent 34%),
        linear-gradient(155deg, rgba(7, 13, 35, 0.97), rgba(3, 9, 26, 0.98));
    box-shadow: 0 18px 55px rgba(0, 0, 0, 0.62), 0 0 22px rgba(103, 56, 204, 0.18);
    scrollbar-color: rgba(168, 85, 247, 0.6) transparent;
}

body.cost-workspace-active #map,
body.cost-workspace-active #route-creator-toolbar,
body.cost-workspace-active #poi-toolbar,
body.cost-workspace-active #tile-switcher,
body.cost-workspace-active #tile-switcher-toggle,
body.cost-workspace-active .mapboxgl-control-container {
    display: none !important;
}

body.cost-workspace-active #menu-cost-calculator { display: none !important; }
body.cost-workspace-active #menu-tours { display: flex !important; }

.cost-workspace-panel {
    display: flex;
    height: 100%;
    width: min(100%, 1320px);
    min-height: 0;
    flex-direction: column;
    box-sizing: border-box;
    margin: 0 auto;
    padding: 30px clamp(20px, 3vw, 42px) 42px;
}

#costs-content {
    min-height: 0;
    flex: 1;
    flex-direction: column;
}

.cost-workspace-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.cost-workspace-header h2 {
    margin: 4px 0 7px;
    color: #fff;
    font-size: clamp(1.7rem, 2.2vw, 2.3rem);
    line-height: 1.1;
}

.cost-workspace-header p {
    max-width: 720px;
    margin: 0;
    color: #aeb6cc;
    line-height: 1.5;
}

.cost-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cost-export-wrap { position: relative; }
.cost-export-toggle::after { content: ' ▾'; }

.cost-export-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 30;
    width: min(360px, calc(100vw - 48px));
    box-sizing: border-box;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border: 1px solid rgba(168, 85, 247, 0.48);
    border-radius: 14px;
    background: linear-gradient(150deg, rgba(15, 22, 53, 0.99), rgba(4, 10, 29, 0.99));
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.58);
}

.cost-export-panel > strong { color: #fff; font-size: 1rem; }
.cost-export-field { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.cost-export-field > span { color: #aeb6cc; font-size: 0.75rem; font-weight: 750; }
.cost-export-field select,
.cost-export-field input {
    width: 100%;
    min-height: 40px;
    box-sizing: border-box;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9px;
    outline: 0;
    background: rgba(3, 9, 26, 0.84);
    color: #fff;
    color-scheme: dark;
    font: inherit;
}
.cost-export-field select:focus,
.cost-export-field input:focus { border-color: #a855f7; box-shadow: 0 0 0 2px rgba(168,85,247,0.13); }
.cost-export-period-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

.cost-export-option {
    display: flex;
    width: 100%;
    min-height: 62px;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    box-sizing: border-box;
    padding: 11px 13px;
    border: 1px solid rgba(88, 230, 235, 0.28);
    border-radius: 10px;
    background: rgba(25, 93, 104, 0.13);
    color: #fff;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.cost-export-option:hover:not(:disabled) { border-color: rgba(88, 230, 235, 0.6); background: rgba(25, 93, 104, 0.24); }
.cost-export-option strong { font-size: 0.84rem; }
.cost-export-option small { color: #92a0b9; font-size: 0.7rem; line-height: 1.35; }
.cost-export-option:disabled { opacity: 0.46; cursor: not-allowed; }

.cost-eyebrow {
    color: #58e6eb;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.btn-cost-primary,
.btn-cost-secondary,
.btn-cost-danger,
.btn-cost-icon {
    min-height: 42px;
    box-sizing: border-box;
    border-radius: 10px;
    color: #fff;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.16s ease, filter 0.16s ease, border-color 0.16s ease;
}

.btn-cost-primary {
    padding: 11px 18px;
    border: 0;
    background: linear-gradient(135deg, #8138e9, #ad5cf8);
    box-shadow: 0 8px 24px rgba(126, 50, 230, 0.3);
}

.btn-cost-secondary {
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(13, 20, 49, 0.82);
}

.btn-cost-danger {
    padding: 8px 12px;
    border: 1px solid rgba(255, 91, 114, 0.36);
    background: rgba(111, 22, 43, 0.25);
    color: #ff91a1;
}

.btn-cost-icon {
    min-width: 40px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.055);
}

.btn-cost-primary:hover:not(:disabled),
.btn-cost-secondary:hover:not(:disabled),
.btn-cost-danger:hover:not(:disabled),
.btn-cost-icon:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(1.09);
}

.btn-cost-primary:disabled,
.btn-cost-secondary:disabled,
.btn-cost-danger:disabled,
.btn-cost-icon:disabled {
    opacity: 0.5;
    cursor: wait;
}

.cost-empty-state,
.cost-locked-card {
    display: flex;
    min-height: 220px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 9px;
    padding: 28px;
    box-sizing: border-box;
    border: 1px dashed rgba(168, 85, 247, 0.42);
    border-radius: 16px;
    background: rgba(10, 16, 42, 0.66);
    color: #aeb6cc;
    text-align: center;
}

.cost-empty-state strong,
.cost-locked-card h3 { color: #fff; }
.cost-locked-card p { max-width: 560px; margin: 2px auto 12px; line-height: 1.55; }

.cost-budget-warning {
    margin-bottom: 18px;
    padding: 14px 17px;
    border: 1px solid rgba(255, 194, 80, 0.48);
    border-radius: 12px;
    background: rgba(116, 74, 15, 0.26);
    color: #ffd48b;
    font-weight: 750;
    line-height: 1.4;
}

.cost-budget-warning.is-exceeded {
    border-color: rgba(255, 91, 114, 0.55);
    background: rgba(117, 21, 44, 0.28);
    color: #ff9cac;
}

.cost-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.cost-summary-grid.is-alltime { grid-template-columns: 1fr; }

.cost-summary-card {
    display: flex;
    min-height: 122px;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 15px;
    background: linear-gradient(145deg, rgba(19, 26, 61, 0.9), rgba(9, 15, 38, 0.9));
    box-shadow: inset 0 0 24px rgba(91, 72, 190, 0.05);
}

.cost-summary-card > span,
.cost-summary-card small { color: #99a4be; }
.cost-summary-card > span { font-size: 0.8rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.05em; }
.cost-summary-card strong { margin: 7px 0 5px; color: #fff; font-size: clamp(1.45rem, 2.2vw, 2rem); }
.cost-summary-total { border-color: rgba(88, 230, 235, 0.36); }
.cost-summary-total strong { color: #64edf0; }
.cost-summary-card.is-negative strong { color: #ff91a1; }

.cost-budget-progress-wrap {
    margin-top: 16px;
    padding: 15px 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 13px;
    background: rgba(7, 13, 34, 0.66);
}

.cost-budget-progress-labels {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 9px;
    color: #aeb6cc;
    font-size: 0.78rem;
}

.cost-budget-track {
    position: relative;
    height: 10px;
    overflow: visible;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
}

.cost-budget-progress {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #4b7df3, #58e6eb);
    transition: width 0.3s ease;
}

.cost-budget-progress.is-warning { background: linear-gradient(90deg, #ffb84d, #ffd66f); }
.cost-budget-progress.is-exceeded { background: linear-gradient(90deg, #f14668, #ff8296); }
.cost-budget-marker { position: absolute; top: -4px; left: 80%; width: 2px; height: 18px; border-radius: 3px; background: #fff; box-shadow: 0 0 7px rgba(255,255,255,0.75); }

.cost-main-grid {
    display: grid;
    min-height: 0;
    flex: 1;
    grid-template-columns: minmax(0, 1.65fr) minmax(250px, 0.75fr);
    gap: 16px;
    margin-top: 16px;
}

.cost-side-column { display: flex; flex-direction: column; gap: 16px; }
.cost-side-column > .cost-panel:last-child { flex: 1; }

.cost-panel {
    box-sizing: border-box;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 15px;
    background: linear-gradient(145deg, rgba(15, 22, 53, 0.9), rgba(7, 13, 34, 0.9));
}

.cost-panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.cost-panel-heading h3 { margin: 0; color: #fff; font-size: 1.05rem; }
.cost-panel-heading span { color: #58e6eb; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }

.cost-expense-panel {
    display: flex;
    min-height: 0;
    flex-direction: column;
}

.cost-expense-list {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
    gap: 11px;
    padding-right: 7px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(168, 85, 247, 0.72) rgba(255, 255, 255, 0.04);
    scrollbar-width: thin;
}

.cost-expense-list::-webkit-scrollbar { width: 8px; }
.cost-expense-list::-webkit-scrollbar-track { border-radius: 999px; background: rgba(255, 255, 255, 0.04); }
.cost-expense-list::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(168, 85, 247, 0.72); }

.cost-expense-empty {
    padding: 42px 16px;
    border: 1px dashed rgba(255, 255, 255, 0.14);
    border-radius: 13px;
    color: #8994ad;
    text-align: center;
    line-height: 1.5;
}

.cost-expense-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 13px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 13px;
    background: rgba(4, 10, 29, 0.62);
}

.cost-expense-icon {
    display: flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(168, 85, 247, 0.32);
    border-radius: 12px;
    background: rgba(126, 50, 230, 0.14);
    font-size: 1.25rem;
}

.cost-expense-body { min-width: 0; }
.cost-expense-title-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px 10px; }
.cost-expense-title { color: #fff; font-weight: 800; }
.cost-expense-original { color: #aeb6cc; font-size: 0.84rem; }
.cost-expense-meta { margin-top: 5px; color: #7f8aa5; font-size: 0.76rem; line-height: 1.4; }
.cost-expense-note { margin: 7px 0 0; overflow-wrap: anywhere; color: #bdc5d7; font-size: 0.84rem; line-height: 1.4; }
.cost-expense-total { color: #64edf0; font-size: 1.05rem; font-weight: 900; white-space: nowrap; text-align: right; }
.cost-expense-actions { grid-column: 2 / 4; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }

.cost-receipt-link {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 5px;
    padding: 6px 9px;
    box-sizing: border-box;
    border: 1px solid rgba(88, 230, 235, 0.24);
    border-radius: 9px;
    background: rgba(24, 91, 100, 0.12);
    color: #83edf0;
    font-size: 0.74rem;
    text-decoration: none;
}

.cost-receipt-delete { min-height: 34px; padding: 5px 8px; }

.cost-category-list { display: flex; flex-direction: column; gap: 12px; }
.cost-category-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; }
.cost-category-name { overflow: hidden; color: #dbe0ec; font-size: 0.84rem; text-overflow: ellipsis; white-space: nowrap; }
.cost-category-value { color: #fff; font-size: 0.82rem; font-weight: 800; white-space: nowrap; }
.cost-category-bar-wrap { grid-column: 2 / 4; height: 5px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,0.09); }
.cost-category-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8138e9, #58e6eb); }

.cost-budget-form,
.expense-form { display: flex; flex-direction: column; gap: 13px; }
.cost-budget-form label,
.expense-field > span { color: #aeb6cc; font-size: 0.78rem; font-weight: 750; }
.cost-budget-form input,
.expense-field input,
.expense-field select,
.expense-field textarea {
    width: 100%;
    min-height: 43px;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9px;
    outline: 0;
    background: rgba(3, 9, 26, 0.76);
    color: #fff;
    font: inherit;
}
.expense-field textarea { min-height: 80px; resize: vertical; }
.cost-budget-form input:focus,
.expense-field input:focus,
.expense-field select:focus,
.expense-field textarea:focus { border-color: #a855f7; box-shadow: 0 0 0 2px rgba(168,85,247,0.13); }
.cost-threshold-field { position: relative; }
.cost-threshold-field span { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); color: #8e99b2; }
.cost-threshold-field input { padding-right: 30px; }

.expense-modal-box {
    width: min(680px, calc(100vw - 30px));
    max-height: min(90vh, 850px);
    overflow-y: auto;
    box-sizing: border-box;
    border: 1px solid rgba(168, 85, 247, 0.45);
    background: linear-gradient(150deg, rgba(14, 21, 51, 0.99), rgba(4, 10, 29, 0.99));
}

.expense-modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.expense-modal-header h3 { margin: 5px 0 0; color: #fff; font-size: 1.35rem; }
.expense-modal-close { width: 38px; height: 38px; flex: 0 0 auto; border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; background: rgba(255,255,255,0.05); color: #fff; cursor: pointer; }
.expense-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.expense-field { display: flex; min-width: 0; flex-direction: column; gap: 7px; }
.expense-field input[type="file"] { height: auto; padding: 11px; }
.expense-field small { color: #7f8aa5; line-height: 1.4; }
.expense-receipt-field { padding: 13px; border: 1px dashed rgba(88, 230, 235, 0.28); border-radius: 11px; background: rgba(20, 92, 101, 0.08); }
.expense-currency-suggestion { margin: -1px 0 1px; color: #8490aa; font-size: 0.78rem; line-height: 1.4; }
.expense-currency-suggestion.is-success { color: #75e7ca; }
.expense-currency-suggestion.is-warning { color: #ffd48b; }
.expense-manual-rate { padding: 11px 13px; border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; background: rgba(3, 9, 26, 0.48); }
.expense-manual-rate summary { color: #aeb6cc; font-size: 0.8rem; cursor: pointer; }
.expense-manual-rate[open] summary { margin-bottom: 12px; }
.expense-form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }

@media (max-width: 1100px) {
    body.cost-workspace-active #costs-view { right: 24px; left: 290px; }
    .cost-main-grid { grid-template-columns: 1fr; }
    .cost-side-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
    body.cost-workspace-active #costs-view {
        top: calc(env(safe-area-inset-top, 0px) + 68px);
        right: 10px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
        left: 10px;
        border-radius: 15px;
        overflow-y: auto;
    }
    .cost-workspace-panel { padding: 20px 14px 28px; }
    .cost-workspace-header { align-items: stretch; flex-direction: column; gap: 15px; }
    .cost-header-actions { width: 100%; align-items: stretch; }
    .cost-header-actions > .btn-cost-primary,
    .cost-header-actions > .cost-export-wrap { flex: 1; }
    .cost-header-actions .btn-cost-primary,
    .cost-header-actions .cost-export-toggle { width: 100%; }
    .cost-export-panel { right: auto; left: 0; }
    .cost-summary-grid { grid-template-columns: 1fr; }
    .cost-summary-card { min-height: 105px; }
    .cost-side-column { display: flex; }
    .cost-expense-item { grid-template-columns: auto minmax(0, 1fr); }
    .cost-expense-total { grid-column: 2; text-align: left; }
    .cost-expense-actions { grid-column: 1 / 3; justify-content: flex-start; }
    .cost-workspace-panel { height: auto; min-height: 100%; }
    #costs-content { flex: none; }
    .cost-main-grid { flex: none; }
    .cost-expense-list { max-height: none; overflow-y: visible; }
    .cost-budget-progress-labels { align-items: flex-start; flex-direction: column; gap: 4px; }
    .expense-form-grid { grid-template-columns: 1fr; }
    .expense-form-actions > button { flex: 1; }
}

@media (max-width: 430px) {
    .cost-panel { padding: 15px; }
    .cost-expense-item { gap: 10px; padding: 12px; }
    .cost-expense-icon { width: 38px; height: 38px; }
    .expense-modal-box { width: calc(100vw - 18px); padding: 18px 14px; }
}


