:root {
    --eco-blue: #003057;
    --eco-red: #e30613;
    --border: #999;
    --border-light: #ddd;
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --muted: #6b7280;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ---------------- Header ---------------- */
.app-header {
    background: var(--eco-blue);
    color: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.app-header .brand {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: .5px;
}
.app-header .brand span { color: var(--eco-red); }
.app-header .subtitle {
    font-size: 13px;
    opacity: .85;
    margin-top: 2px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ---------------- Cards ---------------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    padding: 20px;
    margin-bottom: 20px;
}
.card h2 {
    margin: 0 0 14px;
    font-size: 16px;
    color: var(--eco-blue);
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ---------------- Partner bar ---------------- */
.partner-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}
input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    padding: 9px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--eco-blue);
    outline-offset: 1px;
}

button {
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: filter .15s;
}
button:hover { filter: brightness(0.92); }
.btn-primary { background: var(--eco-blue); color: #fff; }
.btn-danger { background: var(--eco-red); color: #fff; }
.btn-secondary { background: #e5e7eb; color: #111; }
.btn-outline { background: #fff; border: 1px solid var(--border-light); color: var(--eco-blue); }
button:disabled { opacity: .5; cursor: not-allowed; }

.pill {
    display: inline-block;
    background: #eef2ff;
    color: var(--eco-blue);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

/* ---------------- Entry form grid ---------------- */
.entry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}
.entry-grid .full { grid-column: 1 / -1; }

.capture-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 16px;
}
@media (max-width: 700px) {
    .capture-row { grid-template-columns: 1fr; }
}

.capture-box {
    border: 1px dashed var(--border-light);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
}
.capture-box h3 {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
}

/* --- ID photo capture --- */
#idPhotoPreview {
    max-width: 100%;
    max-height: 180px;
    border-radius: 6px;
    display: none;
    margin: 0 auto 10px;
}
#idCameraVideo {
    width: 100%;
    max-height: 220px;
    border-radius: 6px;
    background: #000;
    display: none;
}
.capture-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* --- Signature pad --- */
#signaturePad {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    width: 100%;
    height: 180px;
    touch-action: none;
    background: #fff;
    cursor: crosshair;
}

/* ---------------- Records table (screen) ---------------- */
.table-wrap { overflow-x: auto; }
table.records {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 1100px;
}
table.records th, table.records td {
    border: 1px solid var(--border-light);
    padding: 8px 10px;
    text-align: left;
    white-space: nowrap;
}
table.records thead th {
    background: #f1f5f9;
    color: var(--eco-blue);
    position: sticky;
    top: 0;
}
table.records tbody tr:nth-child(even) { background: #fafbfc; }
table.records img.thumb {
    width: 42px;
    height: 42px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}
table.records img.thumb.sig {
    width: 70px;
    height: 34px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--border-light);
}
.no-data { color: var(--muted); font-style: italic; }
.type-cash_in { color: #067647; font-weight: 700; }
.type-registered_cash_out { color: #b54708; font-weight: 700; }
.type-unregistered_cash_out { color: var(--eco-red); font-weight: 700; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}
.toolbar .filters {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 18px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    z-index: 999;
    animation: fadeIn .2s ease;
}
.toast.success { background: #067647; }
.toast.error { background: var(--eco-red); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px);} to {opacity:1; transform:translateY(0);} }

/* ---------------- Print-only sheet (replicates the paper form) ---------------- */
.print-sheet { display: none; }

@media print {
    body * { visibility: hidden; }
    .print-sheet, .print-sheet * { visibility: visible; }
    .print-sheet {
        display: block;
        position: absolute;
        top: 0; left: 0;
        width: 100%;
    }
    @page { size: landscape; margin: 10mm; }
}

.print-sheet {
    background: #fff;
    padding: 10px;
}
.print-sheet .sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 3px solid var(--eco-blue);
    padding-bottom: 8px;
    margin-bottom: 10px;
}
.print-sheet .sheet-header .logo {
    font-size: 26px;
    font-weight: 800;
    color: var(--eco-blue);
}
.print-sheet .sheet-header .logo span { color: var(--eco-red); }
.print-sheet .sheet-header .form-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .5px;
}
.print-sheet .meta-line {
    font-size: 12px;
    margin-bottom: 10px;
}
.print-sheet .meta-line b { margin-right: 30px; }

table.print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    table-layout: fixed;
}
table.print-table th, table.print-table td {
    border: 1px solid #000;
    padding: 4px 5px;
    text-align: left;
    word-break: break-word;
    height: 26px;
}
table.print-table thead th {
    text-align: center;
    font-size: 9px;
    background: #eee;
}
table.print-table img.sig-img { max-height: 20px; max-width: 90%; }
table.print-table img.id-img { max-height: 22px; max-width: 90%; }

.helper-text {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}

.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-backdrop.open { display: flex; }
.modal-backdrop img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 6px;
}
