:root {
    --ink: #1f2937;
    --muted: #667085;
    --line: #d0d5dd;
    --panel: #ffffff;
    --bg: #f3f6f8;
    --nav: #12343b;
    --accent: #0f766e;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

a {
    color: inherit;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #e7f0ed, #f6f3ec);
}

.login-card {
    width: min(380px, calc(100vw - 32px));
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 18px 50px rgba(18, 52, 59, .12);
}

.login-logo, .logo {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0;
}

.login-logo {
    margin-bottom: 14px;
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 200px 1fr;
}

.sidebar {
    background: var(--nav);
    color: #fff;
    padding: 18px 14px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 4px 4px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .16);
    margin-bottom: 14px;
}

.brand span {
    display: block;
    color: rgba(255, 255, 255, .68);
    font-size: 12px;
    margin-top: 3px;
}

nav a, summary {
    display: block;
    padding: 10px 12px;
    border-radius: 6px;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

nav a:hover, summary:hover {
    background: rgba(255, 255, 255, .12);
}

details a {
    padding-left: 28px;
    color: rgba(255, 255, 255, .86);
}

.content {
    min-width: 0;
}

.topbar {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    font-size: 18px;
    font-weight: 700;
}

.userbar {
    font-size: 13px;
    font-weight: 400;
}

.panel {
    margin: 24px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 14px 18px;
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.grid-5 {
    grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.span-2 {
    grid-column: span 2;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
    font: inherit;
    background: #fff;
}

textarea {
    min-height: 76px;
    resize: vertical;
}

.checks {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
}

.checks label {
    display: flex;
    gap: 6px;
    align-items: center;
    font-weight: 400;
}

.checks input {
    width: auto;
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

button, .btn {
    border: 0;
    border-radius: 6px;
    padding: 9px 14px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-light {
    background: #e6eaee;
    color: var(--ink);
}

.btn-danger {
    background: var(--danger);
}

.action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-small {
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 5px;
    font-size: 12px;
    line-height: 1;
}

.btn-edit {
    background: #2563eb;
}

.btn-delete {
    background: #b42318;
}

.btn-photo {
    background: #7c3aed;
}

.btn-csv {
    background: #16a34a;
}

.btn-excel {
    background: #2563eb;
}

.btn-pdf {
    background: #dc2626;
}
.btn-restore {
    background: #d97706;
}
.btn-restore:hover {
    background: #b45309;
}

.btn-view {
    background: #0f766e;
}
.btn-view:hover {
    background: #115e59;
}

.report-count {
    margin-top: 16px;
    font-size: 15px;
}

.report-table th, .report-table td {
    font-size: 12px;
    padding: 5px 6px;
}

.report-icon {
    width: 30px;
    height: 30px;
    object-fit: cover;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.report-icon-placeholder {
    background: #e6eaee;
    color: #667085;
    font-weight: 700;
    font-size: 14px;
}

.report-summary {
    margin-top: 12px;
    font-size: 15px;
    font-weight: 500;
}

.print-title {
    display: none;
}

.company-head {
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #ccc;
}

.chi-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.chi-addr {
    font-size: 12px;
    color: #444;
    margin-bottom: 1px;
}

.chi-phne {
    font-size: 12px;
    color: #444;
}

.print-report {
    display: none;
}

.pager {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
}

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(17, 24, 39, .42);
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal-backdrop.show {
    display: flex;
}

.modal-box {
    width: min(980px, 100%);
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, .25);
}

.modal-box h2 {
    margin: 0 0 16px;
}

.modal-small {
    width: min(420px, 100%);
}

.receipt {
    max-width: 760px;
    margin: 0 auto;
    color: #111827;
    font-size: 13px;
}

.print-only {
    display: none;
}

.receipt-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
}

.receipt h1 {
    text-align: center;
    font-size: 20px;
    margin: 16px 0 10px;
}

.signature-table th, .signature-table td {
    border-bottom: 0;
    padding: 7px 10px;
}

.signature-table th {
    text-align: center;
    background: #fff;
}

.message {
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: 6px;
    background: #e7f7f3;
    color: #095b52;
}

.inline-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 12px 0 4px;
    align-items: center;
}

.inline-form input, .inline-form select {
    max-width: 260px;
    width: auto;
    flex: 0 1 auto;
}

.org-section {
    margin-top: 24px;
}

.panel h2 {
    margin: 20px 0 4px;
    font-size: 16px;
}

.error {
    background: #fee4e2;
    color: #912018;
}

tr.matched td {
    background: #d8f3dc;
}

.panel-head {
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
    font-size: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: #fff;
}

th, td {
    border-bottom: 1px solid var(--line);
    padding: 9px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f7f9fb;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 14px;
}

.stat {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #fafafa;
}

.stat strong {
    display: block;
    font-size: 26px;
    margin-top: 8px;
}
.stat-c1 { background:#e8f4f8; border-color:#b8dce8; }
.stat-c2 { background:#f0f8e8; border-color:#d0e8b8; }
.stat-c3 { background:#fef3e2; border-color:#f8dbb0; }
.stat-c4 { background:#f5e8fa; border-color:#e0c0e8; }
.stat-c5 { background:#fce8e8; border-color:#f0b8b8; }
.stat-c6 { background:#e8f0f8; border-color:#b8d0e8; }
.stat-c7 { background:#f8f0e0; border-color:#e8d8b0; }
.stat-c8 { background:#e8fce8; border-color:#b8e8b8; }
.stat-c9 { background:#f8e8f0; border-color:#e8b8d0; }
.stat-c10 { background:#fce8e8; border-color:#f0b8b8; }
.stat-c11 { background:#e8f0f8; border-color:#b8d0e8; }
.stat-c12 { background:#f8f0e0; border-color:#e8d8b0; }
.stat-c13 { background:#e8fcf8; border-color:#b8e8e0; }

.dash-title {
    margin: 22px 0 10px;
    font-size: 15px;
    color: var(--muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.dash-title:first-of-type {
    margin-top: 0;
}

.photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.photos img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
}

@media print {
    thead {
        display: table-header-group;
    }
    .no-print {
        display: none !important;
    }
    .printing-transfer .print-hide {
        display: none !important;
    }
    .printing-transfer .print-only {
        display: block !important;
    }
    .print-title {
        display: block;
        text-align: center;
        margin-bottom: 10px;
    }
    .print-title h1 {
        margin: 0 0 4px;
        font-size: 18px;
    }
    .screen-report {
        display: none !important;
    }
    .print-report {
        display: block;
    }
    .group-heading td {
        background: #eef2f6;
        font-weight: 700;
    }
    .group-total td, .grand-total td {
        font-weight: 700;
        border-top: 1px solid #111827;
    }
    .sidebar, .topbar {
        display: none !important;
    }
    .app {
        display: block;
        min-height: 0;
    }
    .content {
        min-height: 0;
    }
    .panel {
        margin: 0;
        border: 0;
        padding: 0;
        page-break-after: avoid;
    }
    html, body {
        height: auto;
        min-height: 0;
    }
    body {
        background: #fff;
        font-size: 12px;
    }
    table {
        margin-top: 10px;
    }
    th, td {
        padding: 5px 7px;
    }
    .receipt {
        max-width: none;
        width: 100%;
    }
    .receipt h2 {
        margin: 0 0 4px;
        font-size: 16px;
    }
    .receipt h1 {
        font-size: 18px;
        margin: 10px 0 6px;
    }
    .receipt p {
        margin: 8px 0;
    }
    .signature-table {
        margin-top: 8px;
    }
}

@media (max-width: 800px) {
    .app {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: static;
    }
    .grid, .grid-4, .grid-5, .stats {
        grid-template-columns: 1fr;
    }
    .span-2 {
        grid-column: auto;
    }
    .topbar {
        padding: 0 14px;
    }
    .panel {
        margin: 14px;
    }
}
