@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #f0f2f7;
    --surface:      #ffffff;
    --surface2:     #f5f7fc;
    --surface3:     #eaeef8;
    --border:       #e2e8f0;
    --border2:      #cbd5e1;
    --text:         #0f172a;
    --text-mid:     #334155;
    --text-muted:   #64748b;
    --emerald:      #059669;
    --emerald-dim:  #d1fae5;
    --emerald-glow: rgba(5,150,105,0.18);
    --amber:        #d97706;
    --amber-dim:    #fef3c7;
    --rose:         #e11d48;
    --rose-dim:     #ffe4e6;
    --blue:         #2563eb;
    --blue-dim:     #dbeafe;
    --violet:       #7c3aed;
    --violet-dim:   #ede9fe;
    --radius:       16px;
    --radius-sm:    10px;
    --sidebar-w:    240px;
    --shadow-sm:    0 1px 4px rgba(15,23,42,0.08);
    --shadow-md:    0 4px 16px rgba(15,23,42,0.10);
    --shadow-lg:    0 8px 32px rgba(15,23,42,0.12);
}

body {
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    height: 100vh;
    overflow: hidden;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: #1e293b;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid #334155;
    position: relative;
}

.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 14px 12px;
    border-bottom: 1px solid #334155;
    gap: 0;
}

.sidebar-logo-img-wrap {
    width: 100%;
    background: #fff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 8px;
    margin-bottom: 6px;
}

.sidebar-logo-img-wrap img {
    width: 100%;
    height: auto;
    max-height: 46px;
    object-fit: contain;
    border-radius: 6px;
}

.sidebar-logo-sub {
    font-size: 9.5px;
    color: #64748b;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
    text-align: center;
}

.logo-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--emerald), #047857);
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 10px rgba(5,150,105,0.3);
    flex-shrink: 0;
}
.logo-text h1 { font-size: 16px; font-weight: 700; color: #f1f5f9; line-height: 1.1; }
.logo-text p  { font-size: 10.5px; color: #64748b; margin-top: 1px; }

nav {
    padding: 12px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 13px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.18s;
}

.nav-item i { width: 16px; font-size: 13px; opacity: 0.8; }
.nav-item:hover { background: #334155; color: #f1f5f9; }
.nav-item.active {
    background: linear-gradient(135deg, var(--emerald), #047857);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(5,150,105,0.3);
}
.nav-item.active i { opacity: 1; }

.sidebar-footer {
    padding: 12px 16px;
    font-size: 10px;
    color: #475569;
    border-top: 1px solid #334155;
    text-align: center;
}

/* ── Main area ── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

/* ── Topbar ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}
.page-title   { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.4px; }
.page-subtitle{ font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

/* ── Search ── */
.search-wrap { position: relative; }
.search-wrap i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; }
.search-wrap input {
    padding: 9px 14px 9px 34px;
    border-radius: 10px;
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    width: 240px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-wrap input:focus {
    border-color: var(--emerald);
    box-shadow: 0 0 0 3px rgba(5,150,105,0.12);
    background: var(--surface);
}

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 10px 18px; border-radius: 10px;
    font-family: 'DM Sans', sans-serif; font-size: 13.5px; font-weight: 600;
    border: none; cursor: pointer; transition: all 0.2s; text-decoration: none;
}
.btn-emerald { background: linear-gradient(135deg, var(--emerald), #047857); color: #fff; box-shadow: 0 2px 10px var(--emerald-glow); }
.btn-emerald:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 4px 16px var(--emerald-glow); }
.btn-ghost   { background: var(--surface2); border: 1px solid var(--border2); color: var(--text-mid); }
.btn-ghost:hover { background: var(--surface3); }
.btn-whatsapp{ background: linear-gradient(135deg, #25d366, #128c7e); color: #fff; box-shadow: 0 2px 10px rgba(37,211,102,0.2); }
.btn-danger  { background: var(--rose-dim); color: var(--rose); border: 1px solid #fecdd3; }
.btn-danger:hover { background: #fecdd3; }

/* ── Cards (Summary) ── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px;
    cursor: pointer; transition: all 0.2s;
    box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.card::before { content:''; position: absolute; top:0; left:0; right:0; height:3px; border-radius: var(--radius) var(--radius) 0 0; }
.card-profit::before  { background: linear-gradient(90deg, var(--emerald), #10b981); }
.card-hotel::before   { background: linear-gradient(90deg, var(--rose),    #f43f5e); }
.card-trans::before   { background: linear-gradient(90deg, var(--amber),   #f59e0b); }
.card-deposit::before { background: linear-gradient(90deg, var(--blue),    #3b82f6); }
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border2); }
.card-icon  { font-size: 22px; margin-bottom: 10px; display: block; }
.card-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.card-value { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.card-sub   { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

.dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.dot-e { background: var(--emerald); }
.dot-r { background: var(--rose); }
.dot-a { background: var(--amber); }
.dot-b { background: var(--blue); }
.dot-v { background: var(--violet); }

/* ── Stat Cards (Dashboard) ── */
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 22px;
    position: relative; overflow: hidden;
    box-shadow: var(--shadow-sm); transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card::after { content:''; position:absolute; top:0; left:0; right:0; height:3px; border-radius: var(--radius) var(--radius) 0 0; }
.sc-e::after { background: linear-gradient(90deg, var(--emerald), #10b981); }
.sc-b::after { background: linear-gradient(90deg, var(--blue),    #3b82f6); }
.sc-a::after { background: linear-gradient(90deg, var(--amber),   #f59e0b); }
.sc-r::after { background: linear-gradient(90deg, var(--rose),    #f43f5e); }
.sc-v::after { background: linear-gradient(90deg, var(--violet),  #8b5cf6); }
.stat-icon  { font-size: 24px; margin-bottom: 10px; display: block; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.5px; }
.stat-sub   { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* ── Section Cards ── */
.section-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.section-card-header { display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--border); background: var(--surface2); }
.section-card-title  { font-size: 14px; font-weight: 700; color: var(--text); }
.section-card-sub    { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Badges ── */
.ref-badge {
    font-family: 'DM Mono', monospace; font-size: 12px; font-weight: 500;
    background: var(--surface2); border: 1px solid var(--border2);
    padding: 3px 8px; border-radius: 7px; color: var(--text-mid);
}
.type-badge  { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.type-full   { background: var(--emerald-dim); color: var(--emerald); }
.type-deposit{ background: var(--blue-dim);    color: var(--blue); }
.profit-cell { color: var(--emerald); font-weight: 600; }
.no-data     { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── Overlay / Modal ── */
.overlay { display:none; position:fixed; inset:0; background:rgba(15,23,42,0.5); backdrop-filter:blur(4px); z-index:100; align-items:center; justify-content:center; }
.overlay.show { display: flex; }
.modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
    width: min(780px, 95vw); max-height: 88vh; overflow-y: auto;
    animation: popIn 0.28s cubic-bezier(0.34,1.56,0.64,1); box-shadow: var(--shadow-lg);
}
@keyframes popIn { from { opacity:0; transform:scale(0.92); } to { opacity:1; transform:scale(1); } }

.modal-header { display:flex; align-items:flex-start; justify-content:space-between; padding:24px 26px 18px; border-bottom:1px solid var(--border); background:var(--surface2); }
.modal-ref  { font-family:'DM Mono',monospace; font-size:12px; color:var(--emerald); font-weight:500; margin-bottom:3px; }
.modal-name { font-size:18px; font-weight:700; color:var(--text); }
.modal-date { font-size:12px; color:var(--text-muted); margin-top:3px; }

.close-btn {
    background: var(--surface3); border: 1px solid var(--border2); color: var(--text-muted);
    width: 32px; height: 32px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 15px; transition: all 0.2s; flex-shrink: 0;
}
.close-btn:hover { background: var(--rose-dim); color: var(--rose); border-color: #fecdd3; }

.modal-body   { padding: 22px 26px; }
.modal-footer { display:flex; gap:10px; padding:16px 26px 20px; border-top:1px solid var(--border); justify-content:flex-end; flex-wrap:wrap; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.section-title { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:0.8px; color:var(--text-muted); margin-bottom:10px; }

.info-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.info-row  { display:flex; justify-content:space-between; align-items:center; padding:10px 14px; border-bottom:1px solid var(--border); font-size:13px; flex-wrap:wrap; gap:4px; }
.info-row:last-child { border-bottom: none; }
.lbl { color: var(--text-muted); font-size: 12.5px; }
.val { font-weight: 600; color: var(--text); font-size: 13px; }
.mono { font-family: 'DM Mono', monospace; font-size: 12px; }

.copy-btn {
    background: var(--emerald-dim); color: var(--emerald);
    border: none; border-radius: 6px; font-size: 11px; padding: 3px 8px;
    cursor: pointer; font-family: 'DM Sans', sans-serif; font-weight: 600; margin-left: 8px; transition: opacity 0.15s;
}
.copy-btn:hover { opacity: 0.8; }

/* ── Pending Modal ── */
.pending-modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
    width: min(520px, 95vw); max-height: 80vh; display: flex; flex-direction: column;
    animation: popIn 0.28s cubic-bezier(0.34,1.56,0.64,1); box-shadow: var(--shadow-lg); overflow: hidden;
}
.pending-header  { display:flex; align-items:flex-start; justify-content:space-between; padding:22px 24px 16px; border-bottom:1px solid var(--border); background:var(--surface2); }
.pending-title   { font-size:16px; font-weight:700; color:var(--text); }
.pending-subtitle{ font-size:12px; color:var(--text-muted); margin-top:3px; }
.pending-list    { flex:1; overflow-y:auto; }
.pending-item    { display:flex; align-items:center; justify-content:space-between; padding:14px 22px; border-bottom:1px solid var(--border); cursor:pointer; transition:background 0.15s; gap:10px; }
.pending-item:hover { background: rgba(5,150,105,0.04); }
.pending-item:last-child { border-bottom: none; }
.pi-ref  { font-family:'DM Mono',monospace; font-size:11px; color:var(--emerald); font-weight:500; }
.pi-name { font-size:13.5px; font-weight:600; color:var(--text); margin:2px 0; }
.pi-date { font-size:11.5px; color:var(--text-muted); }
.pi-right{ text-align:right; flex-shrink:0; }
.pi-amt  { font-size:16px; font-weight:700; margin-bottom:3px; }
.pi-lbl  { font-size:11px; color:var(--text-muted); }
.pi-amt.r { color: var(--rose); }
.pi-amt.a { color: var(--amber); }
.pi-amt.b { color: var(--blue); }
.pending-footer  { border-top:1px solid var(--border); }
.pending-total   { display:flex; justify-content:space-between; align-items:center; padding:16px 22px; }
.pt-label{ font-size:13px; color:var(--text-muted); font-weight:600; }
.pt-value{ font-size:20px; font-weight:700; }

/* ── Toast ── */
.toast {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
    background: #1e293b; color: #f1f5f9; padding: 12px 22px; border-radius: 12px;
    font-size: 13.5px; font-weight: 500; z-index: 9999; pointer-events: none;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    box-shadow: var(--shadow-lg); white-space: nowrap;
}
@keyframes toastIn  { from { opacity:0; transform:translateX(-50%) translateY(12px); } to { opacity:1; transform:translateX(-50%) translateY(0); } }
@keyframes toastOut { to   { opacity:0; transform:translateX(-50%) translateY(8px); } }

/* ── Form inputs ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size:12px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:0.5px; }
.form-input, .form-select {
    padding: 11px 14px; border: 1.5px solid var(--border2); border-radius: 10px;
    background: var(--surface); color: var(--text);
    font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s; width: 100%;
}
.form-input:focus, .form-select:focus { border-color: var(--emerald); box-shadow: 0 0 0 3px rgba(5,150,105,0.1); }
.form-input[readonly] { background: var(--surface2); color: var(--text-muted); cursor: default; }
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer;
}

/* ── Animations ── */
@keyframes float { 0%,100% { transform:translateY(0); } 50% { transform:translateY(-7px); } }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

/* ── Instalment cards ── */
.inst-section { margin-top: 20px; }
.inst-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-top: 10px; }
.inst-card { background:var(--surface2); border:1px solid var(--amber-dim); border-radius:var(--radius-sm); padding:14px; text-align:center; }
.inst-num  { font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:0.7px; color:var(--amber); }
.inst-due  { font-size:12px; color:var(--text-muted); margin:5px 0; }
.inst-amt  { font-size:16px; font-weight:700; color:var(--text); }

/* ── MOBILE RESPONSIVE ── */
@media (max-width: 900px) {
    body { overflow: auto; }

    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; z-index: 300;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
        box-shadow: var(--shadow-lg);
        width: 260px;
    }
    .sidebar.open { transform: translateX(0); }

    .app { height: auto; min-height: 100vh; overflow: auto; }
    .main { height: auto; overflow: visible; }

    .topbar { padding: 14px 16px; }
    .page-title { font-size: 17px; }
    .page-subtitle { display: none; }

    .info-grid { grid-template-columns: 1fr; }

    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn { flex: 1 1 calc(50% - 8px); justify-content: center; font-size: 12px; padding: 9px 10px; }

    /* Form grids collapse on mobile */
    .form-grid-2,
    .form-grid-3,
    .form-grid-4 { grid-template-columns: 1fr 1fr; }

    .col-span-2,
    .col-span-3,
    .col-span-full { grid-column: 1/-1; }

    .inst-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
    .form-grid-2,
    .form-grid-3,
    .form-grid-4 { grid-template-columns: 1fr; }

    .form-scroll { padding: 12px 14px 30px; }
    .form-card { padding: 16px; }

    .topbar { padding: 12px 14px; gap: 8px; }
    .page-title { font-size: 15px; }

    .modal { width: 98vw; border-radius: 14px; }
    .modal-header { padding: 16px; }
    .modal-body { padding: 14px; }
    .modal-footer { padding: 12px 14px; }

    .pending-modal { width: 98vw; border-radius: 14px; }
    .pending-item { padding: 12px 14px; }

    .inst-grid { grid-template-columns: 1fr 1fr; }

    .card-value { font-size: 18px; }
    .card-icon { font-size: 18px; margin-bottom: 6px; }
    .card { padding: 12px 14px; }
}