/* ===== Kamana & Suraj Expense Tracker ===== */

#ks-expense-tracker {
    max-width: 680px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: #1a1a2e;
}

/* ===== Cards ===== */
.ks-card {
    background: #ffffff;
    border: 1px solid #e8eaf0;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* ===== Balance Card ===== */
.ks-balance-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #eef2ff 100%);
    border-color: #dce3ff;
}

.ks-balance-header {
    text-align: center;
    margin-bottom: 20px;
}

.ks-title {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
}

.ks-subtitle {
    font-size: 13px;
    color: #8891b4;
    letter-spacing: 0.3px;
}

.ks-balance-display {
    display: flex;
    align-items: center;
    gap: 0;
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    border: 1px solid #dce3ff;
}

.ks-balance-item {
    flex: 1;
    text-align: center;
}

.ks-balance-divider {
    width: 1px;
    height: 40px;
    background: #dce3ff;
    margin: 0 16px;
}

.ks-name {
    display: block;
    font-size: 12px;
    color: #8891b4;
    margin-bottom: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ks-amount {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: #1a1a2e;
}

.ks-owed-box {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 10px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    text-align: center;
}

.ks-owed-box p {
    margin: 0;
    font-weight: 600;
    color: #b45309;
    font-size: 15px;
}

.ks-settled-box {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 10px;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    text-align: center;
}

.ks-settled-box p {
    margin: 0;
    font-weight: 600;
    color: #2e7d32;
}

/* ===== Section Headers ===== */
.ks-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.ks-section-title {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
}

.ks-section-header .ks-section-title {
    margin-bottom: 0;
}

.ks-toggle-icon {
    font-size: 12px;
    color: #8891b4;
    transition: transform 0.2s ease;
}

.ks-toggle-icon.collapsed {
    transform: rotate(-90deg);
}

/* ===== Form ===== */
.ks-form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.ks-form-row .ks-field {
    flex: 1;
    margin-bottom: 0;
}

.ks-field {
    margin-bottom: 12px;
}

.ks-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #5c6380;
    margin-bottom: 6px;
}

.ks-optional { color: #aab0cc; font-weight: 400; }
.ks-required { color: #e53935; }

.ks-field input,
.ks-field select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e0e3ef;
    border-radius: 10px;
    font-size: 15px;
    color: #1a1a2e;
    background: #fafbff;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.ks-field input:focus,
.ks-field select:focus {
    border-color: #5c6ef8;
    box-shadow: 0 0 0 3px rgba(92, 110, 248, 0.12);
    background: #fff;
}

/* ===== Toggle group (Paid by) ===== */
.ks-toggle-group {
    display: flex;
    gap: 8px;
}

.ks-toggle {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e3ef;
    border-radius: 10px;
    background: #fafbff;
    color: #8891b4;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ks-toggle:hover {
    border-color: #5c6ef8;
    color: #5c6ef8;
}

.ks-toggle.active {
    background: #5c6ef8;
    border-color: #5c6ef8;
    color: #fff;
    box-shadow: 0 2px 8px rgba(92, 110, 248, 0.3);
}

/* ===== Buttons ===== */
.ks-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
    width: 100%;
    margin-top: 4px;
}

.ks-btn-primary {
    background: #5c6ef8;
    color: #fff;
}

.ks-btn-primary:hover {
    background: #4a5ce6;
    box-shadow: 0 4px 12px rgba(92, 110, 248, 0.35);
}

.ks-btn-primary:disabled {
    background: #aab0e8;
    cursor: not-allowed;
}

.ks-btn-danger {
    background: #fff;
    color: #e53935;
    border: 1.5px solid #ffcdd2;
}

.ks-btn-danger:hover {
    background: #ffebee;
    border-color: #e53935;
    box-shadow: 0 4px 12px rgba(229, 57, 53, 0.15);
}

/* ===== Expense History List ===== */
.ks-history-list {
    margin-top: 16px;
}

.ks-empty-state {
    text-align: center;
    color: #aab0cc;
    font-size: 14px;
    padding: 20px 0;
    margin: 0;
}

.ks-expense-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f2f9;
}

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

.ks-expense-icon {
    font-size: 22px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2ff;
    border-radius: 10px;
    flex-shrink: 0;
}

.ks-expense-info {
    flex: 1;
    min-width: 0;
}

.ks-expense-category {
    font-weight: 600;
    font-size: 14px;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ks-expense-desc {
    font-size: 12px;
    color: #8891b4;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ks-expense-meta {
    text-align: right;
    flex-shrink: 0;
}

.ks-expense-amount {
    font-weight: 700;
    font-size: 15px;
    color: #1a1a2e;
}

.ks-expense-payer {
    font-size: 12px;
    color: #8891b4;
    margin-top: 2px;
}

.ks-expense-date {
    font-size: 11px;
    color: #aab0cc;
    margin-top: 2px;
}

.ks-delete-btn {
    background: none;
    border: none;
    color: #ccc;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

.ks-delete-btn:hover {
    color: #e53935;
    background: #ffebee;
}

/* ===== Settle Card ===== */
.ks-settle-card {
    border-color: #fce4e4;
    background: #fffafa;
}

.ks-settle-desc {
    font-size: 13px;
    color: #8891b4;
    margin: -8px 0 16px;
}

/* ===== Settlement History ===== */
.ks-settlement-item {
    padding: 12px 0;
    border-bottom: 1px solid #f0f2f9;
}

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

.ks-settlement-text {
    font-size: 14px;
    font-weight: 600;
    color: #2e7d32;
}

.ks-settlement-note {
    font-size: 12px;
    color: #8891b4;
    margin-top: 2px;
}

.ks-settlement-date {
    font-size: 11px;
    color: #aab0cc;
    margin-top: 2px;
}

/* ===== Error ===== */
.ks-error {
    font-size: 13px;
    color: #e53935;
    margin: 8px 0 0;
    text-align: center;
}

/* ===== Utility ===== */
.ks-hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .ks-card { padding: 18px; }
    .ks-form-row { flex-direction: column; }
    .ks-balance-display { padding: 14px 12px; }
    .ks-amount { font-size: 18px; }
}
