:root {
    --gold: #C5A059;
    --black: #1A1A1A;
    --surface: #242424;
    --surface-light: #2d2d2d;
    --pearl: #f5f5f5;
    --green: #4caf7d;
    --red: #e05c5c;
    --gray: #888;
    --gray-light: #aaa;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: var(--black);
    color: var(--pearl);
    min-height: 100vh;
    padding-bottom: 70px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    color: var(--gold);
    line-height: 1.3;
}

h1 {
    font-size: 1.8rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.2rem;
}

/* Container - Mobile First */
.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
    width: 100%;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(197, 160, 89, 0.2);
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 8px 0 4px;
    word-break: break-word;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--pearl);
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--black);
    border: 1px solid rgba(197, 160, 89, 0.3);
    border-radius: 12px;
    color: var(--pearl);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    transition: all 0.3s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(197, 160, 89, 0.2);
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 0;
}

.radio-group input[type="radio"] {
    width: auto;
    accent-color: var(--gold);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--gold), #a8843d);
    color: var(--black);
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-family: 'Montserrat', sans-serif;
    width: 100%;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(197, 160, 89, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.85rem;
    width: auto;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold);
}

.btn-outline:hover {
    background: rgba(197, 160, 89, 0.1);
}

.btn-danger {
    background: linear-gradient(135deg, var(--red), #c0392b);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--gold);
    cursor: pointer;
    padding: 8px;
    font-size: 1rem;
    transition: opacity 0.3s;
    border-radius: 8px;
}

.btn-icon:hover {
    opacity: 0.7;
    background: rgba(255,255,255,0.05);
}

.btn-icon.delete {
    color: var(--red);
}

/* Transaction Items */
.txn-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    border-left: 3px solid;
    margin-bottom: 0;
    background: var(--surface-light);
    border-radius: 12px;
    margin-bottom: 8px;
}

.txn-item.jama {
    border-left-color: var(--green);
}

.txn-item.udhar {
    border-left-color: var(--red);
}

.txn-details {
    flex: 1;
    min-width: 0;
}

.txn-details > div {
    margin-bottom: 4px;
}

.txn-amount {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
}

.txn-amount.jama {
    color: var(--green);
}

.txn-amount.udhar {
    color: var(--red);
}

.txn-meta {
    font-size: 0.7rem;
    color: var(--gray);
    margin-top: 4px;
    word-break: break-word;
}

.txn-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-jama {
    background: rgba(76, 175, 125, 0.15);
    color: var(--green);
}

.badge-udhar {
    background: rgba(224, 92, 92, 0.15);
    color: var(--red);
}

/* Reminder Banner */
.reminder-banner {
    background: linear-gradient(135deg, rgba(197, 160, 89, 0.15), rgba(197, 160, 89, 0.08));
    border: 1px solid var(--gold);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.reminder-banner span {
    font-size: 0.85rem;
    flex: 1;
}

.reminder-close {
    color: var(--gold);
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
    padding: 4px;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 500px;
    margin: 0 auto;
    background: var(--surface);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    border-top: 1px solid rgba(197, 160, 89, 0.2);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gray);
    font-size: 0.7rem;
    transition: all 0.3s;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
}

.nav-item i {
    font-size: 1.2rem;
}

.nav-item.active {
    color: var(--gold);
    background: rgba(197, 160, 89, 0.1);
}

.nav-item:hover {
    color: var(--gold);
}

/* Customer List */
.customer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--surface-light);
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.customer-item > a {
    flex: 1;
    text-decoration: none;
    color: inherit;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.customer-info {
    flex: 1;
}

.customer-info h4 {
    color: var(--pearl);
    margin-bottom: 4px;
    font-size: 1rem;
}

.customer-info > div {
    font-size: 0.75rem;
    color: var(--gray);
}

.customer-balance {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.customer-balance.positive {
    color: var(--green);
}

.customer-balance.negative {
    color: var(--red);
}

.customer-actions {
    display: flex;
    gap: 4px;
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar select {
    flex: 1;
    min-width: 100px;
    padding: 10px 12px;
    font-size: 0.85rem;
}

.filter-bar .btn-small {
    width: auto;
    padding: 10px 14px;
}

/* Charts */
.chart-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.chart-label {
    width: 100px;
    font-size: 0.85rem;
    font-weight: 500;
}

.chart-progress {
    flex: 1;
    height: 32px;
    background: var(--black);
    border-radius: 8px;
    overflow: hidden;
}

.chart-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--gold), #a8843d);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: var(--black);
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
    display: block;
}

.link {
    color: var(--gold);
    text-decoration: none;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.link:hover {
    text-decoration: underline;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: 20px;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 20px;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: 24px;
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-card h1 {
    margin-bottom: 8px;
    font-size: 2.2rem;
}

.login-card .subtitle {
    color: var(--gray);
    margin-bottom: 32px;
    font-size: 0.9rem;
}

/* Message Alerts */
.error-message {
    background: rgba(224, 92, 92, 0.15);
    color: var(--red);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.success-message {
    background: rgba(76, 175, 125, 0.15);
    color: var(--green);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Header Bar */
.card-header:first-child {
    margin-top: 0;
}

/* Date Separator */
.date-separator {
    color: var(--gold);
    margin: 16px 0 10px;
    font-weight: 600;
    font-size: 0.85rem;
    padding-left: 8px;
    border-left: 2px solid var(--gold);
}

/* Responsive Breakpoints */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }
    
    .card {
        padding: 16px;
    }
    
    .stats-grid {
        gap: 10px;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .filter-bar select,
    .filter-bar .btn-small {
        width: 100%;
    }
    
    .chart-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .chart-label {
        width: 100%;
        margin-bottom: 4px;
    }
    
    .chart-progress {
        width: 100%;
    }
    
    .customer-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .customer-item > a {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .customer-balance {
        align-self: flex-start;
    }
    
    .customer-actions {
        align-self: flex-end;
        margin-top: -30px;
    }
    
    .txn-item {
        flex-wrap: wrap;
    }
    
    .txn-amount {
        order: 2;
    }
    
    .txn-actions {
        order: 3;
        margin-left: auto;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .radio-group {
        flex-direction: column;
        gap: 10px;
    }
    
    .bottom-nav {
        padding: 8px 0;
    }
    
    .nav-item span {
        font-size: 0.6rem;
    }
    
    .nav-item i {
        font-size: 1rem;
    }
}

/* Landscape mode */
@media (max-height: 600px) and (orientation: landscape) {
    .bottom-nav {
        padding: 6px 0;
    }
    
    .container {
        padding-bottom: 60px;
    }
}

/* Touch-friendly improvements */
button, 
.btn, 
.nav-item,
.customer-item,
.txn-item {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

button:active,
.btn:active,
.nav-item:active {
    transform: scale(0.98);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--black);
}

::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 4px;
}