/* ═══════════════════════════════════════════════════════════════════
   KasaBill – Accounting Module Stylesheet
   Premium design tokens & component styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
    --acc-primary: #6366f1;
    --acc-primary-light: #818cf8;
    --acc-primary-dark: #4f46e5;
    --acc-success: #10b981;
    --acc-danger: #ef4444;
    --acc-warning: #f59e0b;
    --acc-info: #3b82f6;
    --acc-purple: #8b5cf6;
    --acc-surface: #ffffff;
    --acc-bg: #f8fafc;
    --acc-border: #e5e7eb;
    --acc-text: #0f172a;
    --acc-text-muted: #64748b;
    --acc-radius: 12px;
    --acc-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --acc-shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.08);
}

/* ── Module Container ── */
.acc-container {
    padding: 0 20px 40px;
    background: var(--acc-bg);
    min-height: 100vh;
}

/* ── KPI Stat Cards ── */
.acc-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.acc-stat-card {
    background: var(--acc-surface);
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius);
    padding: 20px;
    transition: all 0.2s;
}

.acc-stat-card:hover {
    box-shadow: var(--acc-shadow-hover);
    transform: translateY(-2px);
}

.acc-stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--acc-text-muted);
    margin-bottom: 4px;
}

.acc-stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--acc-text);
    font-variant-numeric: tabular-nums;
}

.acc-stat-value.positive {
    color: var(--acc-success);
}

.acc-stat-value.negative {
    color: var(--acc-danger);
}

/* ── Data Tables ── */
.acc-table-wrap {
    background: var(--acc-surface);
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius);
    overflow: hidden;
}

.acc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.acc-table thead {
    background: #f9fafb;
}

.acc-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--acc-text-muted);
    border-bottom: 1px solid var(--acc-border);
}

.acc-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--acc-text);
}

.acc-table tr:hover {
    background: #f8fafc;
}

.acc-table .amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.acc-table .debit {
    color: var(--acc-info);
}

.acc-table .credit {
    color: var(--acc-success);
}

/* ── Status Badges ── */
.acc-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.acc-badge-draft {
    background: #f1f5f9;
    color: #64748b;
}

.acc-badge-sent {
    background: #dbeafe;
    color: #2563eb;
}

.acc-badge-partial {
    background: #fef3c7;
    color: #d97706;
}

.acc-badge-paid {
    background: #dcfce7;
    color: #16a34a;
}

.acc-badge-overdue {
    background: #fee2e2;
    color: #dc2626;
}

.acc-badge-cancelled {
    background: #f1f5f9;
    color: #94a3b8;
}

.acc-badge-approved {
    background: #ddd6fe;
    color: #7c3aed;
}

/* ── Buttons ── */
.acc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.acc-btn-primary {
    background: linear-gradient(135deg, var(--acc-primary), var(--acc-purple));
    color: #fff;
}

.acc-btn-primary:hover {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.acc-btn-outline {
    background: var(--acc-surface);
    border: 1px solid var(--acc-border);
    color: var(--acc-text);
}

.acc-btn-outline:hover {
    background: #f8fafc;
    border-color: #d1d5db;
}

.acc-btn-success {
    background: var(--acc-success);
    color: #fff;
}

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

/* ── Quick Links ── */
.acc-quick-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 16px 0;
    border-bottom: 1px solid var(--acc-border);
    margin-bottom: 24px;
}

.acc-quick-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--acc-surface);
    border: 1px solid var(--acc-border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--acc-text);
    text-decoration: none;
    transition: all 0.2s;
}

.acc-quick-link:hover {
    background: #f8fafc;
    box-shadow: var(--acc-shadow);
    transform: translateY(-1px);
    color: var(--acc-primary);
    text-decoration: none;
}

/* ── Chart Containers ── */
.acc-chart-card {
    background: var(--acc-surface);
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius);
    padding: 20px;
}

.acc-chart-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--acc-text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Invoice / Bill Detail ── */
.acc-doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.acc-doc-number {
    font-size: 22px;
    font-weight: 800;
    color: var(--acc-primary);
}

.acc-doc-meta {
    font-size: 12px;
    color: var(--acc-text-muted);
}

.acc-doc-total {
    font-size: 28px;
    font-weight: 800;
    color: var(--acc-text);
    text-align: right;
}

.acc-doc-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Ledger / Journal ── */
.acc-journal-entry {
    border-left: 3px solid var(--acc-primary);
    padding-left: 12px;
    margin-bottom: 12px;
}

.acc-account-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #eff6ff;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--acc-info);
}

/* ── Filter Tabs ── */
.acc-filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.acc-filter-tab {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--acc-border);
    background: var(--acc-surface);
    color: var(--acc-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.acc-filter-tab:hover {
    background: #f8fafc;
}

.acc-filter-tab.active {
    background: linear-gradient(135deg, var(--acc-primary), var(--acc-purple));
    color: #fff;
    border-color: transparent;
}

/* ══════════════════════════════════════════════════════════════════
   KasaBill shared page chrome — every KasaBill child page uses these
   ══════════════════════════════════════════════════════════════════ */

/* Page header bar: white card, thin ring, title left / actions right */
.acc-page-head {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.acc-page-head-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.acc-page-head-text { min-width: 0; }
.acc-page-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.2;
}
.acc-page-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    border-radius: 10px;
    font-size: 18px;
    flex-shrink: 0;
}
.acc-page-subtitle {
    margin: 4px 0 0 46px;
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}
.acc-page-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.acc-page-head-actions .btn,
.acc-page-head-actions button,
.acc-page-head-actions .acc-btn {
    font-size: 13px;
}

/* Primary / secondary buttons used in header + toolbars */
.acc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1.2;
}
.acc-btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.25);
}
.acc-btn-primary:hover { transform: translateY(-1px); color: #fff; text-decoration: none; box-shadow: 0 4px 10px rgba(99, 102, 241, 0.35); }
.acc-btn-ghost {
    background: #fff;
    color: #4f46e5;
    border-color: #c7d2fe;
}
.acc-btn-ghost:hover { background: #eef2ff; color: #3730a3; text-decoration: none; }
.acc-btn-neutral {
    background: #fff;
    color: #374151;
    border-color: #e5e7eb;
}
.acc-btn-neutral:hover { background: #f9fafb; color: #111827; text-decoration: none; }

/* Shared table card — white rounded container with clean table */
.acc-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    margin-bottom: 18px;
}
.acc-card-head {
    padding: 14px 20px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.acc-card-body { padding: 16px 20px; }
.acc-card-body-flush { padding: 0; }

.acc-data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.acc-data-table thead th {
    background: #f8fafc;
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}
.acc-data-table tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}
.acc-data-table tbody tr:last-child td { border-bottom: none; }
.acc-data-table tbody tr:hover td { background: #fafbff; }
.acc-data-table tfoot td {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 2px solid #e5e7eb;
    font-weight: 700;
    color: #0f172a;
}
.acc-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-muted { color: #94a3b8; }
.acc-empty {
    padding: 56px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

/* Toolbar above tables — search + filter chips */
.acc-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.acc-toolbar-search {
    flex: 1 1 240px;
    min-width: 0;
    position: relative;
}
.acc-toolbar-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    background: #f9fafb;
    outline: none;
    transition: all 0.15s ease;
}
.acc-toolbar-search input:focus { background: #fff; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }
.acc-toolbar-search::before {
    content: '🔍';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.5;
    pointer-events: none;
}

/* ── QuickBooks-style horizontal money bar ── */
.qbo-money-bar {
    display: flex;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    margin-bottom: 20px;
}
.qbo-money-seg {
    flex: 1 1 0;
    padding: 14px 18px;
    border-right: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background 0.15s ease;
    min-width: 0;
}
.qbo-money-seg:last-child { border-right: none; }
.qbo-money-seg:hover { background: #f8fafc; }
.qbo-money-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qbo-money-value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 640px) {
    .qbo-money-bar { flex-wrap: wrap; }
    .qbo-money-seg { flex: 1 1 50%; border-bottom: 1px solid #e5e7eb; }
    .qbo-money-seg:nth-child(2) { border-right: none; }
    .qbo-money-seg:nth-last-child(-n+2) { border-bottom: none; }
}
/* 7-segment dashboard variant — tighter padding + smaller values */
.qbo-money-bar-7 .qbo-money-seg { padding: 12px 14px; }
.qbo-money-bar-7 .qbo-money-value { font-size: 17px; }
.qbo-money-bar-7 a.qbo-money-seg { color: inherit; text-decoration: none; display: block; }
.qbo-money-bar-7 a.qbo-money-seg:hover { text-decoration: none; }
@media (max-width: 1100px) {
    .qbo-money-bar-7 { flex-wrap: wrap; }
    .qbo-money-bar-7 .qbo-money-seg { flex: 1 1 25%; border-bottom: 1px solid #e5e7eb; }
    .qbo-money-bar-7 .qbo-money-seg:nth-child(4) { border-right: none; }
    .qbo-money-bar-7 .qbo-money-seg:nth-last-child(-n+3) { border-bottom: none; }
}
@media (max-width: 768px) {
    .qbo-money-bar-7 .qbo-money-seg { flex: 1 1 50%; }
    .qbo-money-bar-7 .qbo-money-seg:nth-child(2n) { border-right: none; }
    .qbo-money-bar-7 .qbo-money-seg:nth-child(2n+1) { border-right: 1px solid #e5e7eb; }
}

/* ── Shared Status Pills (kb-pill) ── */
.kb-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
    white-space: nowrap;
    border: 1px solid transparent;
}
.kb-pill-draft     { background: #f1f5f9; color: #64748b; }
.kb-pill-sent      { background: #dbeafe; color: #1d4ed8; }
.kb-pill-viewed    { background: #ede9fe; color: #6d28d9; }
.kb-pill-partial   { background: #fef3c7; color: #b45309; }
.kb-pill-paid      { background: #dcfce7; color: #15803d; }
.kb-pill-overdue   { background: #fee2e2; color: #b91c1c; }
.kb-pill-cancelled { background: #e5e7eb; color: #6b7280; }
.kb-pill-received  { background: #cffafe; color: #0e7490; }
.kb-pill-verified  { background: #dbeafe; color: #1d4ed8; }
.kb-pill-variance  { background: #fee2e2; color: #b91c1c; margin-left: 6px; }

/* ── Clickable KPI card (adds hover lift to <a> wrappers) ── */
a.acc-stat-card,
a.kb-kpi-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
a.acc-stat-card:hover,
a.kb-kpi-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.15);
    text-decoration: none;
}

/* ── Print Styles ── */
@media print {

    .acc-btn,
    .acc-quick-links,
    .acc-filter-tabs,
    .content-header {
        display: none !important;
    }

    .acc-table-wrap {
        border: 1px solid #ddd;
        box-shadow: none;
    }

    .acc-stat-card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}