.page {
    max-width: 1480px;
    margin: auto;
    padding: 30px;
}

.document-page .page-head {
    margin-bottom: 22px;
}

.document-page .page-head h1 {
    color: #17211e;
    font-size: 28px;
    letter-spacing: -.025em;
}

.document-page .page-head p {
    font-size: 13px;
}

.create-document {
    align-items: center;
    display: inline-flex;
    gap: 7px;
    min-height: 40px;
    padding: 9px 17px;
}

.create-document span {
    font-size: 17px;
    font-weight: 400;
    line-height: 1;
}

.document-metrics {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.document-metrics.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.document-metric {
    background: #fff;
    border: 1px solid #e2e7e5;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(18, 38, 32, .04);
    min-width: 0;
    overflow: hidden;
    padding: 17px 18px 15px;
    position: relative;
}

.document-metric::before {
    background: #0b8f6a;
    content: "";
    height: 3px;
    inset: 0 0 auto;
    position: absolute;
}

.document-metric.blue::before { background: #5c6ac4; }
.document-metric.purple::before { background: #8b5cf6; }
.document-metric.amber::before { background: #d18b00; }

.document-metric > span {
    color: #68736f;
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    margin-bottom: 9px;
    text-transform: uppercase;
}

.document-metric strong {
    color: #16231f;
    display: block;
    font-size: 21px;
    letter-spacing: -.02em;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-metric small {
    color: #7b8581;
    display: block;
    font-size: 11px;
    margin-top: 7px;
}

.document-card {
    border-color: #dce3e0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(24, 42, 36, .06);
}

.document-toolbar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #e5e9e7;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    padding: 14px 16px;
}

.document-search {
    align-items: center;
    display: flex;
    max-width: 420px;
    position: relative;
    width: 100%;
}

.document-search > span {
    color: #77817d;
    font-size: 19px;
    left: 12px;
    pointer-events: none;
    position: absolute;
}

.document-search input {
    background: #fafbfb;
    border-color: #d8dedb;
    padding-left: 37px;
    width: 100%;
}

.document-toolbar .table-filter {
    background-color: #fafbfb;
    min-width: 145px;
}

.document-table {
    table-layout: auto;
}

.document-table th {
    background: #f7f8f8;
    color: #66716d;
    font-size: 10px;
    letter-spacing: .075em;
    padding: 11px 18px;
    text-transform: uppercase;
    white-space: nowrap;
}

.document-table td {
    color: #29332f;
    padding: 16px 18px;
    vertical-align: middle;
}

.document-table tbody tr {
    transition: background-color .15s ease;
}

.document-table tbody tr:hover {
    background: #f9fbfa;
}

.document-table .money,
.doc-amount,
.doc-balance,
.settlement-line b {
    white-space: nowrap;
}

.doc-number,
.doc-party {
    color: #17211e;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
}

.doc-date,
.doc-gstin,
.doc-subamount,
.document-table td > small {
    color: #7a8581;
    display: block;
    font-size: 10px;
    line-height: 1.4;
    margin-top: 4px;
}

.doc-gstin {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .02em;
}

.document-table .badge {
    gap: 6px;
    padding: 5px 9px;
    text-transform: capitalize;
}

.document-table .badge i {
    background: currentColor;
    border-radius: 50%;
    display: inline-block;
    height: 5px;
    opacity: .75;
    width: 5px;
}

.doc-amount,
.doc-balance {
    color: #17211e;
    font-size: 13px;
    font-weight: 750;
}

.doc-balance.due { color: #a36500; }
.doc-balance.settled { color: #087f5b; }

.settlement-line {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.settlement-line + .settlement-line {
    margin-top: 5px;
}

.settlement-line span {
    color: #7a8581;
    font-size: 9px;
    text-transform: uppercase;
}

.settlement-line b {
    font-size: 11px;
}

.settlement-line.credit b { color: #6d4bd1; }

.actions-heading {
    text-align: center;
}

.doc-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    min-width: 154px;
}

.doc-action {
    align-items: center;
    background: #fff;
    border: 1px solid #d6ddda;
    border-radius: 8px;
    color: #4d5a55;
    cursor: pointer;
    display: inline-flex;
    height: 34px;
    justify-content: center;
    padding: 0;
    text-decoration: none;
    transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease;
    width: 34px;
}

.doc-action svg {
    fill: none;
    height: 16px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 16px;
}

.doc-action:hover {
    background: #eef7f4;
    border-color: #a9c9bf;
    color: #007a5b;
    transform: translateY(-1px);
}

.doc-action.pdf {
    background: #edf7f4;
    border-color: #c7e4dc;
    color: #007a5b;
}

.doc-action.delete:hover {
    background: #fff1ef;
    border-color: #efb8ae;
    color: #c43218;
}

@media (max-width: 1050px) {
    .document-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .document-table th,
    .document-table td { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 900px) {
    .page { padding: 20px; }
}

@media (max-width: 760px) {
    .document-page .page-head { align-items: stretch; flex-direction: column; }
    .document-page .head-actions,
    .create-document { width: 100%; }
    .create-document { justify-content: center; }
    .document-metrics,
    .document-metrics.three { grid-template-columns: 1fr 1fr; }
    .document-toolbar { align-items: stretch; flex-direction: column; }
    .document-search,
    .document-toolbar .table-filter { max-width: none; width: 100%; }
    .document-card { background: transparent; border: 0; box-shadow: none; overflow: visible; }
    .document-card .table-wrap { overflow: visible; }
    .document-table,
    .document-table tbody,
    .document-table tr,
    .document-table td { display: block; width: 100%; }
    .document-table thead { display: none; }
    .document-table tbody { display: grid; gap: 12px; padding-top: 12px; }
    .document-table tbody tr { background: #fff; border: 1px solid #dfe5e2; border-radius: 11px; box-shadow: 0 2px 7px rgba(24,42,36,.05); display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }
    .document-table td { border: 0; padding: 12px 14px; text-align: left; }
    .document-table td::before { color: #85908c; content: attr(data-label); display: block; font-size: 9px; font-weight: 700; letter-spacing: .07em; margin-bottom: 5px; text-transform: uppercase; }
    .document-table td[data-label="Invoice"],
    .document-table td[data-label="Customer"] { border-bottom: 1px solid #edf0ef; }
    .document-table td[data-label="Actions"] { background: #fafbfb; border-top: 1px solid #edf0ef; grid-column: 1 / -1; }
    .settlement-line { justify-content: flex-start; }
    .doc-actions { justify-content: flex-start; }
}

.pagination {
    align-items: center;
    border-top: 1px solid #e5e9e7;
    display: flex;
    gap: 14px;
    justify-content: flex-end;
    padding: 14px 18px;
}
.pagination span { color: #6d7773; font-size: 12px; }
.pagination .btn:disabled { cursor: not-allowed; opacity: .45; }

@media (max-width: 480px) {
    .document-metrics,
    .document-metrics.three { grid-template-columns: 1fr; }
}

/* CA report period controls use predictable selects instead of native date popovers. */
.report-controls {
    align-items: end;
    background: #fff;
    border: 1px solid #e1e6e4;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(24, 42, 36, .05);
    flex-wrap: wrap;
    padding: 16px;
}

.report-controls label {
    color: #34423d;
    font-size: 12px;
    gap: 6px;
}

.report-controls select {
    min-height: 42px;
}

.report-period-fields {
    align-items: end;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(135px, 1fr) 92px;
}

.report-period-fields label { margin: 0; }

@media (max-width: 700px) {
    .report-controls,
    .report-period-fields { display: grid; grid-template-columns: 1fr; }
    .report-controls > label,
    .report-controls > button { max-width: none; width: 100%; }
}
