/* Soubor: style.css | Verze: 9.10 (Aggressive Settlement Colors) */
:root {
    --primary: #2c3e50;
    --accent: #27ae60;
    --info: #3498db;
    --bg: #f0f2f5;
    --card: #ffffff;
    --border: #e1e4e8;
    
    --success-bg: #e6fffa;
    --success-text: #276749;
    --success-border: #38a169;
    
    --danger-bg: #fff5f5;
    --danger-text: #c53030;
    --danger-border: #e53e3e;
    
    --neutral-bg: #edf2f7;
    --neutral-text: #4a5568;

    --selected-bg: #ebf8ff;
    --selected-border: #4299e1;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* --- BASE RESET --- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg);
    margin: 0; padding: 15px; color: #1a202c;
    -webkit-font-smoothing: antialiased; text-size-adjust: 100%;
    padding-top: env(safe-area-inset-top, 15px);
    padding-bottom: env(safe-area-inset-bottom, 15px);
}

.container { max-width: 650px; margin: 0 auto; padding-bottom: 80px; transition: max-width 0.3s ease; }

.flex { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

/* --- PWA UPDATE BAR --- */
#pwa-update-bar {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(44, 62, 80, 0.95); color: white;
    z-index: 10000; display: none; flex-direction: column;
    align-items: center; justify-content: center; text-align: center;
}
#pwa-update-bar.show { display: flex; }
.spinner {
    border: 4px solid rgba(255,255,255,0.3); border-radius: 50%; border-top: 4px solid #fff;
    width: 40px; height: 40px; animation: spin 1s linear infinite; margin-bottom: 20px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- AUTH SCREEN --- */
#auth-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 90vh; text-align: center; padding: 20px 0; }
#auth-screen h1 { margin-bottom: 10px; font-size: 2rem; }
#auth-screen form { width: 100%; max-width: 340px; background: white; padding: 25px; border-radius: 20px; box-shadow: var(--shadow-md); margin-bottom: 20px; }
#auth-screen p { margin-bottom: 15px; color: #4a5568; font-weight: 600; }

.auth-app-info {
    max-width: 340px; margin-bottom: 25px; background: rgba(255,255,255,0.5);
    padding: 15px; border-radius: 16px; border: 1px solid rgba(0,0,0,0.05);
}
.auth-app-info p { margin-bottom: 12px !important; color: var(--primary) !important; font-size: 1rem; }
.auth-app-info ul { list-style: none; padding: 0; margin: 0; text-align: left; }
.auth-app-info li { 
    font-size: 0.85rem; color: #4a5568; margin-bottom: 8px; display: flex; gap: 10px; align-items: flex-start;
    line-height: 1.4;
}
.auth-app-info li i { color: var(--accent); margin-top: 3px; font-size: 0.9rem; width: 16px; text-align: center; }

.auth-footer-help { margin-top: 10px; }
.auth-footer-help a { color: #718096; font-size: 0.85rem; font-weight: 500; display: flex; align-items: center; gap: 6px; justify-content: center; }

/* --- FORMS --- */
input[type="text"], input[type="password"], input[type="number"], select {
    padding: 12px; border: 1px solid var(--border); border-radius: 10px; width: 100%;
    margin-bottom: 12px; font-size: 16px; background-color: #fff; appearance: none; -webkit-appearance: none;
}
button {
    background-color: var(--primary); color: white; border: none; padding: 14px 20px;
    border-radius: 10px; cursor: pointer; font-size: 16px; font-weight: 700; width: 100%; transition: transform 0.1s, opacity 0.2s;
}
button:active { opacity: 0.8; transform: scale(0.98); }
button.secondary { background-color: #95a5a6; }
button.danger { background-color: #c53030; font-size: 13px; padding: 8px 14px; width: auto; }
button.icon-btn { padding: 10px 14px; margin-left: 0; }

/* --- AVATAR CHIPS (Custom Radio Selector) --- */
.chip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}
.chip-input { display: none; }
.chip-label {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: #fff; border: 2px solid var(--border); border-radius: 12px;
    padding: 10px; cursor: pointer; transition: all 0.2s ease;
    opacity: 1;
}
.chip-label.inactive-member { opacity: 0.6; background: #f9f9f9; }
.chip-label:hover { border-color: #cbd5e0; }
.chip-input:checked + .chip-label {
    border-color: var(--selected-border);
    background-color: var(--selected-bg);
    box-shadow: 0 0 0 1px var(--selected-border);
}
.chip-name { font-size: 0.85rem; font-weight: 600; margin-top: 6px; text-align: center; color: #2d3748; }

/* --- SWAP BUTTON --- */
.swap-separator {
    display: flex; justify-content: center; align-items: center;
    margin: -10px 0 10px 0; z-index: 5; position: relative;
}
.btn-swap {
    width: 36px; height: 36px; border-radius: 50%;
    background: white; border: 1px solid var(--border);
    color: var(--primary); font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0;
    transition: all 0.2s ease;
}
.btn-swap:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.1); }
.btn-swap:active { transform: rotate(180deg) scale(0.95); background: #f7fafc; }

/* --- HEADER --- */
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; padding: 0 5px; }
h1 { margin: 0; font-size: 1.4rem; font-weight: 800; color: var(--primary); letter-spacing: -0.5px; }

.header-actions { display: flex; gap: 4px; }
.header-btn {
    background: transparent; color: #718096; border: none;
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; cursor: pointer; transition: all 0.2s; padding: 0;
}
.header-btn:hover, .header-btn:active { background: rgba(0,0,0,0.05); color: var(--primary); }
.help-btn { color: #a0aec0; font-size: 1rem; }

/* --- HERO BALANCE --- */
.balance-card { background: transparent; padding: 0; box-shadow: none; border: none; margin-bottom: 30px; }
.hero-scroll-wrapper {
    display: flex; gap: 12px; overflow-x: auto; padding: 5px 2px 15px 2px;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; -ms-overflow-style: none;
}
.hero-scroll-wrapper::-webkit-scrollbar { display: none; }

.member-card {
    background: var(--card); min-width: 130px; flex: 1; border-radius: 16px; padding: 15px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: var(--shadow-md); border: 1px solid transparent;
    transition: transform 0.2s; scroll-snap-align: start; position: relative; overflow: hidden;
}
.card-positive { border-bottom: 4px solid var(--success-border); }
.card-negative { border-bottom: 4px solid var(--danger-border); }
.card-neutral { border-bottom: 4px solid #cbd5e0; opacity: 0.8; }
.card-amount { font-size: 1.2rem; font-weight: 800; margin: 8px 0 4px 0; letter-spacing: -0.5px; }
.card-name { font-size: 0.85rem; font-weight: 600; color: #4a5568; margin-top: 5px; }
.card-label { font-size: 0.65rem; padding: 2px 8px; border-radius: 10px; font-weight: 700; text-transform: uppercase; margin-top: auto; }

/* --- SETTLEMENT LIST (AGGRESSIVE UI) --- */
.settlement-container-wrapper {
    background: var(--card); 
    border-radius: 24px; 
    box-shadow: var(--shadow-lg);
    padding: 25px 20px; 
    margin-top: 20px; 
    border: 3px solid transparent; 
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    z-index: 10;
}

/* Status: DEBT (STRONG Red) */
@keyframes pulse-red {
    0% { box-shadow: 0 15px 30px rgba(229, 62, 62, 0.25); border-color: #fc8181; }
    50% { box-shadow: 0 15px 35px rgba(229, 62, 62, 0.4); border-color: #f56565; }
    100% { box-shadow: 0 15px 30px rgba(229, 62, 62, 0.25); border-color: #fc8181; }
}

.settlement-container-wrapper.status-debt {
    background-color: #fff0f0; /* More distinct red background */
    border-color: #fc8181;
    box-shadow: 0 15px 30px rgba(229, 62, 62, 0.25);
    animation: pulse-red 3s infinite ease-in-out; /* Subtle pulse */
}
.settlement-container-wrapper.status-debt .view-toggle {
    background: #fed7d7; /* Redder tabs background */
}
.settlement-container-wrapper.status-debt .view-btn.active {
    color: #c53030;
}

/* Status: SETTLED (STRONG Green) */
.settlement-container-wrapper.status-settled {
    background-color: #f0fff4; /* More distinct green background */
    border: 3px solid #48bb78; /* Solid green border */
    box-shadow: 0 15px 30px rgba(72, 187, 120, 0.3);
}
.settlement-container-wrapper.status-settled .view-toggle {
    background: #c6f6d5; /* Greener tabs background */
}
.settlement-container-wrapper.status-settled .view-btn.active {
    color: #276749;
}

.view-toggle { 
    display: flex; background: rgba(0,0,0,0.05); 
    border-radius: 16px; padding: 5px; margin-bottom: 25px; 
}
.view-btn { 
    flex: 1; text-align: center; padding: 12px 0; font-size: 0.95rem; font-weight: 600; 
    color: #718096; cursor: pointer; border-radius: 12px; transition: all 0.3s; 
}
.view-btn.active { 
    background: white; color: var(--primary); 
    box-shadow: 0 2px 8px rgba(0,0,0,0.08); 
    font-weight: 800; transform: scale(1.02);
}

.settlement-group { border: 1px solid var(--border); border-radius: 16px; margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.settlement-header { background: #f8fafc; padding: 12px 15px; border-bottom: 1px solid var(--border); font-size: 0.9rem; color: #4a5568; font-weight: 700; }
.settlement-sub-row { display: flex; align-items: center; justify-content: space-between; padding: 15px; border-bottom: 1px solid #edf2f7; background: white; }
.settlement-sub-row:last-child { border: none; }
.settlement-amount { font-weight: 800; font-size: 1.15rem; color: var(--primary); }

/* --- AVATARS --- */
.avatar, .avatar-small, .avatar-large {
    border-radius: 50% !important; 
    overflow: hidden !important; 
    background-size: cover; background-position: center; background-repeat: no-repeat;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.avatar { width: 32px; height: 32px; font-weight: bold; font-size: 0.8rem; border: 1px solid rgba(0,0,0,0.05); }
.avatar-small { width: 22px; height: 22px; font-size: 0.65rem; margin-right: 5px; }
.avatar-large { width: 48px; height: 48px; font-size: 1.1rem; border: 2px solid white; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }

/* --- UPCOMING PAYMENTS --- */
.upcoming-section { margin-bottom: 30px; }
.upcoming-scroll {
    display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px;
    scrollbar-width: none;
}
.upcoming-scroll::-webkit-scrollbar { display: none; }
.upcoming-card {
    background: #fff; min-width: 160px; padding: 12px; border-radius: 12px;
    border: 1px dashed #cbd5e0; flex-shrink: 0; display: flex; flex-direction: column; gap: 5px;
}
.upcoming-card .up-date { font-size: 0.7rem; font-weight: 700; color: #718096; text-transform: uppercase; }
.upcoming-card .up-title { font-size: 0.85rem; font-weight: 700; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upcoming-card .up-amount { font-size: 1rem; font-weight: 800; color: var(--accent); }
.upcoming-card .up-info { font-size: 0.7rem; color: #a0aec0; }

/* --- ACTIONS GRID --- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 35px; }
.btn-expense {
    text-align: left; display: flex; flex-direction: column; justify-content: center;
    min-height: 85px; background: white; border: 1px solid var(--border); color: var(--primary);
    box-shadow: var(--shadow-sm); padding: 15px; border-radius: 12px; position: relative; overflow: hidden;
    transition: transform 0.1s;
}
.btn-expense:active { transform: scale(0.98); }
.btn-expense::before { content:''; position:absolute; left:0; top:0; bottom:0; width:5px; background: currentColor; }
.btn-expense span { font-weight: 700; font-size: 0.95rem; }
.btn-expense small { display: block; margin-top: 4px; font-size: 0.75rem; opacity: 0.6; font-weight: 500; }

.btn-custom {
    background-color: white; color: #4a5568; 
    border: 1px dashed #a0aec0;
    align-items: center; text-align: center;
}
.btn-custom::before { display: none; }
.btn-custom i { color: #718096; font-size: 1.5rem; margin-bottom: 5px; }

/* --- SECTIONS --- */
h2 { font-size: 1.1rem; color: #2d3748; margin-bottom: 12px; margin-top: 35px; font-weight: 700; display: flex; align-items: center; }
h2::before { content:''; display:inline-block; width:5px; height:20px; background: var(--accent); margin-right: 8px; border-radius: 3px; }

.item {
    background: white; padding: 15px; margin-bottom: 10px; border-radius: 12px;
    display: flex; justify-content: space-between; align-items: flex-start;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border); position: relative; overflow: hidden;
}
.item-indicator { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.item-content { width: 100%; display: flex; flex-direction: column; padding-left: 10px; }
.item-desc { font-weight: 700; font-size: 1rem; margin-bottom: 4px; color: #2d3748; }
.debt-relationship { display: inline-flex; align-items: center; background: #f7fafc; padding: 3px 8px; border-radius: 20px; margin-top: 5px; font-size: 0.75rem; border: 1px solid #edf2f7; }
.item-right-group { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.item-amount { font-weight: 800; font-size: 1.1rem; color: var(--primary); }

.action-row { display: flex; gap: 8px; margin-top: 5px; }

/* Buttons for Settlement/Actions */
.btn-pay { 
    background: white; border: 1px solid var(--accent); color: var(--accent); 
    padding: 6px 12px; border-radius: 10px; font-weight: bold; font-size: 0.9rem;
    transition: all 0.2s;
}
.btn-pay:active { background: var(--accent); color: white; }

.btn-info {
    background: white; border: 1px solid var(--info); color: var(--info);
    padding: 6px 12px; border-radius: 10px; font-weight: bold; font-size: 0.9rem;
    transition: all 0.2s;
}
.btn-info:active { background: var(--info); color: white; }

/* --- STATS & CHARTS --- */
.stats-summary-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 25px; }
.summary-card { background: white; padding: 20px; border-radius: 12px; text-align: center; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.summary-card small { color: #718096; font-size: 0.75rem; text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; }
.summary-card div { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin-top: 5px; }

.charts-wrapper { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 30px; }
.chart-card { background: white; padding: 20px; border-radius: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.chart-title { font-size: 0.95rem; font-weight: 700; color: #4a5568; margin-bottom: 15px; text-align: center; }

.stats-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 15px; }
.stat-box { background: #ffffff; padding: 12px; border-radius: 10px; text-align: center; font-size: 0.85rem; border: 1px solid #eee; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.stat-value { display: block; font-weight: bold; font-size: 1.1rem; margin-top: 4px; color: #333; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 15px; background: white; border-radius: 12px; padding: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.monthly-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 300px; }
.monthly-table th { text-align: left; padding: 10px; border-bottom: 2px solid #eee; color: #888; font-weight: normal; white-space: nowrap; }
.monthly-table td { padding: 10px; border-bottom: 1px solid #f4f4f4; white-space: nowrap; }

/* --- MODALS --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 1000; display: flex; justify-content: center; align-items: flex-start; padding-top: 5vh; overflow-y: auto; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content { background: white; width: 92%; max-width: 500px; padding: 25px; border-radius: 20px; box-shadow: 0 20px 40px rgba(0,0,0,0.2); margin-bottom: 50px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid #eee; padding-bottom: 15px; }
.close-btn { font-size: 1.8rem; color: #cbd5e0; background: none; padding: 0; line-height: 1; border:none; height:auto; width:auto; cursor:pointer;}

.settings-section { border-top: 1px solid #eee; margin-top: 20px; padding-top: 15px; }
.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 0.9rem; color: #4a5568; }
.rule-item { border: 1px solid #eee; padding: 10px; border-radius: 10px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }

.member-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.member-row input[type="text"] { margin-bottom: 0; flex: 1; }

.wipe-data-area { margin-top: 30px; padding-top: 20px; border-top: 2px solid #fed7d7; }

/* --- SYSTEM DIALOG (Better Buttons) --- */
.sys-dialog-body { margin-bottom: 20px; font-size: 1rem; color: #2d3748; text-align: center; }
.sys-dialog-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.btn-sys-confirm { background-color: var(--accent); color: white; padding: 14px; border-radius: 12px; font-weight: 700; border: none; font-size: 1rem; cursor: pointer; }
.btn-sys-cancel { background-color: #e2e8f0; color: #4a5568; padding: 14px; border-radius: 12px; font-weight: 700; border: none; font-size: 1rem; cursor: pointer; }
.btn-sys-cancel:hover { background-color: #cbd5e0; }

/* Desktop */
@media (min-width: 950px) {
    .container { max-width: 1200px; }
    #app-screen {
        display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; align-items: start;
        grid-template-areas: "header header" "balance actions" "upcoming upcoming" "sec-act sec-stats" "sec-act sec-hist";
    }
    header { grid-area: header; }
    #balance-card { grid-area: balance; }
    #actions-container { grid-area: actions; grid-template-columns: repeat(4, 1fr); margin-bottom: 20px;}
    #upcoming-payments-wrapper { grid-area: upcoming; }
}
@media (max-width: 600px) {
    .actions { grid-template-columns: 1fr; }
    .item-right-group { width: 100%; flex-direction: row; justify-content: space-between; align-items: center; margin-top: 10px; border-top: 1px solid #f0f0f0; padding-top: 10px; }
}


