* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, 'Segoe UI', Arial, sans-serif;
    background: #eef2f7;
    color: #1c2733;
    font-size: 14px;
}

.topbar {
    background: linear-gradient(90deg,#123a75,#1a4d96 55%,#2660b0);
    color: #fff;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-brand { font-weight: 800; font-size: 17px; letter-spacing: 0.3px; }
.topbar-nav a {
    color: #dbe6f7;
    text-decoration: none;
    margin-left: 22px;
    font-size: 13.5px;
    font-weight: 600;
    padding-bottom: 3px;
    border-bottom: 2px solid transparent;
}
.topbar-nav a.active, .topbar-nav a:hover { color: #fff; border-bottom-color: #fff; }

.page-wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px 20px; }

.banner {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 13.5px;
    margin-bottom: 16px;
}
.banner-info { background: #eaf1fb; color: #1a4d96; border: 1px solid #cddcf3; }
.banner-success { background: #e9f7ee; color: #1a7a4a; border: 1px solid #c3e6d0; }
.banner-error { background: #fdeceb; color: #b02a1f; border: 1px solid #f3c6c2; }

.card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #dde4ee;
    padding: 18px 20px;
    margin-bottom: 18px;
}
.card-title {
    font-weight: 800;
    font-size: 13.5px;
    color: #1a4d96;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1.5px solid #eef1f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px 18px;
}
.field { display: flex; flex-direction: column; }
.field label {
    font-size: 11.5px;
    font-weight: 700;
    color: #55647a;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.field input, .field textarea {
    padding: 9px 10px;
    border: 1px solid #cdd7e3;
    border-radius: 5px;
    font-size: 13.5px;
    font-family: inherit;
    width: 100%;
}
.field input:focus, .field textarea:focus, .grid-table input:focus, .grid-table textarea:focus {
    outline: none;
    border-color: #1a4d96;
    box-shadow: 0 0 0 3px rgba(26,77,150,0.12);
}
.disabled-look { background: #f5f7fa; color: #8592a5; font-style: italic; }

.area-row { display: flex; gap: 8px; }
.area-row input:first-child { flex: 2; }
.area-unit { flex: 1; }

textarea { resize: vertical; }
.card > textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #cdd7e3;
    border-radius: 5px;
    font-family: inherit;
    font-size: 13.5px;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* --- Packages grid --- */
.table-scroll { overflow-x: auto; }
.grid-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.grid-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: #55647a;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 8px 8px;
    border-bottom: 2px solid #e3e9f2;
    white-space: nowrap;
}
.grid-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #eef1f6;
    vertical-align: top;
}
.grid-table input, .grid-table textarea {
    width: 100%;
    padding: 7px 8px;
    border: 1px solid #dde4ee;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
}
.grid-table textarea { min-height: 46px; }
.col-rec { width: 34px; text-align: center; }
.col-rec input[type=radio] { width: 16px; height: 16px; cursor: pointer; }
.col-chem { width: 160px; }
.col-rate { width: 100px; }
.col-warranty { width: 90px; }
.col-inclusions { min-width: 260px; }
.col-total { width: 110px; text-align: right; white-space: nowrap; padding-top: 14px; font-weight: 700; color: #1a4d96; }
.col-actions { width: 34px; text-align: center; }

.btn-remove-row {
    background: none;
    border: 1px solid #f0c9c4;
    color: #b02a1f;
    border-radius: 4px;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    margin-top: 4px;
}
.btn-remove-row:hover { background: #fdeceb; }

.btn-small {
    background: #1a4d96;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.btn-small:hover { background: #153f7c; }

.hint { font-size: 12px; color: #8592a5; margin: 10px 0 0 0; }

.required-note { font-weight: 400; text-transform: none; letter-spacing: 0; color: #8592a5; font-size: 10.5px; }

.status-pill {
    display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 12px;
    text-transform: uppercase; letter-spacing: 0.3px;
}
.status-paid { background: #e9f7ee; color: #1a7a4a; }
.status-unpaid { background: #fdf3e6; color: #a3510a; }
.status-none { background: #f0f2f5; color: #8592a5; }

.status-pill-btn {
    display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 12px;
    text-transform: uppercase; letter-spacing: 0.3px; border: none; cursor: pointer; font-family: inherit;
}
.status-pill-btn.status-paid { background: #e9f7ee; color: #1a7a4a; }
.status-pill-btn.status-paid:hover { background: #d5f0dd; }
.status-pill-btn.status-unpaid { background: #fdf3e6; color: #a3510a; }
.status-pill-btn.status-unpaid:hover { background: #fbe8d0; }

/* --- Invoice form: package selection --- */
.pkg-select-list { display: flex; flex-direction: column; gap: 8px; }
.pkg-select-row {
    display: flex; align-items: center; gap: 14px;
    border: 1.5px solid #dde4ee; border-radius: 7px; padding: 12px 14px; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.pkg-select-row:has(input:checked) { border-color: #1a4d96; background: #f5f8fc; }
.pkg-select-row input[type=radio] { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.pkg-select-name { font-weight: 700; font-size: 13.5px; color: #1a2333; min-width: 150px; }
.pkg-select-meta { font-size: 12px; color: #7c8aa0; flex: 1; }
.pkg-select-total { font-weight: 800; font-size: 14px; color: #1a4d96; white-space: nowrap; }

/* --- Invoice form: extra charges --- */
.col-charge-label { width: 60%; }
.col-charge-amount { width: 35%; }

/* --- Invoice form: totals preview --- */
.totals-preview { margin-top: 14px; padding-top: 14px; border-top: 1px solid #eef1f6; max-width: 320px; margin-left: auto; }
.totals-row { display: flex; justify-content: space-between; font-size: 13px; color: #55647a; padding: 4px 0; }
.totals-row b { color: #1a2333; }
.totals-grand { border-top: 1px solid #e3e9f2; margin-top: 6px; padding-top: 8px; font-size: 15px; }
.totals-grand b { color: #1a4d96; font-size: 16px; }

/* --- Invoice form: paid toggle --- */
.paid-toggle-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13.5px; color: #33404f; }
.paid-toggle-row input[type=checkbox] { width: 18px; height: 18px; margin-top: 1px; cursor: pointer; flex-shrink: 0; }

.save-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 0 40px 0;
}
.btn-primary {
    background: #1a4d96;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 12px 28px;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
}
.btn-primary:hover { background: #153f7c; }
.save-hint { font-size: 12.5px; color: #8592a5; }

/* --- History page --- */
.search-bar { display: flex; gap: 10px; margin-bottom: 18px; }
.search-bar input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #cdd7e3;
    border-radius: 6px;
    font-size: 14px;
}
.search-bar button {
    background: #1a4d96;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 18px;
    font-weight: 700;
    cursor: pointer;
}

.history-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #dde4ee; }
.history-table th {
    text-align: left;
    background: #f5f8fc;
    font-size: 11.5px;
    font-weight: 700;
    color: #55647a;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 12px 14px;
    border-bottom: 1px solid #e3e9f2;
}
.history-table td { padding: 12px 14px; border-bottom: 1px solid #eef1f6; font-size: 13.5px; }
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: #fafbfd; }
.qn-badge {
    display: inline-block;
    background: #eaf1fb;
    color: #1a4d96;
    font-weight: 700;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
}
.row-actions a {
    color: #1a4d96;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 600;
    margin-right: 12px;
}
.row-actions a:hover { text-decoration: underline; }
.row-actions a.danger { color: #b02a1f; }
.empty-state { text-align: center; padding: 60px 20px; color: #8592a5; }

@media (max-width: 720px) {
    .field-grid { grid-template-columns: 1fr 1fr; }
    .two-col { grid-template-columns: 1fr; }
}
