:root {
    --primary: #fce7f3;
    --primary-hover: #fbcfe8;
    --secondary: #e11d48;
    --secondary-hover: #be123c;
    --text-dark: #1f2937;
    --text-muted: #4b5563;
    --white: #ffffff;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --bg-body: #fdf2f8;
}

* { box-sizing: border-box; }

body { 
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; 
    background-color: var(--bg-body); 
    color: var(--text-dark); 
    margin: 0; 
    padding: 0; 
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.65;
}

/* Top Navigation Bar */
.navbar {
    background: var(--white);
    padding: 12px 24px;
    border-bottom: 1px solid var(--primary-hover);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    position: relative;
    z-index: 200;
}

.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.brand-logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-nav {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    align-items: center;
}

.top-nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s;
}

.top-nav a:hover, .top-nav a.active {
    color: var(--secondary);
}

.app-wrapper {
    padding: 20px;
}

.header { text-align: center; margin-bottom: 20px; }
.header h1 { margin: 0; color: var(--secondary); font-size: 30px; }
.header p { color: #4b5563; margin-top: 6px; font-size: 16px; }

.workspace { 
    display: flex; 
    gap: 20px; 
    align-items: stretch; 
    justify-content: space-between; 
    position: relative; 
    max-width: 1200px;
    margin: 0 auto;
}

.block { 
    flex: 1; 
    background: var(--white); 
    border-radius: 12px; 
    padding: 15px; 
    box-shadow: var(--shadow); 
    border-top: 4px solid var(--secondary); 
    height: 68vh; 
    min-height: 440px;
    display: flex; 
    flex-direction: column;
    z-index: 2;
}

.block-title { 
    font-size: 1.1rem; 
    font-weight: bold; 
    margin-bottom: 15px; 
    text-align: center;
    color: var(--text-dark);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.grid-container { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 10px; 
    overflow-y: auto; 
    padding-right: 5px; 
    align-content: start; 
}
#col-payers .grid-container,
#col-bills .grid-container {
    grid-template-columns: 1fr;
}

.grid-container::-webkit-scrollbar { width: 4px; }
.grid-container::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.card { 
    background: var(--primary); 
    border: 1px solid var(--primary-hover); 
    border-radius: 8px; 
    padding: 10px; 
    position: relative; 
    text-align: center; 
    cursor: pointer; 
    transition: all 0.2s; 
    min-height: 80px; 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    word-break: break-word;
}

.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-close { 
    position: absolute; top: 2px; right: 4px; background: none; border: none; 
    font-weight: bold; color: #9ca3af; cursor: pointer; font-size: 12px; padding: 2px;
}
.btn-close:hover { color: var(--secondary); }

.add-card { 
    border: 2px dashed var(--primary-hover); 
    background: transparent; 
    color: #f472b6; 
    font-size: 24px; 
    font-weight: bold; 
    cursor: pointer;
}
.add-card:hover { background: var(--primary); color: var(--secondary); }

.participant-card .note { font-size: 10px; color: #6b7280; font-weight: normal; margin-top: 4px; }

.link-handle { 
    position: absolute; bottom: 5px; right: 5px; width: 28px; height: 28px; 
    background: var(--secondary); color: white; border-radius: 50%; font-size: 14px; 
    display: flex; align-items: center; justify-content: center; cursor: grab; z-index: 10; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    border: 2px solid white;
}

.bill-card-mini {
    display: flex; flex-direction: column; gap: 8px; justify-content: center; align-items: center; text-align: center;
}
.bill-card-mini .bill-title { font-weight: bold; font-size: 14px; }
.bill-card-mini .bill-total-text { color: var(--secondary); font-size: 13px; }

.bill-detail-inputs { margin-bottom: 15px; }
.bill-detail-inputs input { width: 100%; border: 1px solid var(--border); border-radius: 4px; padding: 8px; font-size: 14px; margin-bottom: 8px; outline: none;}
.bill-detail-inputs input:focus { border-color: var(--secondary); }
.shared-by { 
    font-size: 13px; margin-top: 10px; cursor: pointer; color: var(--secondary); font-weight: bold; 
    text-align: center; background: #fdf2f8; border-radius: 6px; padding: 10px; border: 1px solid var(--primary-hover);
}

.paid-by-list { font-size: 13px; background: white; border-radius: 4px; padding: 10px; margin-top: 10px; border: 1px solid var(--border);}
.paid-by-title { font-size: 12px; color: #6b7280; margin-bottom: 8px; font-weight: bold;}
.paid-by-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: normal;}
.paid-by-item > div { display: flex; align-items: center; gap: 8px; }
.paid-by-item input { width: 80px; text-align: right; font-weight: normal; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px;}
.paid-by-item .remove-link { color: #dc2626; cursor: pointer; font-weight: bold; font-size: 16px; display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 4px;}
.paid-by-item .remove-link:hover { background: #fee2e2; }

#svg-layer { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    pointer-events: none; z-index: 100; 
}
.connection-line { stroke: var(--secondary); stroke-width: 3; fill: none; stroke-linecap: round; }
.temp-line { stroke: #9ca3af; stroke-width: 2; stroke-dasharray: 4; fill: none; }

.footer { text-align: center; margin-top: 30px; position: relative; z-index: 10;}
.btn-export { background: var(--text-dark); color: white; font-size: 16px; padding: 12px 35px; border-radius: 25px; cursor: pointer; border: none; box-shadow: var(--shadow); font-weight: bold; transition: background 0.2s;}
.btn-export:hover { background: black; }

#result-section { display: none; margin: 30px auto; max-width: 1200px; background: white; padding: 25px; border-radius: 12px; box-shadow: var(--shadow); border-top: 4px solid var(--text-dark); z-index: 2; position: relative;}
table { width: 100%; border-collapse: collapse; margin-top: 15px; font-size: 14px;}
th, td { border: 1px solid var(--border); padding: 12px; text-align: center; }
th { background: #f9fafb; color: #4b5563; }
td:first-child { text-align: left; font-weight: bold; }
.positive { color: #16a34a; font-weight: bold; }
.negative { color: #dc2626; font-weight: bold; }

.transaction-text { margin-top: 20px; padding: 15px; background: #f9fafb; border-radius: 8px; position: relative; white-space: pre-wrap; line-height: 1.6; font-family: monospace; font-size: 14px;}
.btn-copy { position: absolute; top: 10px; right: 10px; background: white; border: 1px solid var(--border); padding: 5px 10px; border-radius: 4px; font-size: 12px; cursor: pointer; color: #4b5563; font-weight: bold; }
.btn-copy:hover { color: var(--text-dark); border-color: #9ca3af;}

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2000; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal-content { background: white; padding: 25px; border-radius: 12px; width: 350px; max-width: 90%; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }
.modal-content h3 { margin-top: 0; margin-bottom: 15px; color: var(--text-dark); text-align: center; }
.modal-content input, .modal-content textarea, .modal-content select { width: 100%; margin-bottom: 15px; padding: 10px; border: 1px solid #d1d5db; border-radius: 6px; box-sizing: border-box; font-family: inherit; font-size: 14px; outline: none;}
.modal-content input:focus { border-color: var(--secondary); }
.btn { background: var(--secondary); color: white; border: none; padding: 10px 16px; border-radius: 6px; cursor: pointer; font-weight: bold; width: 100%; font-size: 14px; text-decoration: none; display: inline-block; text-align: center;}
.btn:hover { opacity: 0.9; }

.multi-select-list { max-height: 200px; overflow-y: auto; border: 1px solid #d1d5db; border-radius: 6px; padding: 10px; margin-bottom: 15px;}
.multi-select-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f3f4f6;}
.multi-select-item:last-child { border-bottom: none; }
.multi-select-item input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; accent-color: var(--secondary); }
.multi-select-item label { cursor: pointer; flex: 1; font-size: 14px; }

/* SEO & Documentation Container */
.seo-container {
    max-width: 1080px;
    margin: 40px auto 48px;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

.seo-section {
    background: var(--white);
    border: 1px solid var(--primary-hover);
    border-radius: 14px;
    padding: 36px;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
}

.seo-section h2 {
    color: var(--secondary);
    font-size: 23px;
    margin-top: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px;
}

.seo-section h3 {
    color: #9f1239;
    font-size: 18px;
    margin-top: 22px;
    margin-bottom: 8px;
}

.seo-section p, .seo-section li {
    color: #374151;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.feature-card {
    background: #fff1f2;
    border: 1px solid var(--primary-hover);
    border-radius: 10px;
    padding: 20px;
}

.feature-card h3 {
    margin-top: 0;
    color: var(--text-dark);
}

.faq-item {
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-item h3 {
    margin: 0 0 8px 0;
    color: var(--text-dark);
    font-size: 17px;
}

.faq-item p {
    margin: 0;
}

/* Subpage Paper Layout */
.page-container {
    max-width: 920px;
    margin: 40px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
}

.paper-card {
    background: var(--white);
    border: 1px solid var(--primary-hover);
    border-radius: 14px;
    padding: 44px 48px;
    box-shadow: var(--shadow);
}

.paper-card h1 {
    font-size: 30px;
    color: var(--secondary);
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 12px;
}

.paper-card h2 {
    font-size: 21px;
    color: #9f1239;
    margin-top: 28px;
    margin-bottom: 12px;
}

/* Footer */
.site-footer {
    background: #1f2937;
    color: #d1d5db;
    padding: 40px 24px 28px;
    margin-top: auto;
    position: relative;
    z-index: 20;
}

.footer-inner {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
    text-align: center;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.footer-links a {
    color: #f3f4f6;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.footer-links a:hover {
    color: #fb7185;
    text-decoration: underline;
}

.footer-copy {
    font-size: 13px;
    color: #9ca3af;
}

@media (max-width: 992px) {
    .workspace { flex-direction: column; }
    .block { width: 100%; box-sizing: border-box; height: 50vh; }
    .seo-section, .paper-card { padding: 24px 20px; }
}
