/* V7 Accounting — style.css */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy:   #1a2744;
    --navy2:  #243259;
    --accent: #2e7d32;
    --accent-light: #43a047;
    --red:    #c62828;
    --amber:  #f57f17;
    --bg:     #f4f6f9;
    --card:   #ffffff;
    --border: #dde1ea;
    --text:   #1c2236;
    --muted:  #6b7280;
    --sidebar-w: 210px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
}

.sidebar-logo {
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo .app-name {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.sidebar-logo .app-sub {
    color: rgba(255,255,255,0.5);
    font-size: 11px;
    margin-top: 2px;
}

.sidebar nav {
    padding: 12px 0;
    flex: 1;
}

.nav-section {
    padding: 16px 18px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 18px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 13.5px;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: rgba(255,255,255,0.07);
    color: #fff;
}

.nav-link.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--accent-light);
}

.nav-link .icon { font-size: 15px; }

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    color: rgba(255,255,255,0.45);
}

.sidebar-footer a {
    color: rgba(255,255,255,0.55);
    text-decoration: none;
}
.sidebar-footer a:hover { color: #fff; }

/* ── Main content ────────────────────────────────────────── */

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.content {
    padding: 24px 28px;
    flex: 1;
}

/* ── Flashes ─────────────────────────────────────────────── */

.flashes { margin-bottom: 16px; }

.flash {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 13.5px;
    font-weight: 500;
}

.flash.success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid #43a047; }
.flash.error   { background: #ffebee; color: #c62828; border-left: 4px solid #ef5350; }
.flash.info    { background: #e3f2fd; color: #1565c0; border-left: 4px solid #42a5f5; }

/* ── Cards ───────────────────────────────────────────────── */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 22px;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

/* ── Stat row ─────────────────────────────────────────────── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px 20px;
}

.stat-card .label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.stat-card .value.positive { color: var(--accent); }
.stat-card .value.negative { color: var(--red); }
.stat-card .value.neutral  { color: var(--navy); }

/* ── Tables ──────────────────────────────────────────────── */

.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg);
    padding: 10px 14px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

thead th.num { text-align: right; }

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: #f8f9fc; }

tbody td {
    padding: 10px 14px;
    font-size: 13.5px;
    vertical-align: middle;
}

tbody td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

tbody td.muted { color: var(--muted); }

/* ── Badges / Status ─────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-pending  { background: #fff8e1; color: #e65100; }
.badge-paid     { background: #e8f5e9; color: #2e7d32; }
.badge-overdue  { background: #ffebee; color: #c62828; }
.badge-void     { background: #f3f4f6; color: #6b7280; }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1;
}

.btn-primary {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}
.btn-primary:hover { background: var(--navy2); }

.btn-success {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-success:hover { background: var(--accent-light); }

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm {
    padding: 5px 12px;
    font-size: 12.5px;
}

.btn-danger {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

/* ── Forms ───────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 5px;
}

input[type=text], input[type=password], input[type=number],
input[type=date], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(26,39,68,0.08);
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.form-hint {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 3px;
}

/* ── Filter bar ──────────────────────────────────────────── */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-bar select, .filter-bar input {
    width: auto;
    min-width: 140px;
}

/* ── Login page ──────────────────────────────────────────── */

.login-wrap {
    width: 100%;
    min-height: 100vh;
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: #fff;
    border-radius: 10px;
    padding: 36px 40px;
    width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.login-box h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 4px;
}

.login-box .sub {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 24px;
}

.login-error {
    background: #ffebee;
    color: var(--red);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13.5px;
    margin-bottom: 16px;
    border-left: 4px solid var(--red);
}

/* ── Setup wizard progress bar ───────────────────────────── */

.setup-progress {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
}

.setup-step {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    background: var(--bg);
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.setup-step.active {
    background: var(--navy);
    color: #fff;
}

/* ── Detail panels ───────────────────────────────────────── */

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.detail-item .label {
    font-size: 11.5px;
    color: var(--muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
}

.detail-item .val {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

/* ── Two-column layout ───────────────────────────────────── */

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

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

/* ── Utility ─────────────────────────────────────────────── */

.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.text-right { text-align: right; }
.text-muted  { color: var(--muted); }
.text-green  { color: var(--accent); }
.text-red    { color: var(--red); }
.text-bold   { font-weight: 600; }

.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 14px;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

/* ── Invoice document view ───────────────────────────────── */

.inv-doc-wrap {
    max-width: 820px;
    margin-bottom: 28px;
}

.inv-doc {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 36px 40px 28px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    font-size: 13px;
    color: #1c2236;
}

/* Header row: logo/company | spacer | Invoice title + date box */
.inv-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.inv-company-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 3px;
}

.inv-company-detail {
    font-size: 12px;
    color: #555;
    line-height: 1.6;
}

.inv-title-block {
    text-align: right;
}

.inv-title-block .inv-word {
    font-size: 34px;
    font-weight: 700;
    color: #1a2744;
    line-height: 1;
    margin-bottom: 10px;
}

.inv-date-table {
    border-collapse: collapse;
    margin-left: auto;
    min-width: 200px;
}

.inv-date-table th {
    background: #2F5496;
    color: #fff;
    font-size: 11px;
    padding: 5px 12px;
    text-align: center;
    text-transform: none;
    letter-spacing: 0;
    border: 1px solid #2F5496;
}

.inv-date-table td {
    font-size: 12px;
    padding: 5px 12px;
    text-align: center;
    border: 1px solid #bbb;
    background: #fff;
    color: #1c2236;
}

/* Billing section */
.inv-billing {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.inv-bill-to {
    border: 1px solid #bbb;
    padding: 10px 12px;
    border-radius: 3px;
    font-size: 12px;
    line-height: 1.7;
}

.inv-bill-to .label {
    font-size: 11px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.inv-claim-table {
    border-collapse: collapse;
    width: 100%;
    align-self: end;
}

.inv-claim-table th {
    background: #2F5496;
    color: #fff;
    font-size: 11px;
    padding: 5px 10px;
    text-align: center;
    border: 1px solid #2F5496;
}

.inv-claim-table td {
    font-size: 12px;
    padding: 5px 10px;
    text-align: center;
    border: 1px solid #bbb;
}

/* Line items */
.inv-items {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    font-size: 12px;
}

.inv-items thead th {
    background: #2F5496;
    color: #fff;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    border: none;
}

.inv-items thead th.r { text-align: right; }
.inv-items thead th.c { text-align: center; }

.inv-items tbody tr:nth-child(odd)  { background: #fff; }
.inv-items tbody tr:nth-child(even) { background: #f2f2f2; }
.inv-items tbody tr { border-bottom: none; }
.inv-items tbody tr:hover { background: #e8eef7; }

.inv-items tbody td {
    padding: 6px 10px;
    font-size: 12px;
    border-right: 1px solid #ddd;
    vertical-align: middle;
}

.inv-items tbody td:last-child { border-right: none; }
.inv-items tbody td.r { text-align: right; }
.inv-items tbody td.c { text-align: center; }

.inv-items-wrap {
    border: 1px solid #bbb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

/* Totals */
.inv-totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.inv-totals table {
    border-collapse: collapse;
    min-width: 260px;
}

.inv-totals td {
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    background: transparent;
}

.inv-totals td:first-child { color: #555; }
.inv-totals td:last-child  { text-align: right; font-weight: 500; }

.inv-totals tr.total-row td {
    border-top: 2px solid #1c2236;
    font-weight: 700;
    font-size: 14px;
    padding-top: 6px;
}

.inv-totals tr.subtotal-sep td { border-top: 1px solid #bbb; }

/* Footer */
.inv-footer {
    border: 1px solid #bbb;
    border-radius: 3px;
    display: grid;
    grid-template-columns: 100px 110px 1fr;
    font-size: 12px;
    overflow: hidden;
}

.inv-footer-cell {
    padding: 6px 10px;
    border-right: 1px solid #bbb;
    text-align: center;
}

.inv-footer-cell:last-child {
    border-right: none;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inv-footer-cell .flabel {
    font-size: 10px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}

/* ── Invoice status form ─────────────────────────────────── */

.status-form {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
}

.status-form h3 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-form .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 140px;
}

/* ── Reconcile / Clear button ────────────────────────────── */

.clr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    font-family: inherit;
}

.clr-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: #e8f5e9;
}

.clr-btn.clr-on {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.clr-btn.clr-on:hover {
    background: var(--red);
    border-color: var(--red);
}

tr.row-cleared td {
    opacity: 0.5;
}

/* ── Account Register split layout ──────────────────────── */

.reg-wrap {
    display: flex;
    min-height: calc(100vh - 61px);
}

.reg-sidebar {
    width: 210px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--card);
    padding: 16px 0;
    overflow-y: auto;
}

.reg-sidebar-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 16px 10px;
}

.reg-sidebar-section {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 16px 4px;
    opacity: 0.7;
}

.reg-acc-link {
    display: block;
    padding: 9px 16px;
    text-decoration: none;
    color: var(--text);
    border-left: 3px solid transparent;
    transition: background 0.1s;
}

.reg-acc-link:hover { background: var(--bg); }

.reg-acc-link.active {
    background: #e8f5e9;
    border-left-color: var(--accent);
}

.reg-acc-link .acc-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.reg-acc-link.active .acc-name { color: var(--accent); }

.reg-acc-link .acc-bal {
    font-size: 11.5px;
    color: var(--muted);
    margin-top: 1px;
}

.reg-acc-link .acc-unc {
    font-size: 10.5px;
    color: var(--amber);
    font-weight: 600;
}

.reg-main {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    min-width: 0;
}

/* ── Mobile hamburger toggle ────────────────────────────── */

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1100;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    font-size: 22px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

/* ── Responsive — phones & tablets ──────────────────────── */

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .mobile-menu-btn { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1000;
        width: 240px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        padding: 0 14px 0 56px;
        height: 52px;
    }

    .topbar h1 { font-size: 15px; }

    .content {
        padding: 16px 14px;
    }

    /* Tables scroll horizontally */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-wrap table {
        min-width: 520px;
    }

    /* Forms stack */
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form .form-group {
        min-width: unset;
    }

    /* Stat cards stack */
    .stat-grid {
        grid-template-columns: 1fr;
    }

    /* Filter bar stacks */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar select, .filter-bar input {
        width: 100%;
        min-width: unset;
    }

    /* Two-col stacks */
    .two-col { grid-template-columns: 1fr; }

    /* Detail grid */
    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Login box */
    .login-box {
        width: calc(100vw - 32px);
        max-width: 360px;
        padding: 28px 24px;
    }

    /* Account register stacks */
    .reg-wrap {
        flex-direction: column;
        min-height: auto;
    }

    .reg-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 12px 0;
    }

    .reg-main {
        padding: 16px 14px;
    }

    /* Invoice doc */
    .inv-doc {
        padding: 20px 16px 16px;
    }

    .inv-header {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .inv-title-block { text-align: left; }
    .inv-date-table { margin-left: 0; }

    .inv-billing {
        grid-template-columns: 1fr;
    }

    .inv-footer {
        grid-template-columns: 1fr;
    }

    .inv-footer-cell {
        border-right: none;
        border-bottom: 1px solid #bbb;
    }

    .inv-footer-cell:last-child {
        border-bottom: none;
    }
}
