/* ===== Harrier Accounting — Books & Banking palette ===== */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #0f172a;
    --text-muted: #64748b;

    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #dbeafe;

    --success: #16a34a;
    --success-soft: #dcfce7;
    --warn: #f97316;
    --warn-soft: #ffedd5;
    --info: #a855f7;
    --info-soft: #f3e8ff;
    --danger: #dc2626;
    --danger-soft: #fee2e2;

    --sidebar-bg: #1a1d29;
    --sidebar-hover: #252836;
    --sidebar-active: #2563eb;
    --sidebar-text: #c9cbd4;
    --sidebar-muted: #6b7080;

    --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
    --shadow: 0 4px 12px rgba(15,23,42,.06);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-weight: 600; color: var(--text); letter-spacing: -0.01em; margin: 0; font-family: inherit; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== App shell ===== */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 18px 12px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.brand-name { font-size: 17px; font-weight: 600; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 10.5px; color: var(--sidebar-muted); letter-spacing: .06em; text-transform: uppercase; }

.sidebar-nav { flex: 1; margin-top: 12px; overflow-y: auto; }
.nav-section { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--sidebar-muted); padding: 14px 12px 6px; font-weight: 500; }
.sidebar .nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: 7px;
    color: var(--sidebar-text); font-size: 13.5px;
    transition: background .12s, color .12s;
    text-decoration: none;
    margin-bottom: 1px;
}
.sidebar .nav-link i { font-size: 16px; width: 18px; text-align: center; opacity: .9; }
.sidebar .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar .nav-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar .nav-link.active i { opacity: 1; }
.sidebar .nav-link.disabled { color: var(--sidebar-muted); cursor: not-allowed; pointer-events: none; }
.badge-soon { margin-left: auto; font-size: 9px; background: rgba(255,255,255,.06); color: var(--sidebar-muted); padding: 2px 6px; border-radius: 4px; letter-spacing: .04em; }

/* Collapsible nav group */
.nav-group { margin-bottom: 1px; }
.nav-group-toggle {
    width: 100%; background: transparent; border: 0; text-align: left;
    cursor: pointer; font-family: inherit;
}
.nav-group-toggle .chevron { margin-left: auto; font-size: 11px; transition: transform .18s; opacity: .7; }
.nav-group.open .nav-group-toggle .chevron { transform: rotate(180deg); }
.nav-group-items {
    max-height: 0; overflow: hidden;
    transition: max-height .22s ease;
    margin-left: 8px; padding-left: 14px;
    border-left: 1px solid rgba(255,255,255,.08);
    margin-top: 2px;
}
.nav-group.open .nav-group-items { max-height: 400px; }
.sidebar .nav-link.nav-sub { padding: 7px 12px; font-size: 13px; }
.sidebar .nav-link.nav-sub i { font-size: 14px; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.06); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.user-name { color: #fff; font-size: 13px; font-weight: 500; line-height: 1.2; }
.user-role { color: var(--sidebar-muted); font-size: 11px; }

/* ===== Main ===== */
.main-area { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px; gap: 16px;
    position: sticky; top: 0; z-index: 10;
}
.search-box { flex: 1; max-width: 520px; position: relative; }
.search-box i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 15px; }
.search-box input {
    width: 100%; padding: 9px 14px 9px 40px;
    border: 1px solid var(--border); background: var(--surface-2);
    border-radius: 8px; font-size: 13.5px; outline: none;
}
.search-box input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn { background: transparent; border: 0; width: 36px; height: 36px; border-radius: 8px; color: var(--text-muted); display: grid; place-items: center; cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.org-chip { display: flex; align-items: center; gap: 8px; padding: 7px 14px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-weight: 500; }
.org-chip i { color: var(--primary); }

.page-content { padding: 24px 28px; max-width: 1500px; width: 100%; }

/* ===== Page header ===== */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 16px; }
.page-header h1 { font-size: 24px; font-weight: 600; }
.page-header .subtitle { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }
.page-header .actions { display: flex; gap: 10px; }

/* ===== Buttons ===== */
.btn { font-weight: 500; border-radius: 8px; padding: 9px 16px; font-size: 13.5px; border: 1px solid transparent; transition: all .12s; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; line-height: 1.2; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; border-color: #15803d; color: #fff; }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger-soft:hover { background: #fecaca; color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ===== KPI Cards ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); position: relative; }
.kpi-card .label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.kpi-card .value { font-size: 26px; font-weight: 700; margin-top: 10px; color: var(--text); letter-spacing: -0.02em; }
.kpi-card .value .currency { font-size: 18px; font-weight: 500; color: var(--text-muted); margin-right: 2px; }
.kpi-card .delta { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.kpi-card .delta.up { color: var(--success); }
.kpi-card .delta.down { color: var(--danger); }
.kpi-card .icon-bubble { position: absolute; right: 18px; top: 18px; width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; font-size: 18px; color: #fff; }
.icon-bubble.blue { background: var(--primary); }
.icon-bubble.orange { background: var(--warn); }
.icon-bubble.green { background: var(--success); }
.icon-bubble.purple { background: var(--info); }

/* ===== Panels ===== */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel-header { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.panel-header h3 { font-size: 16px; font-weight: 600; }
.panel-body { padding: 22px; }
.panel-body.no-pad { padding: 0; }

/* ===== Tables ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th { text-align: left; padding: 11px 22px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.data-table tbody td { padding: 14px 22px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .party-name { font-weight: 500; color: var(--text); }
.data-table .party-code { font-size: 11.5px; color: var(--text-muted); font-family: ui-monospace, 'SF Mono', Menlo, monospace; margin-top: 2px; }
.empty-row td { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 42px; color: var(--border-strong); margin-bottom: 10px; display: block; }

/* ===== Status pills ===== */
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 500; }
.status-pill::before { content:""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-active { background: var(--success-soft); color: var(--success); }
.status-inactive { background: #f1f5f9; color: #64748b; }

/* ===== Filter bar ===== */
.filter-bar { display: flex; gap: 10px; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.filter-bar .search { position: relative; flex: 1; max-width: 360px; }
.filter-bar .search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.filter-bar .search input { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; outline: none; background: var(--surface); }
.filter-bar .search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.filter-bar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; background: var(--surface); outline: none; }

/* ===== Forms ===== */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.form-tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 22px; gap: 4px; overflow-x: auto; }
.form-tab { padding: 14px 18px; font-size: 13.5px; color: var(--text-muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; background: transparent; border-top: 0; border-left: 0; border-right: 0; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.form-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.form-tab:hover:not(.active) { color: var(--text); }
.form-section { padding: 22px 26px; display: none; }
.form-section.active { display: block; }
.form-section h4 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 14px; }

.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 20px; margin-bottom: 4px; }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.field input[type="text"], .field input[type="email"], .field input[type="number"], .field input[type="date"], .field input[type="tel"], .field input[type="url"], .field select, .field textarea {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 13.5px; background: var(--surface); outline: none; font-family: inherit; width: 100%; transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field textarea { resize: vertical; min-height: 80px; }
.field-check { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.field-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.field-check label { margin: 0; font-size: 13px; }
.text-danger { color: var(--danger); font-size: 12px; margin-top: 2px; }

/* ===== Dashboard Profit & Loss ===== */
.pl-dashboard { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin: 20px 0; }
@media (max-width: 1100px) { .pl-dashboard { grid-template-columns: 1fr; } }
.pl-chart-panel .panel-body, .pl-trend-panel .panel-body { padding: 20px; }
.pl-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.pl-stat { padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.pl-stat.income  { border-color: #c8ead4; background: linear-gradient(135deg, #ecfdf3, #fff); }
.pl-stat.expense { border-color: #fbcaca; background: linear-gradient(135deg, #fef2f2, #fff); }
.pl-stat.profit  { border-color: #c5d8fb; background: linear-gradient(135deg, #eff6ff, #fff); }
.pl-stat.loss    { border-color: #fbcaca; background: linear-gradient(135deg, #fef2f2, #fff); }
.pl-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; }
.pl-value { font-size: 22px; font-weight: 700; color: var(--text); margin-top: 6px; font-variant-numeric: tabular-nums; }
.pl-value .currency { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.pl-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; font-weight: 500; }
.pl-stat.income  .pl-value { color: #166534; }
.pl-stat.expense .pl-value { color: #b91c1c; }
.pl-stat.profit  .pl-value { color: #1e40af; }
.pl-stat.loss    .pl-value { color: #b91c1c; }
.pl-chart-wrap { position: relative; height: 320px; }

/* ===== Banking module ===== */
.bank-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; margin-top: 20px; }
.bank-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-sm); transition: border-color .12s, transform .08s, box-shadow .15s; position: relative; }
.bank-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.06); }
.bank-card-head { display: flex; align-items: center; gap: 12px; }
.bank-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.bank-icon.blue   { background: #eef4ff; color: #2563eb; }
.bank-icon.green  { background: #e8f7ee; color: #16a34a; }
.bank-icon.purple { background: #f1ecff; color: #7c3aed; }
.bank-meta { flex: 1; min-width: 0; }
.bank-name { font-size: 15px; font-weight: 600; color: var(--text); }
.bank-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.review-badge { background: #fff4e5; color: #b45309; font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; border: 1px solid #fde2b3; white-space: nowrap; }
.bank-card-body { padding: 6px 0 0; }
.bank-balance-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.bank-balance { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); display: flex; align-items: baseline; gap: 8px; }
.bank-balance .currency { font-size: 16px; color: var(--text-muted); font-weight: 600; }
.bank-balance.negative { color: var(--danger); }
.muted-sm { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.bank-card-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-muted); padding-top: 12px; border-top: 1px solid var(--border); }
.bank-card-cta { color: var(--primary); font-weight: 600; }

.bank-status-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--success); background: #e8f7ee; padding: 4px 10px; border-radius: 999px; border: 1px solid #c8ead4; }

.bank-feed-row .feed-desc { font-weight: 500; font-size: 13.5px; }
.bank-feed-row .feed-ref  { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.feed-actions { display: flex; gap: 6px; align-items: center; }
.action-panel { display: none; gap: 8px; align-items: center; margin-top: 8px; }
.action-panel.open { display: flex; }
.action-panel select { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; background: var(--surface); }

.review-kpi { background: linear-gradient(135deg, #fff8eb 0%, #fff 70%); border-color: #fde2b3; }

.connect-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .connect-grid { grid-template-columns: 1fr; } }

.provider-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.provider-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; text-align: left; transition: border-color .12s, background .12s, transform .08s; font-family: inherit; }
.provider-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.provider-card.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-soft); }
.provider-logo { width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 12px; letter-spacing: .04em; color: #fff; flex-shrink: 0; }
.provider-logo.blue   { background: linear-gradient(135deg, #2563eb, #1e40af); }
.provider-logo.orange { background: linear-gradient(135deg, #f97316, #c2410c); }
.provider-logo.green  { background: linear-gradient(135deg, #16a34a, #15803d); }
.provider-logo.purple { background: linear-gradient(135deg, #7c3aed, #5b21b6); }
.provider-name { font-size: 13.5px; font-weight: 600; color: var(--text); }

.connect-info { display: flex; gap: 12px; padding: 14px 16px; background: var(--primary-soft); border: 1px solid #d3def4; border-radius: 10px; margin-top: 8px; }
.connect-info i { font-size: 20px; color: var(--primary); }
.connect-info strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 2px; }

@keyframes spin-anim { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin-anim .8s linear infinite; }

/* Bank-connection progress overlay (demo handshake) */
.connect-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 9999; padding: 20px; }
.connect-overlay.show { display: flex; animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.connect-modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: 16px; box-shadow: 0 25px 60px rgba(0,0,0,.35); padding: 28px 30px; animation: pop-in .3s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop-in { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.connect-header { display: flex; align-items: center; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.connect-bank-logo { width: 56px; height: 56px; border-radius: 12px; background: linear-gradient(135deg, #2563eb, #1e40af); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .04em; flex-shrink: 0; box-shadow: 0 4px 12px rgba(37, 99, 235, .3); }
.connect-title { font-size: 17px; font-weight: 700; color: var(--text); }
.connect-title span { color: var(--primary); }
.connect-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.connect-sub i { color: var(--success); }

.connect-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.connect-steps li { display: flex; align-items: flex-start; gap: 12px; opacity: .4; transition: opacity .2s; }
.connect-steps li.active, .connect-steps li.done { opacity: 1; }
.connect-steps .step-icon { font-size: 20px; color: var(--text-muted); width: 24px; text-align: center; margin-top: 2px; flex-shrink: 0; }
.connect-steps li.active .step-icon { color: var(--primary); }
.connect-steps li.done .step-icon { color: var(--success); }
.connect-steps .step-title { font-size: 14px; font-weight: 600; color: var(--text); }
.connect-steps .step-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.connect-success { display: none; align-items: center; gap: 14px; margin-top: 22px; padding: 16px 18px; background: #e8f7ee; border: 1px solid #c8ead4; border-radius: 12px; animation: pop-in .3s cubic-bezier(.2,.9,.3,1.2); }
.connect-success.show { display: flex; }
.connect-success i { font-size: 28px; color: var(--success); }
.success-title { font-size: 14.5px; font-weight: 700; color: var(--text); }
.success-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.how-grid > div { display: flex; flex-direction: column; gap: 6px; }
.how-num { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; font-size: 13px; margin-bottom: 4px; }
.how-text { font-size: 13px; color: var(--text-muted); }

/* Report drill-down links */
.report-link { color: var(--primary); text-decoration: none; border-bottom: 1px dashed transparent; transition: border-color .12s, color .12s; }
.report-link:hover { color: var(--primary); border-bottom-color: var(--primary); }
.statement-table .report-link { font-weight: 500; }

/* Clickable aging KPI cards */
.aging-card { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .08s; }
.aging-card:hover { border-color: var(--primary); }
.aging-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.aging-card.active .label { color: var(--primary); }

/* Invoice number field with edit toggle */
.inv-num-group { position: relative; display: flex; align-items: center; }
.inv-num-group .inv-num-icon { position: absolute; left: 11px; font-size: 13px; color: var(--text-muted); pointer-events: none; }
.inv-num-group input[type="text"] { padding-left: 30px; padding-right: 78px; font-weight: 600; letter-spacing: .02em; }
.inv-num-group input[readonly] { background: var(--surface-2); color: var(--text-muted); cursor: default; }
.inv-num-toggle { position: absolute; right: 5px; display: flex; align-items: center; gap: 5px; padding: 5px 10px; font-size: 11.5px; font-weight: 600; color: var(--primary); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; transition: background .12s, border-color .12s; }
.inv-num-toggle:hover { background: var(--primary-soft); border-color: var(--primary); }
.inv-num-group.editing input[readonly] { background: var(--surface); color: var(--text); }
.inv-num-group.editing input[type="text"] { color: var(--text); }

.form-footer { padding: 16px 26px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; justify-content: flex-end; gap: 10px; }

/* ===== Detail view ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; }
.detail-item { display: flex; flex-direction: column; gap: 3px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.detail-item:last-child { border-bottom: 0; }
.detail-item .lbl { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.detail-item .val { font-size: 14px; color: var(--text); }

.party-header-card { display: flex; align-items: center; gap: 18px; padding: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.party-avatar { width: 60px; height: 60px; border-radius: 12px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 600; }
.party-header-info h2 { font-size: 20px; }
.party-header-info .meta { color: var(--text-muted); font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== Responsive ===== */
@media (max-width: 992px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .form-row, .form-row.cols-3 { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
}

/* ===== Alerts ===== */
.alert { border-radius: var(--radius-sm); border: 1px solid; padding: 12px 16px; font-size: 13.5px; }
.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: #166534; }
.alert-danger { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }

/* ===== Invoice status pills ===== */
.inv-pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.inv-draft     { background: #f1f5f9; color: #64748b; }
.inv-sent      { background: var(--primary-soft); color: var(--primary); }
.inv-partial   { background: var(--warn-soft); color: #c2410c; }
.inv-paid      { background: var(--success-soft); color: var(--success); }
.inv-overdue   { background: var(--danger-soft); color: var(--danger); }
.inv-cancelled { background: #e2e8f0; color: #475569; }

/* ===== Invoice line-item table (form) ===== */
.line-table { width: 100%; border-collapse: collapse; }
.line-table thead th { text-align: left; padding: 8px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.line-table tbody td { padding: 6px 6px; vertical-align: middle; }
.line-table input, .line-table select { width: 100%; padding: 8px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; outline: none; font-family: inherit; background: var(--surface); }
.line-table input:focus, .line-table select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.row-del { background: transparent; border: 0; color: var(--text-muted); width: 30px; height: 30px; border-radius: 6px; cursor: pointer; }
.row-del:hover { background: var(--danger-soft); color: var(--danger); }

/* ===== Invoice totals box ===== */
.invoice-totals { margin-left: auto; margin-top: 18px; width: 320px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.invoice-totals .tot-row { display: flex; justify-content: space-between; padding: 9px 14px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.invoice-totals .tot-row:last-child { border-bottom: 0; }
.invoice-totals .tot-row.grand { background: var(--surface-2); font-weight: 700; font-size: 15px; }
.invoice-totals .tot-row.balance { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
.invoice-totals.doc { margin-top: 0; }

/* ===== Invoice document (Details) ===== */
.invoice-doc { padding: 32px; }
.invoice-doc-head { display: flex; justify-content: space-between; gap: 30px; padding-bottom: 24px; border-bottom: 2px solid var(--text); }
.company-name { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.muted-lines { font-size: 12.5px; color: var(--text-muted); line-height: 1.7; }
.invoice-doc-parties { display: flex; justify-content: space-between; gap: 30px; padding: 22px 0; }
.invoice-doc-parties .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.party-block { font-size: 13px; line-height: 1.6; }
.invoice-doc-foot { display: flex; justify-content: space-between; gap: 40px; margin-top: 22px; }
.notes-block { flex: 1; font-size: 13px; }
.notes-block .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }

@media print {
    .sidebar, .topbar, .page-header .actions, .form-footer { display: none !important; }
    .app-shell { grid-template-columns: 1fr; }
    .page-content { padding: 0; }
    .invoice-doc { border: 0; box-shadow: none; }
}

/* ===== Reports ===== */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.report-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .1s; display: block; }
.report-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.report-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; color: #fff; margin-bottom: 14px; }
.report-icon.blue { background: var(--primary); }
.report-icon.orange { background: var(--warn); }
.report-icon.green { background: var(--success); }
.report-icon.purple { background: var(--info); }
.report-title { font-size: 15.5px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.report-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.report-total-row td { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--border-strong); }

/* Financial statement tables (P&L, Balance Sheet) */
.statement-table td { padding: 11px 22px; font-size: 13.5px; }
.statement-table .section-head td { background: var(--surface-2); font-weight: 600; text-transform: uppercase; font-size: 11.5px; letter-spacing: .06em; color: var(--text-muted); }
.statement-table .subtotal td { font-weight: 600; border-top: 1px solid var(--border-strong); }
.statement-table .grand td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--border-strong); background: var(--surface-2); }
.statement-table .grand.positive td { color: var(--success); }
.statement-table .grand.negative td { color: var(--danger); }
.statement-table .muted { color: var(--text-muted); font-size: 12px; font-weight: 400; }

.badge-system { font-size: 9.5px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px; margin-left: 8px; text-transform: uppercase; letter-spacing: .04em; }
