* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: #f4f6f2;
    color: #1f2a1f;
}
a { text-decoration: none; color: inherit; }
input, select, button { font-family: inherit; font-size: 16px; }

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(160deg, #2f7d32, #1b4d1e);
}
.auth-card {
    background: #fff;
    width: 100%;
    max-width: 380px;
    border-radius: 16px;
    padding: 28px 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.auth-card h1 { margin: 0 0 4px; font-size: 24px; text-align: center; }
.auth-card .sub { text-align: center; color: #667; margin: 0 0 20px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #445; }
input, select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d7ddd2;
    border-radius: 10px;
    background: #fafcf8;
}
input:focus, select:focus { outline: none; border-color: #2f7d32; }

.btn-primary {
    width: 100%;
    margin-top: 22px;
    padding: 14px;
    background: #2f7d32;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    display: block;
}
.btn-primary:active { background: #256128; }

.alert {
    background: #fde8e8;
    color: #a12a2a;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 8px;
}
.alert.success { background: #e6f4ea; color: #1b4d1e; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #2f7d32;
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-title { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.back-link { color: #fff; font-size: 20px; font-weight: 700; }
.logout-link { font-size: 13px; opacity: 0.9; background: rgba(255,255,255,0.15); padding: 6px 10px; border-radius: 8px; }

.page { padding: 14px 14px 90px; max-width: 560px; margin: 0 auto; }

.summary-row { display: flex; gap: 10px; margin-bottom: 14px; }
.summary-card { flex: 1; background: #fff; border-radius: 12px; padding: 12px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.summary-card small { display: block; color: #778; font-size: 12px; margin-bottom: 4px; }
.summary-card strong { font-size: 17px; }
.summary-card.due strong { color: #c0392b; }
.summary-card.paid strong { color: #1b7a3d; }

.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; }
.search-row button { border: none; background: #2f7d32; color: #fff; border-radius: 10px; padding: 0 16px; }

.filter-row { display: flex; gap: 8px; margin-bottom: 14px; }
.chip { padding: 6px 14px; border-radius: 20px; background: #e9efe4; font-size: 13px; font-weight: 600; color: #445; }
.chip.active { background: #2f7d32; color: #fff; }

.empty-state { text-align: center; padding: 40px 20px; color: #667; }
.empty-state .btn-primary { max-width: 260px; margin: 16px auto 0; }

.entry-list { display: flex; flex-direction: column; gap: 10px; }
.entry-card { background: #fff; border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border-left: 4px solid #c0392b; }
.entry-card.is-paid { border-left-color: #1b7a3d; }
.entry-top { display: flex; justify-content: space-between; gap: 10px; }
.entry-name { font-weight: 700; font-size: 16px; }
.entry-meta { font-size: 12px; color: #778; margin-top: 2px; }
.entry-note { font-size: 12px; color: #99a; margin-top: 2px; font-style: italic; }
.entry-amount { text-align: right; font-weight: 700; font-size: 16px; white-space: nowrap; }
.due-badge { display: block; font-size: 11px; font-weight: 600; color: #c0392b; margin-top: 3px; }
.paid-badge { display: block; font-size: 11px; font-weight: 600; color: #1b7a3d; margin-top: 3px; }

.entry-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.inline-form { display: contents; }
.act-btn { flex: 1; min-width: 80px; text-align: center; padding: 8px 6px; border-radius: 8px; font-size: 13px; font-weight: 600; border: none; cursor: pointer; }
.act-btn.call { background: #e6f0fb; color: #1a5fb4; }
.act-btn.wa { background: #e2f7e5; color: #1b7a3d; }
.act-btn.paid { background: #fff3d6; color: #8a6d00; }
.act-btn.edit { background: #f0f0f0; color: #555; }

.act-btn.delete { background: #fde8e8; color: #a12a2a; }

.entry-form { background: #fff; padding: 16px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 16px; }
.hint { font-size: 12px; color: #889; margin: 6px 0 14px; }

.add-client-btn { margin-bottom: 16px; display: block; text-align: center; }

.client-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.client-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: #2f7d32; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 17px; flex-shrink: 0;
}
.client-avatar.big { width: 56px; height: 56px; font-size: 22px; }
.client-info { flex: 1; min-width: 0; }
.client-name { font-weight: 700; font-size: 15px; }
.client-name.big { font-size: 19px; }
.client-phone { font-size: 12px; color: #778; margin-top: 2px; }
.client-due { text-align: right; }
.no-work { font-size: 11px; color: #99a; }

.client-header-card { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 16px; }
.client-header-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.client-header-card .summary-row { margin-bottom: 12px; }
.client-header-card .entry-actions { margin-top: 0; }

.client-strip { background: #e9efe4; color: #2f5c31; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 8px; margin-bottom: 14px; }

.category-picker { display: flex; gap: 10px; margin-bottom: 18px; }
.category-card {
    flex: 1;
    background: #fff;
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 18px 10px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    color: #1f2a1f;
}
.category-card .cat-icon { display: block; font-size: 30px; margin-bottom: 6px; }
.category-card.khet.selected, .category-card.khet:active { border-color: #2f7d32; background: #eef7ec; }
.category-card.other.selected, .category-card.other:active { border-color: #1a5fb4; background: #eaf2fb; }
.category-picker.small .category-card { padding: 12px 8px; }
.category-picker.small .cat-icon { font-size: 22px; }

.section-title { font-size: 15px; font-weight: 700; margin: 18px 0 10px; color: #2a3a2a; }

.overall-due-card {
    background: #fff3d6;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 600;
    color: #8a6d00;
}
.overall-due-card strong { font-size: 18px; }

.custom-range-row { display: flex; gap: 8px; margin-bottom: 14px; }
.custom-range-row input { flex: 1; }
.custom-range-row button { border: none; background: #2f7d32; color: #fff; border-radius: 10px; padding: 0 14px; font-weight: 600; }

.rate-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.rate-row .rate-name { flex: 2; }
.rate-row .rate-value { flex: 1; }
.rate-row .rate-delete { border: none; background: #fde8e8; color: #a12a2a; border-radius: 8px; padding: 10px 12px; cursor: pointer; }

.payment-btn { background: #1a5fb4; margin-bottom: 16px; }
.payment-btn:active { background: #164d92; }

.mode-picker { display: flex; gap: 10px; margin-top: 6px; }
.mode-option { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; background: #fafcf8; border: 1px solid #d7ddd2; border-radius: 10px; padding: 12px; margin: 0; font-weight: 600; cursor: pointer; }
.mode-option input { width: auto; padding: 0; margin-right: 4px; }
.mode-option:has(input:checked) { border-color: #2f7d32; background: #eef7ec; }

.entry-card.is-debit { border-left-color: #c0392b; }
.entry-card.is-credit { border-left-color: #1b7a3d; }
.entry-amount.debit { color: #c0392b; }
.entry-amount.credit { color: #1b7a3d; }

.creator-tag { font-size: 11px; color: #1a5fb4; font-weight: 600; margin-top: 3px; background: #eaf2fb; display: inline-block; padding: 2px 8px; border-radius: 6px; }

.subuser-password { margin-top: 10px; }
.subuser-password summary { list-style: none; cursor: pointer; }
.subuser-password summary::-webkit-details-marker { display: none; }
.mini-inline-form { display: flex; gap: 8px; margin-top: 8px; }
.mini-inline-form input { flex: 1; }
.btn-primary.small { width: auto; margin-top: 0; padding: 10px 16px; white-space: nowrap; }

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e4e8de;
    display: flex;
    padding: 6px 0;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.bottom-nav a { flex: 1; text-align: center; padding: 6px 0; font-size: 11px; color: #778; }
.bottom-nav a span { display: block; font-size: 20px; }
.bottom-nav a.active { color: #2f7d32; font-weight: 700; }

@media (min-width: 600px) {
    .page { padding-top: 20px; }
}

.kb-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.kb-confirm-box {
    background: #fff;
    border-radius: 14px;
    padding: 22px 20px;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.kb-confirm-msg { margin: 0 0 18px; font-size: 15px; color: #1f2a1f; line-height: 1.4; }
.kb-confirm-actions { display: flex; gap: 10px; }
.kb-confirm-actions button {
    flex: 1;
    padding: 11px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.kb-confirm-cancel { background: #f0f0f0; color: #555; }
.kb-confirm-yes { background: #c0392b; color: #fff; }

.client-row { display: flex; align-items: stretch; gap: 8px; }
.client-row .client-card { flex: 1; min-width: 0; }
.client-delete-form { display: flex; }
.client-delete-btn { border: none; background: #fde8e8; color: #a12a2a; border-radius: 12px; padding: 0 14px; font-size: 18px; cursor: pointer; }
.summary-card.karnal strong { color: #1a5fb4; }
.client-header-card .summary-row { flex-wrap: wrap; }
.client-header-card .summary-card { min-width: calc(50% - 5px); }

.karnal-baki { font-size: 12px; font-weight: 600; color: #c0392b; white-space: nowrap; }
.nav-badge { position: absolute; top: -4px; right: -10px; background: #c0392b; color: #fff; font-style: normal; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; line-height: 16px; border-radius: 8px; text-align: center; padding: 0 4px; }
.bottom-nav a span { position: relative; display: inline-block; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; }

.pay-card { background: #fff; border-radius: 14px; padding: 18px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 14px; }
.pay-card small { color: #778; font-size: 12px; display: block; }
.pay-amount { font-size: 34px; font-weight: 800; color: #1a5fb4; margin: 4px 0; }
.pay-apps { display: flex; flex-wrap: wrap; gap: 8px; }
.pay-apps .act-btn { padding: 14px 6px; font-size: 14px; }
.qr-box { background: #fff; border-radius: 14px; padding: 14px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 12px; }
.qr-box img { max-width: 100%; width: 260px; height: auto; border-radius: 8px; display: block; margin: 0 auto 10px; }
.qr-box .act-btn { display: block; }
.qr-upi { font-size: 13px; color: #556; margin-top: 8px; }
.shot-link { display: block; margin-top: 10px; }
.shot-thumb { max-width: 100%; max-height: 240px; border-radius: 8px; border: 1px solid #e4e8de; display: block; }
input[type=file] { padding: 10px; background: #fff; }
