/* ==========================================================================
   Speedy Admin — Accounting module
   Chart-of-accounts hierarchy, journal-entry line editor and reports
   (trial balance, balance sheet, P&L, VAT return, ledger cards).
   Tables build on .table-wrap/.data-table; editor inputs mirror the
   invoice items-editor (seamless cells, chrome on hover/focus).
   ========================================================================== */

/* ---------- Chart of accounts ---------- */

.acc-group-row td {
    background: var(--surface-2);
    font-weight: 600;
}

.acc-code-l1 { font-weight: 700; }
.acc-code-l2 { font-weight: 600; padding-left: 14px; }
.acc-code-l3 { padding-left: 28px; }
.acc-code-l4 { padding-left: 28px; }

/* ---------- Journal-entry view (read-only lines) ---------- */

.acc-view-lines { margin-top: 18px; }

.acc-lines-table tfoot td {
    padding: 11px 14px;
    border-top: 2px solid var(--border-strong);
    background: var(--surface-2);
    font-variant-numeric: tabular-nums;
}
.acc-lines-table tfoot .badge { margin-left: 8px; }

/* ---------- Journal-entry line editor ---------- */

.acc-lines-editor { margin-bottom: 4px; overflow: hidden; }

.acc-lines-editor .data-table td { padding: 4px 6px; }

/* Column widths: account | description | debit | credit | vat | base | × */
.acc-lines-editor .data-table th:nth-child(1) { width: 26%; }
.acc-lines-editor .data-table th:nth-child(3),
.acc-lines-editor .data-table th:nth-child(4),
.acc-lines-editor .data-table th:nth-child(6) { width: 96px; }
.acc-lines-editor .data-table th:nth-child(5) { width: 88px; }
.acc-lines-editor .data-table th:nth-child(7) { width: 40px; }

.acc-lines-editor input,
.acc-lines-editor select {
    width: 100%;
    padding: 7px 9px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.45;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.acc-lines-editor input::placeholder { color: var(--text-3); }
.acc-lines-editor input:hover,
.acc-lines-editor select:hover { border-color: var(--border-strong); }
.acc-lines-editor input:focus,
.acc-lines-editor select:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.acc-lines-editor select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
    cursor: pointer;
}

.acc-lines-editor input[type="number"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
    appearance: textfield;
    -moz-appearance: textfield;
}
.acc-lines-editor input[type="number"]::-webkit-inner-spin-button,
.acc-lines-editor input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.acc-form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 10px 0 16px;
}

.acc-totals {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--text-2);
}

.acc-totals strong {
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

/* ---------- Reports ---------- */

.acc-report-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.acc-report-head h3 {
    margin: 0;
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.acc-report-table td.cell-num,
.acc-report-table th.cell-num { white-space: nowrap; }

.acc-report-table tfoot td {
    padding: 11px 14px;
    border-top: 2px solid var(--border-strong);
    background: var(--surface-2);
    font-variant-numeric: tabular-nums;
}

/* Empty-state used as a table cell must stay a table cell */
.acc-report-table td.empty-state,
.acc-lines-table td.empty-state {
    display: table-cell;
    text-align: center;
    padding: 32px 20px;
}

/* Balance sheet & P&L: two columns side by side */
.acc-balance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

.acc-balance-col {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.acc-balance-col h4 {
    margin: 0;
    padding: 12px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-3);
}

@media (max-width: 900px) {
    .acc-balance-grid { grid-template-columns: 1fr; }
}

/* P&L result line */
.acc-result-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding: 13px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 14.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.acc-result-line.positive {
    background: var(--success-soft);
    color: var(--success);
    border-color: transparent;
}

.acc-result-line.negative {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: transparent;
}

/* VAT return summary */
.acc-vat-summary {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
    margin-left: auto;
    width: 340px;
    max-width: 100%;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    font-size: 13.5px;
}

.acc-vat-summary > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.acc-vat-summary strong {
    font-variant-numeric: tabular-nums;
}

.acc-vat-balance {
    border-top: 2px solid var(--border-strong);
    padding-top: 9px;
    margin-top: 4px;
    font-size: 14.5px;
    font-weight: 800;
}
