* { box-sizing: border-box; }
:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-soft: #f8fbff;
    --surface-muted: #f1f5f9;
    --border: #dbe4ef;
    --text: #1e293b;
    --muted: #64748b;
    --brand: #123a63;
    --brand-2: #1d4ed8;
    --success: #166534;
    --danger: #991b1b;
    --warning: #a16207;
    --shadow: 0 10px 30px rgba(15, 23, 42, .08);
    --radius: 18px;
    --radius-sm: 12px;
}
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Tahoma, Arial, sans-serif;
    background: linear-gradient(180deg, #eef3f8 0%, var(--bg) 180px, var(--bg) 100%);
    color: var(--text);
    line-height: 1.7;
}
a { color: var(--brand-2); }
.topbar {
    background: linear-gradient(135deg, #0f2740 0%, var(--brand) 100%);
    color: #fff;
    padding: 18px 34px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .16);
}
.brand-block h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: .2px;
}
.brand-block p {
    margin: 6px 0 0;
    color: rgba(255,255,255,.82);
    font-size: 15px;
}
.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}
.topbar nav a {
    color: #fff;
    text-decoration: none;
    padding: 11px 18px;
    border-radius: 999px;
    background: rgba(255,255,255,.09);
    border: 1px solid rgba(255,255,255,.12);
    font-weight: 700;
    transition: .18s ease;
    white-space: nowrap;
}
.topbar nav a:hover {
    background: rgba(255,255,255,.18);
    transform: translateY(-1px);
}
.container {
    width: min(1600px, calc(100% - 40px));
    margin: 26px auto 40px;
}
.page-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}
.page-head h2 {
    margin: 0;
    font-size: 30px;
    color: #0f2740;
}
.page-head p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 15px;
}
.page-head .meta-badge {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 16px;
    font-weight: 700;
    color: var(--brand);
    white-space: nowrap;
    box-shadow: var(--shadow);
}
.card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    border: 1px solid rgba(219, 228, 239, .9);
}
.card.tight { padding: 18px; }
.card-header, .section-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}
.card-header h2, .card-header h3, .section-header h3,
.card > h2, .card > h3 {
    margin: 0;
    color: #102a43;
}
.card-subtitle, .helper-text {
    color: var(--muted);
    font-size: 14px;
    margin-top: 6px;
}
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.detail-item {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
}
.detail-item .label {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 4px;
}
.detail-item .value {
    font-weight: 700;
    color: #0f2740;
}
.metric {
    text-align: center;
    padding: 18px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.metric h3 {
    font-size: 16px;
    margin: 0 0 8px;
    color: var(--muted);
}
.metric strong {
    display: block;
    font-size: 30px;
    margin: 10px 0 4px;
    color: #0f2740;
}
.summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 4px;
}
.summary span {
    background: linear-gradient(180deg, #fff, #f8fbff);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(15,23,42,.04);
}
.summary span b {
    display: block;
    font-size: 20px;
    margin-top: 4px;
    color: #0f2740;
}
.progress-wrap {
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    height: 22px;
    margin-top: 8px;
}
.progress-bar {
    height: 22px;
    background: linear-gradient(90deg, #0f766e 0%, #0891b2 100%);
    color: white;
    text-align: center;
    font-size: 12px;
    line-height: 22px;
    font-weight: 700;
}
.button, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 11px 18px;
    border-radius: 12px;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    margin: 4px;
    box-shadow: 0 8px 18px rgba(37, 99, 235, .18);
    transition: .18s ease;
}
.button:hover, button:hover { transform: translateY(-1px); }
.button.secondary {
    background: #fff;
    color: var(--brand);
    border: 1px solid var(--border);
    box-shadow: none;
}
.button.success, .report-standards-btn {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%) !important;
}
.button.warning { background: linear-gradient(135deg, #b45309 0%, #d97706 100%); }
.actions, .form-actions, .page-actions, .quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
}
.form {
    display: grid;
    gap: 16px;
    width: 100%;
}
.wide-form { max-width: 100%; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.full > * { grid-column: 1 / -1; }
.field, .form label {
    display: grid;
    gap: 8px;
    align-content: start;
    font-weight: 700;
    color: #1f3552;
}
.field small, .field-note, .small, .stage-note {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.7;
}
input, select, textarea {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(59,130,246,.12);
}
input[disabled], select[disabled], textarea[disabled] {
    background: #f8fafc;
    color: #475569;
}
textarea { min-height: 124px; resize: vertical; }
textarea.report-draft { min-height: 520px; direction: rtl; line-height: 2; font-size: 16px; }
.inline-check {
    display: flex !important;
    align-items: center;
    gap: 10px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    font-weight: 700;
}
.inline-check input { width: auto; margin: 0; }
.msg {
    padding: 14px 16px;
    border-radius: 12px;
    background: #e2e8f0;
    margin-bottom: 12px;
    border: 1px solid transparent;
    font-weight: 700;
}
.msg.success { background: #dcfce7; color: var(--success); border-color: #bbf7d0; }
.msg.error { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.ok { color: var(--success); font-weight: 700; }
.bad { color: var(--danger); font-weight: 700; }
.small { direction: rtl; text-align: right; }
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
    min-width: 760px;
}
thead th {
    background: #eef4fb;
    color: #16324f;
    font-size: 14px;
    position: sticky;
    top: 0;
}
th, td {
    border-bottom: 1px solid #e5edf6;
    padding: 14px 12px;
    text-align: right;
    vertical-align: top;
}
tbody tr:nth-child(even) { background: #fbfdff; }
tbody tr:hover { background: #f3f8ff; }
.num { direction: ltr; text-align: left; white-space: nowrap; }
.stage-list, .risk-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
.stage-card, .risk-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 6px 18px rgba(15,23,42,.04);
}
.stage-card {
    display: grid;
    grid-template-columns: 86px 1fr 180px 170px;
    gap: 14px;
    align-items: stretch;
}
.stage-card.done { border-right: 6px solid #15803d; }
.stage-card.current { border-right: 6px solid #2563eb; }
.stage-card.blocked { opacity: .78; }
.stage-no, .stage-status {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    text-align: center;
    padding: 14px 8px;
    font-weight: 700;
    color: #0f2740;
}
.stage-title { font-size: 19px; font-weight: 700; color: #0f2740; }
.stage-desc { font-size: 14px; color: var(--muted); margin-top: 6px; }
.disabled-link {
    display: inline-block;
    padding: 12px 14px;
    border-radius: 12px;
    background: #eef2f7;
    color: #64748b;
    font-size: 14px;
    text-align: center;
}
.stage-action {
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}
.risk-card.risk-high { border-right: 6px solid #b91c1c; }
.risk-card.risk-medium { border-right: 6px solid #d97706; }
.risk-card.risk-low { border-right: 6px solid #15803d; }
.risk-head {
    display: grid;
    grid-template-columns: 120px 200px 1fr;
    gap: 12px;
    margin-bottom: 14px;
}
.head-chip {
    background: #f8fbff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}
.report-standard-box {
    border: 1px solid #d8e4f2;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
    border-radius: 16px;
    padding: 18px;
    margin: 10px 0;
}
.report-standard-box h3 {
    margin: 0 0 14px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #cfdceb;
    font-size: 18px;
    color: #102a43;
}
.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.badge {
    background: #eef4fb;
    color: #16324f;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
}
.list-clean {
    margin: 0;
    padding-right: 18px;
}
footer {
    text-align: center;
    color: #64748b;
    padding: 24px 20px 34px;
}
@media (max-width: 1200px) {
    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.four, .grid.five, .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
    .topbar, .page-head, .card-header, .section-header, .stage-card, .risk-head,
    .grid.two, .grid.three, .grid.four, .grid.five, .details, .form-grid,
    .summary {
        grid-template-columns: 1fr;
        flex-direction: column;
    }
    .topbar { padding: 18px 20px; }
    .container { width: min(100% - 24px, 1600px); }
    .stage-card { display: grid; }
}
@media (max-width: 640px) {
    .brand-block h1 { font-size: 25px; }
    .page-head h2 { font-size: 26px; }
    .card { padding: 18px; }
    .summary span b { font-size: 18px; }
    textarea.report-draft { min-height: 420px; }
}

/* =========================
   Auditor Report Print View
   ========================= */
.print-body {
    background: #e8eef6;
    margin: 0;
    color: #111827;
}
.print-actions {
    width: min(900px, calc(100% - 32px));
    margin: 18px auto;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-start;
}
.print-page {
    width: 210mm;
    min-height: 297mm;
    margin: 18px auto 34px;
    background: #fff;
    padding: 22mm 18mm;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .18);
    border: 1px solid #dbe4ef;
    font-size: 14px;
    line-height: 1.9;
}
.print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    border-bottom: 3px solid #123a63;
    padding-bottom: 14px;
    margin-bottom: 18px;
}
.print-header h1 {
    margin: 0;
    font-size: 26px;
    color: #123a63;
}
.print-header p {
    margin: 6px 0 0;
    color: #64748b;
    font-weight: 700;
}
.print-file-code {
    border: 1px solid #cbd5e1;
    background: #f8fbff;
    color: #123a63;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
    white-space: nowrap;
}
.print-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.print-meta div {
    border: 1px solid #dbe4ef;
    background: #f8fbff;
    border-radius: 10px;
    padding: 10px 12px;
}
.print-meta div.wide { grid-column: 1 / -1; }
.print-meta span {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin-bottom: 2px;
}
.print-meta b {
    color: #111827;
    font-size: 14px;
}
.print-section {
    margin: 16px 0;
    page-break-inside: avoid;
}
.print-section h2 {
    font-size: 18px;
    margin: 0 0 8px;
    color: #123a63;
    border-bottom: 1px solid #dbe4ef;
    padding-bottom: 6px;
}
.print-text {
    white-space: pre-wrap;
    text-align: justify;
    color: #1f2937;
}
.main-report-text .print-text {
    font-size: 15px;
    line-height: 2;
}
.print-signatures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 32px;
    page-break-inside: avoid;
}
.print-signatures div {
    border-top: 1px solid #94a3b8;
    padding-top: 10px;
    min-height: 70px;
}
.print-signatures span {
    display: block;
    color: #64748b;
    font-size: 12px;
}
.print-signatures strong {
    display: block;
    margin-top: 6px;
    color: #111827;
}
@media print {
    @page { size: A4; margin: 14mm; }
    body.print-body { background: #fff; }
    .no-print, .print-actions { display: none !important; }
    .print-page {
        width: auto;
        min-height: auto;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: 0;
    }
    .print-header { margin-top: 0; }
    .print-section { break-inside: avoid; }
}

.print-body {
    background: #e5e7eb;
    margin: 0;
    font-family: Tahoma, Arial, sans-serif;
    color: #111827;
}
.print-actions {
    width: 210mm;
    margin: 18px auto 8px;
    text-align: left;
}
.print-page {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 24px;
    background: white;
    padding: 20mm 18mm;
    box-shadow: 0 10px 35px rgba(15, 23, 42, .18);
}
.print-header {
    text-align: center;
    border-bottom: 2px solid #123a63;
    padding-bottom: 14px;
    margin-bottom: 18px;
}
.print-header h1 {
    margin: 0 0 8px;
    color: #123a63;
    font-size: 24px;
}
.print-header p {
    margin: 0;
    color: #475569;
}
.print-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    border: 1px solid #dbe4ef;
    background: #f8fbff;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 18px;
}
.print-text {
    white-space: pre-wrap;
    line-height: 2.1;
    font-size: 15px;
}
.print-signatures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 42px;
    text-align: center;
}
.print-signatures div {
    border-top: 1px solid #1f2937;
    padding-top: 10px;
    min-height: 45px;
}
@media print {
    body.print-body { background: white; }
    .print-actions { display: none; }
    .print-page {
        width: auto;
        min-height: auto;
        margin: 0;
        padding: 0;
        box-shadow: none;
    }
    .topbar, footer { display: none; }
    @page { size: A4; margin: 16mm; }
}


/* ============================================================
   Arabic professional layout refinement - phase labels and boxes
   ============================================================ */
.container {
    width: min(1720px, calc(100% - 44px));
}
.page-head {
    background: rgba(255,255,255,.68);
    border: 1px solid rgba(219, 228, 239, .85);
    border-radius: 18px;
    padding: 18px 20px;
    box-shadow: 0 8px 24px rgba(15,23,42,.05);
}
.summary {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.summary span,
.metric,
.detail-item,
.head-chip,
.inline-check {
    min-height: 92px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.stage-card {
    grid-template-columns: 96px minmax(420px, 1fr) 190px 210px;
    min-height: 150px;
    padding: 22px;
    gap: 18px;
}
.stage-no,
.stage-status {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.stage-title {
    font-size: 21px;
    line-height: 1.45;
}
.stage-desc {
    font-size: 15px;
    line-height: 1.8;
    max-width: 980px;
}
.stage-action .button,
.stage-action .disabled-link {
    width: 100%;
    min-height: 44px;
    margin: 0;
}
.card,
.stage-card,
.risk-card {
    border-radius: 20px;
}
.risk-head {
    grid-template-columns: minmax(160px, .8fr) minmax(220px, 1fr) minmax(420px, 2fr);
    align-items: stretch;
}
.table-wrap table input,
.table-wrap table select,
.table-wrap table textarea {
    min-width: 150px;
}
.table-wrap table textarea {
    min-height: 94px;
}
button, .button {
    min-width: 132px;
}
@media (max-width: 1280px) {
    .stage-card { grid-template-columns: 90px 1fr; }
    .stage-status, .stage-action { grid-column: 1 / -1; }
    .stage-action { flex-direction: row; flex-wrap: wrap; }
    .stage-action .button, .stage-action .disabled-link { width: auto; }
    .risk-head { grid-template-columns: 1fr; }
}

/* ============================================================
   التقرير النهائي الكامل - مطابق لبنية التقرير المرفق
   ============================================================ */
.final-report-body {
    margin: 0;
    background: #e9edf3;
    color: #111827;
    font-family: Tahoma, Arial, sans-serif;
}
.final-page {
    width: 210mm;
    min-height: 297mm;
    box-sizing: border-box;
    margin: 10mm auto;
    padding: 12mm 13mm;
    background: #fff;
    border: 1px solid #d8dee8;
    box-shadow: 0 8px 26px rgba(15, 23, 42, .12);
    page-break-after: always;
    position: relative;
    direction: rtl;
}
.final-page::after {
    content: "نظام معيار";
    position: absolute;
    bottom: 7mm;
    left: 13mm;
    right: 13mm;
    text-align: center;
    font-size: 9px;
    color: #68758a;
    border-top: 1px solid #dbe2ea;
    padding-top: 3mm;
}
.final-letter-head {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 10mm;
    align-items: start;
    margin-bottom: 8mm;
    border-bottom: 2px solid #111827;
    padding-bottom: 5mm;
}
.final-letter-head .center-side { text-align: center; grid-column: 2; }
.final-letter-head .firm-side { text-align: center; font-size: 11px; line-height: 1.8; }
.final-letter-head h1,
.statement-title h1 {
    margin: 0 0 3mm;
    font-size: 16px;
    font-weight: 800;
}
.final-letter-head p,
.statement-title h2 {
    margin: 0;
    font-size: 12px;
    font-weight: 700;
}
.final-text-block {
    font-size: 11.4px;
    line-height: 1.9;
    text-align: justify;
}
.final-text-block h2 {
    margin: 4mm 0 1.5mm;
    font-size: 12.5px;
    text-align: center;
    text-decoration: underline;
}
.final-signature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18mm;
    margin-top: 10mm;
    align-items: end;
    text-align: center;
    font-size: 11px;
}
.final-signature-grid div {
    border-top: 1px solid #111827;
    padding-top: 2.5mm;
    min-height: 16mm;
}
.final-signature-grid span { display: block; margin-top: 2mm; color: #374151; }
.final-signature-grid.small { margin-top: 15mm; }
.statement-title {
    text-align: center;
    margin-bottom: 6mm;
    border-bottom: 1.8px solid #111827;
    padding-bottom: 4mm;
}
.final-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 10px;
    line-height: 1.45;
}
.final-table th {
    background: #171717;
    color: #fff;
    border: 1px solid #111;
    padding: 2.2mm 1.5mm;
    text-align: center;
    font-weight: 800;
}
.final-table td {
    border: 1px solid #9ca3af;
    padding: 1.8mm 1.5mm;
    vertical-align: top;
}
.final-table td:nth-child(1),
.final-table td:nth-child(3),
.final-table td:nth-child(4),
.final-table td:nth-child(5) { text-align: center; }
.financial-table th:nth-child(1),
.financial-table td:nth-child(1) { width: 24mm; }
.financial-table th:nth-child(2),
.financial-table td:nth-child(2) { width: auto; text-align: right; }
.financial-table th:nth-child(3),
.financial-table th:nth-child(4),
.financial-table td:nth-child(3),
.financial-table td:nth-child(4) { width: 32mm; text-align: center; }
.compact-table { font-size: 9.5px; }
.compact-table td { padding: 1.35mm 1mm; }
.total-row td {
    background: #f0f3f7;
    font-weight: 800;
    border-top: 2px solid #111827;
    border-bottom: 2px solid #111827;
}
.note-box {
    margin-top: 7mm;
    border: 1px solid #9ca3af;
    padding: 4mm;
    font-size: 10.5px;
    line-height: 1.8;
}
.management-page h3 {
    font-size: 12px;
    margin: 6mm 0 2mm;
    border-bottom: 1px solid #111827;
    padding-bottom: 1.5mm;
}
.management-page p {
    font-size: 10.8px;
    line-height: 1.85;
    text-align: justify;
}
.mini-table { max-width: 150mm; margin: 4mm auto; }
.bars-box {
    margin-top: 8mm;
    border: 1px solid #cbd5e1;
    padding: 5mm;
    display: grid;
    gap: 3mm;
}
.bars-box div {
    display: grid;
    grid-template-columns: 35mm 1fr;
    gap: 3mm;
    align-items: center;
    font-size: 10.5px;
}
.bars-box b {
    display: block;
    height: 9mm;
    width: var(--w);
    background: repeating-linear-gradient(45deg, #374151 0, #374151 5px, #6b7280 5px, #6b7280 10px);
}
@page {
    size: A4;
    margin: 8mm;
}
@page final-landscape {
    size: A4 landscape;
    margin: 8mm;
}
.landscape-page {
    page: final-landscape;
    width: 297mm;
    min-height: 210mm;
}
@media print {
    body.final-report-body { background: #fff; }
    .final-page {
        margin: 0;
        border: 0;
        box-shadow: none;
        width: auto;
        min-height: auto;
    }
    .landscape-page { width: auto; min-height: auto; }
    .no-print { display: none !important; }
    .final-page::after { color: #555; }
}

/* Final Report Editor */
.editor-toolbar{display:flex;flex-wrap:wrap;gap:10px;margin:14px 0 18px;align-items:center}
.final-report-editor{background:#fff;border:1px solid #cbd7e3;border-radius:18px;padding:28px;min-height:760px;line-height:1.9;font-size:16px;color:#172033;box-shadow:inset 0 0 0 1px rgba(18,58,99,.05)}
.final-report-editor:focus{outline:3px solid rgba(37,99,235,.18);border-color:#2563eb}
.final-report-editor .final-page,.final-report-editor .editable-report-page{background:#fff;border:1px solid #e2e8f0;border-radius:14px;padding:24px;margin:0 0 22px;page-break-after:always;break-after:page}
.print-toolbar{position:sticky;top:0;background:#0f172a;color:#fff;padding:10px;display:flex;gap:10px;z-index:20}.print-toolbar button,.print-toolbar a{background:#fff;color:#0f172a;border:0;border-radius:8px;padding:8px 14px;text-decoration:none;font-weight:700}.print-status{padding:8px 14px;background:#e0f2fe;color:#075985;font-weight:700}.final-report-print-canvas{max-width:980px;margin:0 auto;background:#fff;padding:0 10px}
@media print{.no-print,.print-toolbar,.print-status{display:none!important}.final-report-print-canvas{max-width:none;margin:0;padding:0}.final-report-print-canvas .final-page{border:0;border-radius:0;margin:0;padding:18mm 14mm;page-break-after:always;break-after:page}body.final-editor-print{background:#fff}}



/* Manual print orientation selector */
.print-orientation-panel {
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.orientation-title {
    font-weight: 900;
    color: #0f172a;
    margin-left: 6px;
}
.orientation-btn.active,
.print-toolbar .orientation-btn.active {
    background: #123a63 !important;
    color: #fff !important;
    border-color: #123a63 !important;
}
.orientation-help {
    width: 100%;
    font-size: 12px;
    color: #475569;
    margin-top: 4px;
}
.print-toolbar .orientation-help {
    width: auto;
    color: #e2e8f0;
    font-weight: 400;
}

/* ============================================================
   Final Report A4 Orientation & Borders Fix - 2026-04-30
   ============================================================ */
.statement-code {
    display: inline-block;
    min-width: 28mm;
    margin-bottom: 2.5mm;
    padding: 1.2mm 4mm;
    border: 1px solid #111827;
    border-radius: 3px;
    background: #f8fafc;
    color: #111827;
    font-size: 12px;
    font-weight: 900;
    text-align: center;
}
.final-page {
    overflow: hidden;
}
.final-page.portrait-page {
    width: 210mm;
    min-height: 297mm;
}
.final-page.landscape-page {
    width: 297mm;
    min-height: 210mm;
    padding: 10mm 11mm;
}
.final-page.landscape-page .final-table {
    font-size: 9.2px;
}
.final-page.landscape-page .compact-table {
    font-size: 9px;
}
.final-page.landscape-page .statement-title {
    margin-bottom: 4mm;
}
.final-page.landscape-page .statement-title h1 {
    font-size: 15px;
}
.final-page.landscape-page .statement-title h2 {
    font-size: 11.5px;
}
.final-page.landscape-page .final-table th {
    padding: 1.8mm 1.2mm;
}
.final-page.landscape-page .final-table td {
    padding: 1.35mm 1.1mm;
}
.final-page .statement-title,
.final-letter-head,
.note-box,
.final-signature-grid div {
    border-color: #111827;
}
.final-page .final-table th,
.final-page .final-table td {
    word-break: break-word;
    overflow-wrap: anywhere;
}
.final-page .final-table th {
    border: 1.2px solid #111827;
}
.final-page .final-table td {
    border: 1px solid #4b5563;
}
.final-page .total-row td {
    border-top: 1.8px solid #111827;
    border-bottom: 1.8px solid #111827;
}

@page reportPortrait {
    size: A4 portrait;
    margin: 8mm;
}
@page reportLandscape {
    size: A4 landscape;
    margin: 8mm;
}
.final-page.portrait-page {
    page: reportPortrait;
}
.final-page.landscape-page {
    page: reportLandscape;
}

@media print {
    @page {
        size: A4;
        margin: 8mm;
    }
    @page reportPortrait {
        size: A4 portrait;
        margin: 8mm;
    }
    @page reportLandscape {
        size: A4 landscape;
        margin: 8mm;
    }
    body.final-report-body,
    body.final-editor-print {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .final-page,
    .final-report-print-canvas .final-page {
        border: 1px solid #111827 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        margin: 0 auto !important;
        page-break-after: always;
        break-after: page;
        box-sizing: border-box;
        position: relative;
        background: #fff !important;
    }
    .final-page.portrait-page,
    .final-report-print-canvas .final-page.portrait-page {
        page: reportPortrait;
        width: 194mm !important;
        min-height: 281mm !important;
        padding: 7mm 8mm 13mm !important;
    }
    .final-page.landscape-page,
    .final-report-print-canvas .final-page.landscape-page {
        page: reportLandscape;
        width: 281mm !important;
        min-height: 194mm !important;
        padding: 6mm 7mm 11mm !important;
    }
    .final-report-print-canvas {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }
    .final-page::after {
        bottom: 3.5mm !important;
        left: 7mm !important;
        right: 7mm !important;
    }
    .final-page.landscape-page::after {
        bottom: 3mm !important;
        left: 7mm !important;
        right: 7mm !important;
    }
    .landscape-page .final-table {
        font-size: 8.7px !important;
        line-height: 1.32 !important;
    }
    .portrait-page .final-table {
        font-size: 9.4px !important;
        line-height: 1.38 !important;
    }
    .final-table th {
        background: #111827 !important;
        color: #fff !important;
        padding: 1.6mm 1mm !important;
    }
    .final-table td {
        padding: 1.25mm .9mm !important;
    }
    .financial-table th:nth-child(1),
    .financial-table td:nth-child(1) { width: 23mm; }
    .financial-table th:nth-child(3),
    .financial-table th:nth-child(4),
    .financial-table td:nth-child(3),
    .financial-table td:nth-child(4) { width: 30mm; }
    .statement-title {
        margin-bottom: 4.5mm !important;
        padding-bottom: 3mm !important;
    }
    .statement-code {
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* ============================================================
   Final Report Table Inside Page Bounds Fix - 2026-04-30
   الهدف: منع خروج الجداول والحدود خارج ورقة A4 عند الطباعة
   ============================================================ */
.final-page,
.final-page * {
    box-sizing: border-box;
}
.final-page {
    max-width: calc(100vw - 22px);
    overflow: hidden !important;
}
.final-page.portrait-page {
    width: min(210mm, calc(100vw - 22px));
}
.final-page.landscape-page {
    width: min(297mm, calc(100vw - 22px));
}
.final-page table,
.final-page .final-table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
}
.final-page .final-table th,
.final-page .final-table td {
    min-width: 0 !important;
    max-width: 0;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    vertical-align: top;
}
.final-page .final-table th:nth-child(1),
.final-page .final-table td:nth-child(1) { width: 14% !important; }
.final-page .final-table th:nth-child(2),
.final-page .final-table td:nth-child(2) { width: 38% !important; }
.final-page .final-table th:nth-child(3),
.final-page .final-table td:nth-child(3),
.final-page .final-table th:nth-child(4),
.final-page .final-table td:nth-child(4) { width: 16% !important; }
.final-page .final-table th:nth-child(5),
.final-page .final-table td:nth-child(5) { width: 16% !important; }
.schedule-12-extra .final-table th:nth-child(1),
.schedule-12-extra .final-table td:nth-child(1) { width: 13% !important; }
.schedule-12-extra .final-table th:nth-child(2),
.schedule-12-extra .final-table td:nth-child(2) { width: 22% !important; }
.schedule-12-extra .final-table th:nth-child(3),
.schedule-12-extra .final-table td:nth-child(3),
.schedule-12-extra .final-table th:nth-child(4),
.schedule-12-extra .final-table td:nth-child(4) { width: 10% !important; text-align: center; }
.schedule-12-extra .final-table th:nth-child(5),
.schedule-12-extra .final-table td:nth-child(5) { width: 13% !important; text-align: center; }
.schedule-12-extra .final-table th:nth-child(6),
.schedule-12-extra .final-table td:nth-child(6) { width: 32% !important; }
.final-page.fit-tight .final-table,
.final-page.final-fit-overflow .final-table {
    font-size: 8.2px !important;
    line-height: 1.22 !important;
}
.final-page.fit-tight .final-table th,
.final-page.fit-tight .final-table td,
.final-page.final-fit-overflow .final-table th,
.final-page.final-fit-overflow .final-table td {
    padding: .85mm .55mm !important;
}
.final-page.fit-ultra .final-table {
    font-size: 7.2px !important;
    line-height: 1.16 !important;
}
.final-page.fit-ultra .final-table th,
.final-page.fit-ultra .final-table td {
    padding: .65mm .38mm !important;
}

@media print {
    html,
    body.final-report-body,
    body.final-editor-print {
        width: 100% !important;
        max-width: 100% !important;
        overflow: visible !important;
    }
    .final-page,
    .final-report-print-canvas .final-page {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 6mm 6mm 10mm !important;
        border: 1px solid #111827 !important;
        background: #fff !important;
    }
    .final-page.portrait-page,
    .final-report-print-canvas .final-page.portrait-page {
        page: reportPortrait;
    }
    .final-page.landscape-page,
    .final-report-print-canvas .final-page.landscape-page {
        page: reportLandscape;
    }
    .final-page table,
    .final-page .final-table {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        transform: none !important;
    }
    .final-page .final-table th,
    .final-page .final-table td {
        min-width: 0 !important;
        max-width: 0 !important;
        white-space: normal !important;
        word-break: break-word !important;
        overflow-wrap: anywhere !important;
        overflow: hidden !important;
    }
    .portrait-page .final-table {
        font-size: 8.1px !important;
        line-height: 1.22 !important;
    }
    .landscape-page .final-table {
        font-size: 8.4px !important;
        line-height: 1.24 !important;
    }
    .portrait-page .compact-table,
    body[data-print-mode="portrait"] .final-page .final-table {
        font-size: 7.4px !important;
        line-height: 1.16 !important;
    }
    .landscape-page .compact-table {
        font-size: 8.0px !important;
    }
    .final-table th,
    .final-table td {
        padding: .85mm .55mm !important;
    }
    body[data-print-mode="portrait"] .final-table th,
    body[data-print-mode="portrait"] .final-table td,
    .portrait-page .compact-table th,
    .portrait-page .compact-table td {
        padding: .65mm .38mm !important;
    }
    .statement-title,
    .final-letter-head,
    .note-box,
    .bars-box {
        max-width: 100% !important;
        overflow: hidden !important;
    }
    .statement-title h1,
    .statement-title h2,
    .final-letter-head h1,
    .final-letter-head p {
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
    }
    .bars-box {
        display: block !important;
    }
    .bars-box div {
        display: grid !important;
        grid-template-columns: 26mm 1fr !important;
        max-width: 100% !important;
    }
    .bars-box b {
        max-width: 100% !important;
    }
    .final-page::after {
        left: 6mm !important;
        right: 6mm !important;
        bottom: 3mm !important;
    }
}


/* Phase 1 - Permissions, Audit Trail, Stage Lock/Reopen */
.logout-form {
    display: inline-flex;
    margin: 0;
}

.logout-form button {
    border: 1px solid rgba(255,255,255,.35);
    background: rgba(255,255,255,.12);
    color: #fff;
    border-radius: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-family: inherit;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-weight: 700;
}

.auth-card {
    max-width: 560px;
    margin: 40px auto;
}

.form-stack {
    display: grid;
    gap: 16px;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.permission-list p {
    margin: 0 0 12px;
    line-height: 1.8;
}

.filters-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr auto;
    gap: 14px;
    align-items: end;
}

.inline-actions {
    margin-top: 0;
    align-items: end;
}

.inline-stage-form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) auto;
    gap: 8px;
    margin-top: 8px;
}

.inline-stage-form input {
    min-width: 0;
    border: 1px solid #cfd8e3;
    border-radius: 10px;
    padding: 9px 10px;
    font-family: inherit;
}

.small-button {
    padding: 8px 12px;
    font-size: .9rem;
}

.button.danger {
    background: #9f1239;
    color: #fff;
}

.status-mini {
    display: inline-block;
    margin-top: 4px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    font-size: .78rem;
}

.lock-note {
    color: #991b1b;
    background: #fff1f2;
    border-right: 4px solid #e11d48;
    padding: 7px 10px;
    border-radius: 10px;
}

.reopen-note {
    color: #854d0e;
    background: #fef9c3;
    border-right: 4px solid #eab308;
    padding: 7px 10px;
    border-radius: 10px;
}

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

    .inline-stage-form {
        grid-template-columns: 1fr;
    }
}


/* Phase 2 - Permanent File + Detailed Workpapers */
.full-span {
    grid-column: 1 / -1;
}

.detailed-card.is-locked {
    border-inline-start: 6px solid #64748b;
    background: #f8fafc;
}

.detailed-card textarea {
    min-height: 92px;
}

.table-wrap input,
.table-wrap select,
.table-wrap textarea {
    width: 100%;
    min-width: 160px;
    box-sizing: border-box;
}

.table-wrap textarea {
    min-height: 64px;
}

@media print {
    .full-span {
        grid-column: auto;
    }
}

/* Phase 6 - Final audit file closure */
.button.danger { background: linear-gradient(135deg, #991b1b 0%, #dc2626 100%) !important; }
button:disabled, .button:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}
.clean-list {
    margin: 8px 0 0;
    padding: 0 24px 0 0;
}
.clean-list li {
    margin: 8px 0;
    padding: 8px 12px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    color: #9a3412;
    font-weight: 700;
}
hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 22px 0;
}

/* Phase 7 - Final report quality gate */
.quality-panel {
    border-radius: 14px;
    padding: 14px 16px;
    margin: 12px 0 16px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
}
.quality-panel.ok-panel {
    border-color: #bbf7d0;
    background: #f0fdf4;
}
.quality-panel.bad-panel {
    border-color: #fecaca;
    background: #fff1f2;
}
.quality-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}
.quality-head span {
    font-weight: 800;
}
.quality-list {
    margin: 8px 18px 0 0;
    padding: 0;
}
.quality-list li {
    margin-bottom: 6px;
    line-height: 1.8;
}
.quality-list.blockers li {
    color: #991b1b;
    font-weight: 700;
}
.quality-list.warnings li {
    color: #854d0e;
    font-weight: 700;
}
.quality-ok {
    color: #166534;
    font-weight: 800;
}
button[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

/* Phase 11 - Audit file index and office settings */
.form-grid label {
    display: grid;
    gap: 8px;
    align-content: start;
    font-weight: 700;
    color: #1f3552;
}
.form-grid .full { grid-column: 1 / -1; }
.checkline {
    display: flex !important;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.checkline input { width: auto; }
.inline-form {
    display: grid;
    gap: 8px;
    min-width: 210px;
}
.print-body {
    background: #fff;
    color: #111827;
    padding: 20px;
}
@media print {
    .print-body { padding: 0; }
}

.workflow-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.workflow-strip.large { margin-top: 18px; }
.workflow-step {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    padding: 8px 10px;
    box-shadow: 0 4px 12px rgba(15,23,42,.04);
    font-size: 13px;
}
.workflow-step a { text-decoration: none; color: #0f2740; font-weight: 700; }
.workflow-no {
    min-width: 26px;
    height: 26px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 12px;
}

/* Phase 13 - Runtime database selector */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin: 16px 0;
}
.mini-card {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 6px 18px rgba(15,23,42,.05);
}
.warning-card { background: #fff7ed; }
.error-box {
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
    background: #fff1f2;
    color: #991b1b;
    border: 1px solid #fecdd3;
    border-radius: 12px;
    padding: 12px;
    overflow: auto;
}
.form-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    background: #fff;
}
.form-grid .wide { grid-column: 1 / -1; }
.primary-actions { margin-top: 18px; }
code { direction: ltr; unicode-bidi: embed; }
.msg.info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* =========================
   Phase 14 - Arabic professional shell
   ========================= */
.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 315px minmax(0, 1fr);
    background: linear-gradient(180deg, #eef3f8 0%, #f6f8fb 100%);
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #0f2740 0%, #123a63 55%, #0b2238 100%);
    color: #fff;
    padding: 18px 16px 26px;
    border-left: 1px solid rgba(255,255,255,.12);
    box-shadow: -12px 0 35px rgba(15, 23, 42, .14);
}
.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 8px 18px;
    border-bottom: 1px solid rgba(255,255,255,.14);
    margin-bottom: 14px;
}
.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.18);
    font-size: 24px;
    font-weight: 800;
}
.sidebar-brand h1 {
    margin: 0;
    font-size: 20px;
}
.sidebar-brand p {
    margin: 4px 0 0;
    font-size: 12px;
    color: rgba(255,255,255,.74);
}
.sidebar-context {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 16px;
    padding: 12px 14px;
    margin: 10px 0;
}
.sidebar-context span, .sidebar-context small {
    display: block;
    color: rgba(255,255,255,.72);
    font-size: 12px;
}
.sidebar-context b {
    display: block;
    margin: 3px 0;
    color: #fff;
}
.side-nav {
    display: grid;
    gap: 7px;
    margin-top: 16px;
}
.side-nav a, .side-nav .nav-disabled {
    color: #fff;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,.075);
    border: 1px solid rgba(255,255,255,.08);
    font-weight: 700;
    font-size: 13px;
    line-height: 1.45;
}
.side-nav a:hover {
    background: rgba(255,255,255,.16);
}
.side-nav .nav-disabled {
    opacity: .54;
    cursor: not-allowed;
}
.nav-section-title {
    margin: 18px 4px 5px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,.13);
    color: #bfdbfe;
    font-size: 12px;
    font-weight: 800;
}
.main-area {
    min-width: 0;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}
.top-header {
    min-height: 72px;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #dbe4ef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 28px;
    position: sticky;
    top: 0;
    z-index: 5;
}
.top-header strong { color: #0f2740; font-size: 18px; display: block; }
.top-header span { color: #64748b; font-size: 13px; }
.app-shell .container { width: min(1500px, calc(100% - 48px)); }
.hero-card {
    border: 1px solid rgba(37, 99, 235, .16);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.workflow-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.workflow-step {
    background: #ffffff;
    border: 1px solid #dbe4ef;
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 58px;
}
.workflow-step a, .workflow-step span:not(.workflow-no) {
    color: #123a63;
    text-decoration: none;
    font-weight: 800;
}
.workflow-no {
    min-width: 34px;
    height: 34px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: #eaf2ff;
    color: #1d4ed8;
    font-weight: 800;
    direction: ltr;
}
.stage-list.professional { gap: 16px; }
.stage-card.professional, .stage-list.professional .stage-card {
    grid-template-columns: 92px minmax(0,1fr) 150px 210px;
    border-radius: 20px;
}
.stage-no span { display: block; color: #64748b; font-size: 12px; }
.stage-no strong { display: block; font-size: 24px; }
.status-mini {
    display: inline-block;
    margin-right: 6px;
    background: #eaf2ff;
    color: #1d4ed8;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 11px;
}
.inline-stage-form { display: grid; gap: 6px; }
.public-container { width: min(1100px, calc(100% - 40px)); }
.public-topbar { position: relative; }
@media (max-width: 1180px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .top-header { position: relative; }
    .stage-card.professional, .stage-list.professional .stage-card { grid-template-columns: 1fr; }
}

/* =========================
   Executive Command Dashboard
   ========================= */
.audit-command-dashboard {
    display: grid;
    gap: 18px;
}
.command-hero {
    position: relative;
    overflow: hidden;
    min-height: 280px;
    border-radius: 30px;
    padding: 34px;
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr);
    gap: 26px;
    align-items: center;
    color: #fff;
    background:
        radial-gradient(circle at 8% 18%, rgba(56,189,248,.45), transparent 28%),
        radial-gradient(circle at 82% 24%, rgba(37,99,235,.56), transparent 34%),
        linear-gradient(135deg, #081827 0%, #123a63 45%, #0f766e 100%);
    box-shadow: 0 22px 55px rgba(15, 23, 42, .18);
}
.command-hero::after {
    content: "";
    position: absolute;
    inset: 18px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 24px;
    pointer-events: none;
}
.command-hero h2 {
    margin: 8px 0 8px;
    font-size: clamp(34px, 4vw, 54px);
    line-height: 1.18;
    color: #fff;
}
.command-hero p {
    max-width: 720px;
    margin: 0;
    color: rgba(255,255,255,.82);
    font-size: 16px;
}
.eyebrow {
    color: #bfdbfe;
    letter-spacing: .5px;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}
.hero-copy, .hero-status-panel { position: relative; z-index: 1; }
.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}
.command-primary {
    background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%) !important;
    color: #fff !important;
    border: 0 !important;
    box-shadow: 0 14px 30px rgba(37,99,235,.24) !important;
}
.command-secondary {
    background: rgba(255,255,255,.92) !important;
    color: #123a63 !important;
    border: 1px solid rgba(148,163,184,.35) !important;
    box-shadow: 0 10px 22px rgba(15,23,42,.08) !important;
}
.hero-status-panel {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}
.status-orb {
    aspect-ratio: 1 / 1;
    border-radius: 999px;
    display: grid;
    place-items: center;
    text-align: center;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.22);
    box-shadow: inset 0 0 0 14px rgba(255,255,255,.06), 0 20px 40px rgba(0,0,0,.16);
}
.status-orb span {
    display: block;
    font-size: 42px;
    font-weight: 900;
    line-height: 1;
}
.status-orb small {
    display: block;
    color: rgba(255,255,255,.78);
    margin-top: 8px;
    font-weight: 800;
}
.status-orb.is-offline { box-shadow: inset 0 0 0 14px rgba(248,113,113,.12), 0 20px 40px rgba(0,0,0,.16); }
.status-list {
    display: grid;
    gap: 10px;
}
.status-list div {
    background: rgba(255,255,255,.11);
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 18px;
    padding: 13px 15px;
}
.status-list b {
    display: block;
    font-size: 26px;
    line-height: 1;
}
.status-list span {
    display: block;
    color: rgba(255,255,255,.76);
    font-size: 12px;
    margin-top: 6px;
}
.command-metrics {
    display: grid;
    grid-template-columns: 1.4fr repeat(3, minmax(180px, 1fr));
    gap: 14px;
}
.command-metric {
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(219,228,239,.96);
    border-radius: 22px;
    padding: 18px;
    box-shadow: 0 12px 30px rgba(15,23,42,.06);
    min-height: 128px;
    display: grid;
    align-content: center;
    gap: 5px;
}
.command-metric span, .command-metric small {
    color: #64748b;
    font-size: 13px;
    line-height: 1.6;
}
.command-metric b {
    font-size: 28px;
    color: #0f2740;
    line-height: 1.2;
}
.command-metric.action-metric { align-content: space-between; }
.cardless-panel {
    border-radius: 24px;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    background: linear-gradient(135deg, #ffffff 0%, #eef6ff 100%);
    border: 1px solid #dbeafe;
    box-shadow: 0 12px 32px rgba(15,23,42,.07);
}
.smart-next-step h3 {
    margin: 4px 0 5px;
    color: #0f2740;
    font-size: 22px;
}
.smart-next-step p {
    margin: 0;
    color: #64748b;
}
.command-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 345px;
    gap: 18px;
    align-items: start;
}
.section-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.section-title-row h3 {
    margin: 0;
    font-size: 24px;
    color: #0f2740;
}
.section-title-row p {
    margin: 4px 0 0;
    color: #64748b;
}
.engagement-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 14px;
}
.audit-file-card {
    background: #fff;
    border: 1px solid #dbe4ef;
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 12px 30px rgba(15,23,42,.07);
    position: relative;
    overflow: hidden;
}
.audit-file-card::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: #2563eb;
}
.audit-file-card.tone-good::before { background: #16a34a; }
.audit-file-card.tone-attention::before { background: #f59e0b; }
.audit-file-card.tone-closed::before { background: #64748b; }
.file-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}
.file-code {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 10px;
    background: #eaf2ff;
    color: #1d4ed8;
    direction: ltr;
    font-weight: 900;
    font-size: 12px;
}
.file-card-head h4 {
    margin: 10px 0 2px;
    color: #0f2740;
    font-size: 20px;
}
.file-card-head p {
    margin: 0;
    color: #64748b;
    font-size: 13px;
}
.health-pill {
    border-radius: 999px;
    padding: 8px 11px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-weight: 900;
    white-space: nowrap;
    font-size: 12px;
}
.progress-line { margin-top: 18px; }
.progress-meta {
    display: flex;
    justify-content: space-between;
    color: #64748b;
    font-size: 13px;
    margin-bottom: 8px;
}
.progress-meta strong { color: #0f2740; }
.smart-progress {
    height: 11px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}
.smart-progress span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #0ea5e9 0%, #2563eb 60%, #0f766e 100%);
}
.current-stage-box {
    margin-top: 14px;
    background: #f8fbff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 13px 14px;
}
.current-stage-box span {
    display: block;
    color: #64748b;
    font-size: 12px;
    margin-bottom: 3px;
}
.current-stage-box b {
    display: block;
    color: #0f2740;
}
.mini-signal-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.mini-signal-grid div {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px 8px;
    text-align: center;
}
.mini-signal-grid b {
    display: block;
    font-size: 18px;
    color: #0f2740;
}
.mini-signal-grid span {
    display: block;
    color: #64748b;
    font-size: 11px;
    margin-top: 2px;
}
.blocker-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 13px;
    min-height: 34px;
}
.blocker-strip span {
    border-radius: 999px;
    padding: 6px 9px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
    font-size: 12px;
    font-weight: 800;
}
.blocker-strip span.clean {
    background: #ecfdf5;
    color: #166534;
    border-color: #bbf7d0;
}
.compact-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.compact-actions .button {
    min-height: 40px;
    padding: 9px 13px;
    margin: 0;
}
.command-side {
    display: grid;
    gap: 14px;
    position: sticky;
    top: 88px;
}
.side-panel {
    background: #fff;
    border: 1px solid #dbe4ef;
    border-radius: 24px;
    padding: 18px;
    box-shadow: 0 12px 30px rgba(15,23,42,.06);
}
.side-panel h3 {
    margin: 0 0 12px;
    color: #0f2740;
}
.side-panel > a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    background: #f8fbff;
    color: #123a63;
    text-decoration: none;
    font-weight: 900;
    margin-top: 8px;
}
.side-panel > a span,
.timeline-step span {
    min-width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border-radius: 12px;
    background: #eaf2ff;
    color: #1d4ed8;
    direction: ltr;
    font-weight: 900;
}
.timeline-step {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 9px 0;
    border-bottom: 1px dashed #e2e8f0;
}
.timeline-step a,
.timeline-step b {
    color: #123a63;
    text-decoration: none;
    font-weight: 800;
    line-height: 1.5;
}
.timeline-step.compact a,
.timeline-step.compact b { font-size: 13px; }
.timeline-more summary {
    cursor: pointer;
    margin-top: 10px;
    color: #1d4ed8;
    font-weight: 900;
}
.empty-state-pro {
    grid-column: 1 / -1;
    text-align: center;
    border: 1px dashed #cbd5e1;
    background: #fff;
    border-radius: 24px;
    padding: 34px;
}
.empty-state-pro h3 { margin: 0 0 6px; color: #0f2740; }
.empty-state-pro p { color: #64748b; margin: 0 0 16px; }
@media (max-width: 1280px) {
    .command-hero,
    .command-grid,
    .command-metrics {
        grid-template-columns: 1fr;
    }
    .command-side { position: relative; top: 0; }
}
@media (max-width: 760px) {
    .command-hero { padding: 24px; border-radius: 24px; }
    .hero-status-panel { grid-template-columns: 1fr; }
    .status-orb { width: 180px; margin: 0 auto; }
    .cardless-panel,
    .section-title-row,
    .file-card-head { flex-direction: column; }
    .engagement-board { grid-template-columns: 1fr; }
    .mini-signal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Collapsible sidebar navigation - reduces visual clutter */
.compact-side-nav {
    gap: 8px;
}
.compact-side-nav details {
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 14px;
    background: rgba(255,255,255,.055);
    overflow: hidden;
}
.compact-side-nav summary {
    cursor: pointer;
    list-style: none;
    padding: 11px 12px;
    color: #bfdbfe;
    font-size: 13px;
    font-weight: 900;
}
.compact-side-nav summary::-webkit-details-marker { display: none; }
.compact-side-nav summary::before {
    content: "+";
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-left: 8px;
    border-radius: 8px;
    background: rgba(255,255,255,.10);
    color: #fff;
    direction: ltr;
}
.compact-side-nav details[open] summary::before { content: "−"; }
.compact-side-nav details a,
.compact-side-nav details .nav-disabled {
    display: block;
    margin: 0 8px 8px;
    background: rgba(255,255,255,.065);
}
.compact-side-nav .nav-home {
    background: rgba(96,165,250,.22) !important;
    border-color: rgba(191,219,254,.24) !important;
}

/* Audit Analytics & Anomalies Center */
.analytics-hero {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 18px;
    align-items: stretch;
    margin-bottom: 18px;
}
.quick-run-form {
    background: rgba(255,255,255,.76);
    border: 1px solid rgba(148,163,184,.25);
    border-radius: 18px;
    padding: 14px;
    display: grid;
    gap: 10px;
}
.analytics-kpis {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.kpi-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 10px 26px rgba(15,23,42,.06);
}
.kpi-card span { display:block; color:#64748b; font-size: 13px; margin-bottom: 8px; }
.kpi-card b { font-size: 26px; color:#0f172a; }
.kpi-card.warning { border-color:#facc15; }
.kpi-card.danger { border-color:#fb7185; }
.bar-list { display:grid; gap: 10px; }
.bar-row { display:grid; grid-template-columns: 220px 1fr 45px; gap: 10px; align-items:center; }
.bar-track { height: 12px; border-radius: 999px; background:#e2e8f0; overflow:hidden; }
.bar-track i { display:block; height:100%; border-radius:999px; background:#1d4ed8; }
.compact-run-list { display:grid; gap:8px; }
.compact-run-list > div { display:flex; justify-content:space-between; gap:12px; padding:10px 12px; border:1px solid #e2e8f0; border-radius:14px; background:#f8fafc; }
.compact-run-list span { color:#64748b; }
.section-title.spread { display:flex; justify-content:space-between; gap:14px; align-items:flex-start; }
.inline-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.row-actions { min-width: 160px; }
.button.small { padding: 6px 10px; font-size: 12px; margin: 2px; }
.pill { display:inline-block; padding:4px 8px; border-radius:999px; background:#e0f2fe; color:#075985; margin:2px; font-size:12px; }
.pill.success { background:#dcfce7; color:#166534; }
.muted { color:#64748b; }
.empty-state { padding:16px; border:1px dashed #cbd5e1; border-radius:14px; background:#f8fafc; color:#64748b; }
.wide-table textarea { min-width: 240px; min-height: 72px; }
@media (max-width: 1100px) {
    .analytics-hero { grid-template-columns: 1fr; }
    .analytics-kpis { grid-template-columns: repeat(2, 1fr); }
    .bar-row { grid-template-columns: 1fr; }
    .section-title.spread { display:block; }
}

/* Excel/mod alignment core */
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
.grid-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 700;
    color: #334155;
}
.grid-form input,
.grid-form select,
.grid-form textarea,
.inline-form input,
.inline-form select,
.inline-form textarea {
    border: 1px solid var(--border, #dbe3ef);
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
    font-family: inherit;
}
.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.kpi {
    background: #fff;
    border: 1px solid var(--border, #dbe3ef);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
}
.kpi span { display:block; color:#64748b; font-size:13px; margin-bottom:8px; }
.kpi b { font-size:28px; color:#0f172a; }

/* =========================
   Branding + amount comma formatting patch
   ========================= */
.brand-logo {
    display: inline-block;
    object-fit: contain;
    flex: 0 0 auto;
}
.sidebar-brand-logo {
    width: 58px;
    height: 58px;
    padding: 4px;
    border-radius: 18px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
    box-shadow: 0 10px 26px rgba(0,0,0,.15);
}
.top-header-brand,
.public-brand,
.login-brand-card {
    display: flex;
    align-items: center;
    gap: 14px;
}
.top-header-logo {
    width: 46px;
    height: 46px;
}
.public-brand-logo {
    width: 64px;
    height: 64px;
    padding: 3px;
    border-radius: 20px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.18);
}
.login-card-enhanced {
    max-width: 620px;
    padding: 30px;
}
.login-brand-card {
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.login-logo {
    width: 82px;
    height: 82px;
}
.login-brand-card h2 {
    margin: 0;
    color: #0f2740;
    font-size: 30px;
}
.login-brand-card p,
.login-note {
    margin: 8px 0 0;
    color: var(--muted);
}
.login-actions .button {
    min-width: 170px;
}
.money-input,
input.money-input {
    direction: ltr !important;
    text-align: left !important;
    font-family: Tahoma, Arial, sans-serif;
    font-variant-numeric: tabular-nums;
}
.money-display,
[data-money-display="1"],
.num {
    font-variant-numeric: tabular-nums;
}
@media (max-width: 760px) {
    .top-header-brand,
    .public-brand,
    .login-brand-card {
        align-items: flex-start;
    }
    .top-header-logo { width: 40px; height: 40px; }
    .public-brand-logo { width: 52px; height: 52px; }
    .login-logo { width: 70px; height: 70px; }
}

/* Billing, invoice printing, and JPEG logo refinement */
.sidebar-brand-logo,
.public-brand-logo,
.login-logo,
.top-header-logo,
.invoice-print-logo {
    background: #fff;
    object-fit: contain;
}
.top-header-logo { border-radius: 12px; padding: 2px; }
.invoice-issue-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(130px, 1fr));
    gap: 8px;
    min-width: 390px;
}
.invoice-issue-form label {
    display: grid;
    gap: 5px;
    font-size: 12px;
    color: #334155;
    font-weight: 700;
}
.invoice-issue-form .invoice-notes-label,
.invoice-issue-form button {
    grid-column: 1 / -1;
}
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--border);
    background: #f8fafc;
    color: #475569;
}
.status-pill.ok {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #166534;
}
.status-pill.draft {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}
.small-button {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 9px;
}
.mini-action-form {
    margin-top: 6px;
}
.action-cell {
    min-width: 140px;
}
.print-toolbar {
    width: min(900px, calc(100% - 40px));
    margin: 18px auto;
    display: flex;
    justify-content: flex-start;
    gap: 8px;
}
.invoice-print-page {
    width: min(900px, calc(100% - 40px));
    margin: 20px auto;
    background: #fff;
    border: 1px solid #d7dde8;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 12px 30px rgba(15,23,42,.08);
}
.invoice-print-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 16px;
    margin-bottom: 18px;
}
.invoice-print-logo {
    width: 110px;
    max-height: 110px;
    border-radius: 18px;
}
.invoice-print-header h1 {
    margin: 0;
    font-size: 28px;
    color: #7f1027;
}
.invoice-print-header p {
    margin: 6px 0 0;
    color: #475569;
    font-weight: 700;
}
.invoice-print-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.invoice-print-meta div {
    border: 1px solid #dbe4ef;
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px;
}
.invoice-print-meta span {
    display: block;
    color: #64748b;
    font-size: 12px;
}
.invoice-print-meta b {
    display: block;
    margin-top: 4px;
    color: #0f172a;
}
.invoice-client-box {
    margin-bottom: 18px;
}
.invoice-client-box h2,
.invoice-notes-print h2 {
    font-size: 18px;
    margin: 0 0 10px;
    color: #0f2740;
}
.invoice-print-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.invoice-print-table th,
.invoice-print-table td {
    border: 1px solid #dbe4ef;
    padding: 12px;
    text-align: right;
}
.invoice-print-table th {
    background: #f1f5f9;
}
.invoice-total-row td {
    background: #f8fafc;
    font-weight: 800;
    font-size: 17px;
}
.invoice-notes-print {
    margin-top: 18px;
    border: 1px solid #dbe4ef;
    border-radius: 12px;
    padding: 14px;
}
.invoice-print-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 34px;
    padding-top: 22px;
    border-top: 1px solid #dbe4ef;
    color: #475569;
    font-weight: 700;
}
@media print {
    .no-print,
    .topbar,
    .sidebar,
    .top-header,
    footer { display: none !important; }
    .invoice-print-page {
        width: 100%;
        margin: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 12mm;
    }
    .invoice-print-body { background: #fff; }
}

/* Phase 25 invoice official fees */
.invoice-auto-fees-note {
    grid-column: 1 / -1;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.05);
    color: #475569;
    font-size: 13px;
    line-height: 1.7;
}
.checkbox-label.invoice-foreign-label {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid rgba(15, 23, 42, 0.10);
    border-radius: 12px;
    background: #fff;
    color: #334155;
    font-weight: 700;
}
.checkbox-label.invoice-foreign-label input {
    width: auto;
    min-width: 18px;
    height: 18px;
}


/* =========================================================
   TAWAZON Audit Premium Theme - Logo color system
   This block intentionally overrides older blue styling globally.
   ========================================================= */
:root{
    --bg: #f7f4f5;
    --surface: #ffffff;
    --surface-soft: #fff9fa;
    --surface-muted: #f4edf0;
    --border: #eadbe0;
    --text: #252933;
    --muted: #68707c;
    --brand: #8f102a;
    --brand-2: #c71d3a;
    --brand-dark: #6f0d20;
    --brand-soft: #fff1f4;
    --brand-soft-2: #f9e6eb;
    --brand-gradient: linear-gradient(135deg, #6f0d20 0%, #98142b 48%, #c71d3a 100%);
    --brand-gradient-soft: linear-gradient(135deg, #8f102a 0%, #b81935 55%, #df3149 100%);
    --shadow: 0 12px 30px rgba(96, 22, 37, .10);
    --shadow-strong: 0 18px 46px rgba(96, 22, 37, .18);
    --radius: 20px;
    --radius-sm: 13px;
}

html, body{
    background:
        radial-gradient(circle at top right, rgba(199,29,58,.075), transparent 28%),
        radial-gradient(circle at bottom left, rgba(111,13,32,.07), transparent 32%),
        var(--bg) !important;
    color: var(--text);
}
body{
    font-family: Tahoma, Arial, "Segoe UI", sans-serif;
}
a{ color: var(--brand-2); }

/* Shell */
.app-shell{
    background:
        radial-gradient(circle at 95% 0%, rgba(199,29,58,.08), transparent 28%),
        linear-gradient(180deg, #fbf7f8 0%, var(--bg) 100%) !important;
}
.sidebar{
    background: var(--brand-gradient) !important;
    border-left: 1px solid rgba(255,255,255,.14) !important;
    box-shadow: -16px 0 42px rgba(94, 10, 31, .22) !important;
}
.sidebar::-webkit-scrollbar{ width: 8px; }
.sidebar::-webkit-scrollbar-thumb{ background: rgba(255,255,255,.22); border-radius: 999px; }
.sidebar-brand{
    background: rgba(255,255,255,.075);
    border: 1px solid rgba(255,255,255,.12) !important;
    border-radius: 22px;
    padding: 14px 12px !important;
    margin-bottom: 16px !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.sidebar-brand h1{ color:#fff !important; font-weight:900; letter-spacing:.1px; }
.sidebar-brand p{ color:rgba(255,255,255,.82) !important; }
.sidebar-context{
    background: rgba(255,255,255,.092) !important;
    border-color: rgba(255,255,255,.16) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.sidebar-context.active-file{
    background: rgba(255,255,255,.14) !important;
    border-color: rgba(255,255,255,.22) !important;
}
.compact-side-nav details,
.side-nav a,
.side-nav .nav-disabled{
    background: rgba(255,255,255,.07) !important;
    border-color: rgba(255,255,255,.10) !important;
}
.compact-side-nav summary{
    color: #ffe6eb !important;
}
.compact-side-nav summary::before{
    background: rgba(255,255,255,.14) !important;
}
.side-nav a:hover,
.compact-side-nav details a:hover{
    background: rgba(255,255,255,.16) !important;
    transform: translateX(-2px);
}
.compact-side-nav .nav-home,
.side-nav a.active{
    background: rgba(255,255,255,.19) !important;
    border-color: rgba(255,255,255,.28) !important;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

/* Top header */
.top-header{
    background: rgba(255,255,255,.94) !important;
    border-bottom: 1px solid var(--border) !important;
    box-shadow: 0 10px 30px rgba(96,22,37,.075);
}
.top-header strong,
.page-head h2,
.card-header h2,
.card-header h3,
.section-header h3,
.card > h2,
.card > h3,
.metric strong,
.summary span b,
.detail-item .value,
.workflow-step a,
.workflow-step span:not(.workflow-no){
    color: var(--brand-dark) !important;
}
.top-header span{ color: var(--muted) !important; }

/* Public header */
.topbar,
.public-topbar{
    background: var(--brand-gradient) !important;
    box-shadow: 0 14px 34px rgba(96,22,37,.20) !important;
}
.topbar nav a{
    background: rgba(255,255,255,.12) !important;
    border-color: rgba(255,255,255,.18) !important;
}
.topbar nav a:hover{ background: rgba(255,255,255,.22) !important; }
.brand-block h1{ color:#fff !important; }
.brand-block p{ color:rgba(255,255,255,.84) !important; }

/* Logo presentation */
.brand-logo{
    object-fit: contain !important;
    background: #fff !important;
    border: 1px solid rgba(143,16,42,.12) !important;
    box-shadow: 0 12px 24px rgba(96,22,37,.16) !important;
}
.sidebar-brand-logo{
    width: 68px !important;
    height: 68px !important;
    border-radius: 21px !important;
    padding: 4px !important;
}
.top-header-logo{
    width: 54px !important;
    height: 54px !important;
    border-radius: 16px !important;
    padding: 3px !important;
}
.public-brand-logo,
.login-logo{
    border-radius: 24px !important;
}

/* Cards and page sections */
.container{ position: relative; }
.card,
.form-card,
.stage-card,
.risk-card,
.kpi,
.kpi-card,
.report-standard-box,
.workflow-step,
.detail-item,
.summary span,
.quick-run-form,
.empty-state{
    background: linear-gradient(180deg, #ffffff 0%, #fffafb 100%) !important;
    border-color: var(--border) !important;
    box-shadow: var(--shadow) !important;
}
.card{
    border-radius: 22px !important;
}
.card-header,
.section-header{
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}
.hero-card{
    border-color: rgba(143,16,42,.18) !important;
    background:
        radial-gradient(circle at top right, rgba(199,29,58,.08), transparent 32%),
        linear-gradient(180deg, #ffffff 0%, #fff7f9 100%) !important;
}
.page-head .meta-badge,
.badge,
.pill,
.head-chip{
    background: var(--brand-soft) !important;
    color: var(--brand-dark) !important;
    border-color: #f0cbd4 !important;
}

/* Buttons */
.button,
button,
input[type="submit"]{
    background: var(--brand-gradient-soft) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 13px !important;
    box-shadow: 0 10px 20px rgba(143,16,42,.20) !important;
}
.button:hover,
button:hover,
input[type="submit"]:hover{
    filter: brightness(1.04);
    transform: translateY(-1px);
}
.button.secondary,
button.secondary,
.button.outline,
.btn-outline-primary{
    background: #fff !important;
    color: var(--brand) !important;
    border: 1px solid #e2c5ce !important;
    box-shadow: none !important;
}
.button.success,
.report-standards-btn{
    background: linear-gradient(135deg, #187044 0%, #1f8b4c 100%) !important;
}
.button.warning{ background: linear-gradient(135deg, #b9780a 0%, #d99412 100%) !important; }
.button.danger{ background: linear-gradient(135deg, #a3122c 0%, #c53737 100%) !important; }

/* Forms */
.field,
.form label,
label,
.form-label{
    color: var(--brand-dark) !important;
}
input,
select,
textarea{
    border-color: #dfcbd1 !important;
    border-radius: 13px !important;
    background: #fff !important;
}
input:focus,
select:focus,
textarea:focus{
    border-color: var(--brand-2) !important;
    box-shadow: 0 0 0 4px rgba(199,29,58,.12) !important;
}
input[disabled], select[disabled], textarea[disabled]{
    background: #f7eff2 !important;
    color: #5f6670 !important;
}
.inline-check{
    background: #fff8fa !important;
    border-color: var(--border) !important;
}

/* Tables */
thead th,
.final-table th,
.invoice-items th{
    background: linear-gradient(180deg, #fff1f4 0%, #f8dfe6 100%) !important;
    color: var(--brand-dark) !important;
    border-bottom-color: #e6c0ca !important;
}
th, td{ border-bottom-color: #f0e3e7 !important; }
tbody tr:nth-child(even){ background: #fffafa !important; }
tbody tr:hover{ background: #fff3f6 !important; }
.table-card{ border-color: var(--border) !important; }
.num,
.money-input,
.money-display,
[data-money-display="1"]{
    font-variant-numeric: tabular-nums;
}

/* Messages and statuses */
.msg.success{ background:#eef9f2 !important; color:#1f8b4c !important; border-color:#cde8d7 !important; }
.msg.error{ background:#fff1f4 !important; color:#a3122c !important; border-color:#f0c6d0 !important; }
.msg.info{ background:#fff4f6 !important; color:var(--brand) !important; border-color:#f0cbd4 !important; }
.ok{ color:#1f8b4c !important; }
.bad{ color:#b31332 !important; }
.progress-bar{
    background: linear-gradient(90deg, #8f102a 0%, #c71d3a 100%) !important;
}
.progress-wrap{ background:#eadbe0 !important; }
.stage-card.current{ border-right-color: var(--brand-2) !important; }
.stage-card.done{ border-right-color: #1f8b4c !important; }
.risk-card.risk-high{ border-right-color:#b31332 !important; }
.risk-card.risk-medium{ border-right-color:#d99412 !important; }
.risk-card.risk-low{ border-right-color:#1f8b4c !important; }

/* Login page */
body.login-body{
    min-height: 100vh;
    background:
        radial-gradient(circle at 85% 12%, rgba(199,29,58,.16), transparent 30%),
        radial-gradient(circle at 12% 85%, rgba(111,13,32,.13), transparent 34%),
        linear-gradient(135deg, #fbf7f8 0%, #f2e8ec 100%) !important;
}
body.login-body .public-topbar{
    max-width: min(1080px, calc(100% - 34px));
    margin: 18px auto 0;
    border-radius: 26px;
    overflow: hidden;
}
body.login-body .public-container{
    min-height: calc(100vh - 165px);
    display: grid;
    place-items: center;
}
.login-card-enhanced{
    width: min(560px, 100%) !important;
    border: 1px solid rgba(143,16,42,.16) !important;
    border-radius: 28px !important;
    box-shadow: var(--shadow-strong) !important;
    background: rgba(255,255,255,.96) !important;
    backdrop-filter: blur(10px);
}
.login-brand-card{
    justify-content: center;
    text-align: center;
    flex-direction: column;
    border-bottom-color: var(--border) !important;
}
.login-brand-card h2{
    color: var(--brand-dark) !important;
    font-size: 32px !important;
    font-weight: 900;
}
.login-actions{ justify-content: center; }
.login-actions .button{ min-width: 210px; }
.login-note{ text-align: center; }

/* Invoice/print visual alignment */
.invoice-print-page,
.print-page{
    border-color: #e6cbd3 !important;
}
.invoice-print-title h1,
.print-header h1,
.print-section h2{
    color: var(--brand-dark) !important;
}
.invoice-print-header,
.print-header{
    border-bottom-color: var(--brand) !important;
}
.invoice-total-row td{
    background: #fff1f4 !important;
    color: var(--brand-dark) !important;
}
.invoice-auto-fees-note{
    background: #fff4f6 !important;
    color: var(--brand-dark) !important;
    border: 1px solid #f0cbd4;
}

footer{
    color: #7e6570 !important;
}

@media (max-width: 1000px){
    .sidebar-brand-logo{ width:58px !important; height:58px !important; }
    .top-header-logo{ width:44px !important; height:44px !important; }
    body.login-body .public-topbar{ border-radius: 0; margin:0; max-width:100%; }
}
@media print{
    body,
    html{
        background:#fff !important;
    }
    .brand-logo{ box-shadow:none !important; }
    .button, button{ box-shadow:none !important; }
}

/* =========================
   TAWAZON Audit dashboard command center theme override
   Applies the logo burgundy identity to the main dashboard hero and cards.
   ========================= */
.audit-command-dashboard{
    gap: 20px !important;
}
.command-hero{
    background:
        radial-gradient(circle at 9% 12%, rgba(255,255,255,.18), transparent 24%),
        radial-gradient(circle at 82% 20%, rgba(223,49,73,.30), transparent 28%),
        radial-gradient(circle at 48% 88%, rgba(143,16,42,.22), transparent 34%),
        linear-gradient(135deg, #5d0918 0%, #8f102a 42%, #c71d3a 100%) !important;
    box-shadow: 0 24px 58px rgba(111,13,32,.24) !important;
    border: 1px solid rgba(255,255,255,.16) !important;
}
.command-hero::after{
    border-color: rgba(255,255,255,.18) !important;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.05);
}
.command-hero-brand{
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 18px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.17);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
    margin-bottom: 8px;
}
.command-hero-brand img{
    width: 58px;
    height: 58px;
    object-fit: contain;
    border-radius: 16px;
    background: rgba(255,255,255,.94);
    padding: 5px;
    box-shadow: 0 12px 26px rgba(62,5,18,.22);
}
.command-hero-brand strong{
    display: block;
    color: #fff;
    font-size: 15px;
    font-weight: 900;
    letter-spacing: .2px;
}
.command-hero .eyebrow,
.audit-command-dashboard .eyebrow{
    color: #ffdce4 !important;
}
.command-hero h2{
    text-shadow: 0 10px 26px rgba(53,4,14,.22);
}
.command-hero p{
    color: rgba(255,245,248,.88) !important;
}
.command-primary{
    background: linear-gradient(135deg, #b31332 0%, #d7193f 100%) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,.13) !important;
    box-shadow: 0 14px 30px rgba(143,16,42,.26) !important;
}
.command-primary:hover{
    filter: brightness(1.05);
    transform: translateY(-1px);
}
.command-secondary{
    background: rgba(255,255,255,.94) !important;
    color: #7c0d23 !important;
    border: 1px solid rgba(143,16,42,.18) !important;
    box-shadow: 0 10px 22px rgba(93,9,24,.10) !important;
}
.command-secondary:hover{
    background: #fff3f6 !important;
    color: #5d0918 !important;
}
.status-orb{
    background: rgba(255,255,255,.13) !important;
    border-color: rgba(255,255,255,.25) !important;
    box-shadow: inset 0 0 0 14px rgba(255,255,255,.07), 0 20px 44px rgba(65,5,17,.22) !important;
}
.status-list div{
    background: rgba(255,255,255,.13) !important;
    border-color: rgba(255,255,255,.18) !important;
}
.command-metric,
.audit-file-card,
.side-panel,
.empty-state-pro,
.cardless-panel{
    border-color: #ead2d9 !important;
    box-shadow: 0 14px 34px rgba(111,13,32,.08) !important;
}
.command-metric{
    background: linear-gradient(180deg, #ffffff 0%, #fff8fa 100%) !important;
}
.command-metric b,
.section-title-row h3,
.file-card-head h4,
.smart-next-step h3,
.side-panel h3,
.empty-state-pro h3,
.progress-meta strong,
.current-stage-box b,
.mini-signal-grid b{
    color: #5d0918 !important;
}
.command-metric span,
.command-metric small,
.section-title-row p,
.file-card-head p,
.smart-next-step p,
.progress-meta,
.current-stage-box span,
.mini-signal-grid span,
.empty-state-pro p{
    color: #7e6570 !important;
}
.cardless-panel{
    background: linear-gradient(135deg, #ffffff 0%, #fff2f5 100%) !important;
}
.audit-file-card::before{
    background: linear-gradient(180deg, #8f102a 0%, #c71d3a 100%) !important;
}
.audit-file-card.tone-good::before{ background: #1f8b4c !important; }
.audit-file-card.tone-attention::before{ background: #d99412 !important; }
.audit-file-card.tone-closed::before{ background: #7e6570 !important; }
.file-code{
    background: #fff1f4 !important;
    color: #8f102a !important;
    border: 1px solid #f0cbd4 !important;
}
.health-pill{
    background: #fff7f9 !important;
    border-color: #ead2d9 !important;
    color: #7c0d23 !important;
}
.smart-progress{
    background: #eadbe0 !important;
}
.smart-progress span{
    background: linear-gradient(90deg, #8f102a 0%, #c71d3a 66%, #df3149 100%) !important;
}
.current-stage-box,
.side-panel > a,
.mini-signal-grid div{
    background: #fff8fa !important;
    border-color: #ead2d9 !important;
}
.side-panel > a,
.timeline-step a,
.timeline-step b{
    color: #7c0d23 !important;
}
.side-panel > a span,
.timeline-step span{
    background: #fff1f4 !important;
    color: #8f102a !important;
    border: 1px solid #f0cbd4;
}
.timeline-step{
    border-bottom-color: #eadbe0 !important;
}
.timeline-more summary{
    color: #b31332 !important;
}
.blocker-strip span{
    background: #fff7e8 !important;
    color: #9a5a00 !important;
    border-color: #f1ddb1 !important;
}
.blocker-strip span.clean{
    background: #eef9f2 !important;
    color: #1f8b4c !important;
    border-color: #cde8d7 !important;
}
@media (max-width: 760px){
    .command-hero-brand{
        align-items: flex-start;
    }
    .command-hero-brand img{
        width: 50px;
        height: 50px;
    }
}

/* Dashboard unique company identity */
.audit-file-card .company-identity{
    color: var(--text-muted, #7d8694);
    font-size: .82rem;
    margin: 4px 0 2px;
    font-weight: 700;
}
