* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.hidden {
    display: none !important;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 20px;
    text-align: center;
    position: relative;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    margin-bottom: 15px;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 0.9em;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.header-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.group-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    color: white;
    flex-wrap: wrap;
    font-size: 0.95em;
}

.app-version {
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85em;
}

.group-label {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 999px;
}

.header-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85em;
    transition: all 0.3s;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

main {
    padding: 30px 20px;
}

section {
    margin-bottom: 40px;
}

section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

/* Formulario */
.input-section form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 0.95em;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Botones */
.btn-primary,
.btn-danger {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-danger {
    background: #ff6b6b;
    color: white;
    margin-top: 20px;
}

.btn-danger:hover {
    background: #ff5252;
    transform: translateY(-2px);
}

/* Resumen */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.summary-card .label {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 10px;
}

.summary-card .amount {
    font-size: 2em;
    font-weight: bold;
}

/* Lista de gastos */
.expenses-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.expense-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.expense-info {
    flex: 1;
}

.expense-person {
    font-weight: 600;
    color: #333;
    font-size: 1.1em;
}

.expense-description {
    color: #666;
    font-size: 0.9em;
    margin-top: 4px;
}

.expense-amount {
    font-size: 1.3em;
    font-weight: bold;
    color: #667eea;
}

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

.btn-edit {
    background: #4dabf7;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.3s;
}

.btn-edit:hover {
    background: #339af0;
}

.btn-delete {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.3s;
}

.btn-delete:hover {
    background: #ff5252;
}

/* Settlement */
.settlement-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settlement-item {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    animation: slideIn 0.3s ease-out;
}

.settlement-item.neutral {
    background: #e0e0e0;
    color: #666;
}

.settlement-text {
    font-size: 1.05em;
    font-weight: 600;
}

.settlement-amount {
    font-size: 1.3em;
    font-weight: bold;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 1em;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.hidden {
    display: none;
}

.modal:not(.hidden) {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #f0f0f0;
    background: #f8f9fa;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5em;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #666;
    transition: color 0.3s;
}

.btn-close:hover {
    color: #000;
}

.modal-body {
    padding: 30px 20px;
}

.confirm-message {
    font-size: 1.05em;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.4;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.confirm-actions .btn-secondary,
.confirm-actions .btn-danger {
    width: auto;
    flex: 1;
    margin-top: 0;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.settings-group {
    margin-bottom: 15px;
}

.settings-group label {
    display: block;
    margin-bottom: 10px;
}

.input-with-button {
    display: flex;
    gap: 10px;
}

.input-with-button input {
    flex: 1;
}

.input-with-button button {
    padding: 12px 20px;
    white-space: nowrap;
}

.names-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.name-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.name-input-group label {
    width: 80px;
    margin: 0;
    font-size: 0.9em;
}

.name-input-group input {
    flex: 1;
    margin: 0;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-block {
    width: 100%;
}

.code-input {
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.group-created {
    margin-top: 12px;
    padding: 10px 12px;
    background: #eef1ff;
    border-radius: 8px;
    text-align: center;
    color: #333;
    font-weight: 600;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
    pointer-events: none;
    max-width: 320px;
}

.toast {
    background: #333;
    color: white;
    padding: 12px 16px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    font-size: 0.95em;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: #2f9e44;
}

.toast-error {
    background: #e03131;
}

.toast-info {
    background: #1c7ed6;
}

@media (max-width: 600px) {
    header h1 {
        font-size: 2em;
    }

    .settings-btn {
        padding: 6px 12px;
        font-size: 0.8em;
    }

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

    main {
        padding: 20px 15px;
    }

    section h2 {
        font-size: 1.3em;
    }

    .modal-content {
        width: 95%;
    }

    .toast-container {
        right: 12px;
        left: 12px;
        max-width: none;
    }
}
