:root {
    --ink: #12221f;
    --teal: #0d4f4a;
    --teal-deep: #083632;
    --teal-soft: #e6f2f0;
    --gold: #b8954a;
    --gold-soft: #f4ead2;
    --cream: #f3eee4;
    --paper: #fffdf8;
    --muted: #6b7280;
    --line: #e4d9c8;
    --success: #1b7a4a;
    --success-soft: #dcf5e7;
    --danger: #b42318;
    --danger-soft: #fde8e6;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --info: #1d4ed8;
    --info-soft: #dbeafe;
    --debit: #0d4f4a;
    --credit: #1b7a4a;
    --due: #b42318;
    --shadow: 0 12px 28px rgba(18, 34, 31, 0.08);
    --radius: 16px;
    --sidebar: 272px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--cream);
    color: var(--ink);
    font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-deep); }

.app {
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar);
    flex: 0 0 var(--sidebar);
    background: var(--teal-deep);
    color: #f4ead2;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 14px 10px 10px;
    overflow: visible;
    text-align: right;
    position: relative;
    transition: width .2s ease, flex-basis .2s ease, padding .2s ease;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 4px 8px 16px;
    border-bottom: 1px solid rgba(244, 234, 210, 0.12);
    margin-bottom: 12px;
    flex-shrink: 0;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--gold);
    color: var(--teal-deep);
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: -0.04em;
    flex-shrink: 0;
}

.brand h1 {
    margin: 0;
    font-size: 16px;
    color: #fff;
}

.brand p {
    margin: 2px 0 0;
    font-size: 11px;
    color: #d6c49a;
}

.brand-mark.brand-logo {
    background: #fffdf8;
    padding: 2px;
    overflow: hidden;
}
.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.logo-box {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 18px;
    align-items: start;
}
.logo-preview {
    width: 160px;
    height: 160px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--muted);
    font-size: 13px;
}
.logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.logo-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    margin-top: 10px;
}

.nav-group {
    font-size: 11px;
    color: #c4b48a;
    margin: 8px 10px 4px;
    letter-spacing: 0.04em;
}

.nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(184, 149, 74, 0.35) transparent;
}

.nav::-webkit-scrollbar { width: 5px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb {
    background: rgba(184, 149, 74, 0.35);
    border-radius: 99px;
}

.nav a {
    display: block;
    color: #efe6d4;
    padding: 7px 12px;
    border-radius: 8px;
    margin-bottom: 2px;
    font-size: 13px;
    width: 100%;
    text-align: right;
    line-height: 1.4;
}

.nav a:hover,
.nav a.active {
    background: rgba(184, 149, 74, 0.18);
    color: #fff;
}

.nav a.active {
    box-shadow: inset -3px 0 0 var(--gold);
}

.app.nav-hidden .sidebar {
    width: 0;
    flex-basis: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
}
.app.nav-hidden .sidebar .brand,
.app.nav-hidden .sidebar .nav,
.app.nav-hidden .sidebar .sidebar-foot {
    display: none;
}

.is-go[data-href], table.data tr.is-go { cursor: pointer; }
table.data tr.is-go:hover td { background: #eef6f4; }
a.cell-go { font-weight: 700; }

.assist-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.inline-form { display: inline; margin: 0; }
.pref-card { margin-bottom: 14px; }
.pref-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.pref-form .field { margin: 0; min-width: 200px; }
.pref-save { min-width: 200px; }
.days-input {
    display: flex;
    align-items: center;
    gap: 8px;
}
.days-input input[type="number"],
.group-form input[type="number"],
.sched-form input[type="number"] {
    width: 72px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.law-strip {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f6f1e8;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    color: var(--teal-deep);
    line-height: 1.7;
}
.group-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin: 0 0 12px;
    padding: 10px 12px;
    background: #f8faf9;
    border: 1px dashed var(--line);
    border-radius: 10px;
}
.group-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.group-lab, .group-form label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.sched-form {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.sched-form select,
.group-form select {
    font-family: inherit;
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.sched-custom {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.sched-custom[hidden] { display: none; }
.sched-custom label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
}
.sched-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}
.muted { color: var(--muted); font-size: 12px; font-weight: 500; }
.class-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}
.ledger-card { padding-top: 14px; }
.ledger-head {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--teal-deep);
    margin: 0 0 10px;
}
.muted { color: var(--muted); font-weight: 500; font-size: 13px; }

.hub-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.hub-card {
    display: block;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 16px 14px;
    color: inherit;
    min-height: 132px;
}
.hub-card:hover {
    border-color: var(--gold);
    color: inherit;
}
.hub-kicker {
    font-size: 11px;
    color: var(--gold);
    font-weight: 800;
    margin-bottom: 4px;
}
.hub-card h4 {
    margin: 0;
    font-size: 16px;
    color: var(--teal-deep);
}
.hub-num {
    font-size: 28px;
    font-weight: 800;
    color: var(--teal);
    margin: 8px 0 4px;
    line-height: 1.15;
}
.hub-num-sm { font-size: 15px; }
.hub-card p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}
.dash-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}
.report-form { margin: 0; }
.report-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}
.report-custom-dates { display: none; }
.period-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin: 0 0 14px;
}
.period-bar .field {
    margin: 0;
    min-width: 220px;
}
.page-find {
    margin: 0 0 14px;
}
.page-find .field { margin: 0; }
.page-find input {
    width: 100%;
    max-width: 640px;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
}
.tbl-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.tbl-tools .tbl-search {
    min-width: 220px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 13px;
}
.col-pick { position: relative; }
.col-pick-box {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    min-width: 220px;
    max-height: 280px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 10px 12px;
    text-align: right;
}
.col-pick-box label {
    display: block;
    margin: 4px 0;
    font-size: 13px;
    cursor: pointer;
}
table.smart-table .col-off,
table.data .col-off { display: none !important; }
.desk-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 16px;
}
.desk-nav a {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    color: inherit;
}
.desk-nav a:hover { border-color: var(--gold); color: inherit; }
.desk-sec { margin-bottom: 8px; }
.desk-sec h3 { margin-top: 0; }
@media print {
    .col-pick, .tbl-tools, .desk-nav { display: none !important; }
}
.year-hint {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
}

.quick-card {
    display: block;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 16px;
    color: inherit;
}

.quick-card:hover {
    border-color: var(--gold);
    color: inherit;
}

.quick-card .mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--teal-soft);
    color: var(--teal-deep);
    display: grid;
    place-items: center;
    font-weight: 800;
    margin-bottom: 12px;
}

.quick-card h4 {
    margin: 0 0 6px;
    font-size: 16px;
    color: var(--teal-deep);
}

.quick-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

@media (max-width: 1100px) {
    .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .quick-grid { grid-template-columns: 1fr; }
}

.sidebar-foot {
    flex-shrink: 0;
    margin-top: 8px;
    padding: 12px 10px 4px;
    font-size: 12px;
    color: #c9b88a;
    border-top: 1px solid rgba(244, 234, 210, 0.12);
}

.main {
    flex: 1;
    min-width: 0;
    height: 100vh;
    overflow: auto;
    padding: 18px 22px 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar h2 {
    margin: 0;
    font-size: 24px;
}

.topbar .sub {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.user-chip {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow);
}

.btn, button.btn, a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: 10px;
    padding: 9px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-deep); color: #fff; }
.btn-gold { background: var(--gold); color: var(--teal-deep); }
.btn-ghost { background: transparent; color: var(--teal); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

.grid {
    display: grid;
    gap: 16px;
}

.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.kpi, .card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card { padding: 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 16px; color: var(--teal-deep); }
.grid > .card,
.grid > .kpi,
.dash-3 > .card { margin-bottom: 0; }

.kpi {
    padding: 16px 18px;
    min-height: 118px;
    display: flex;
    flex-direction: column;
}
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi .label-mean {
    color: var(--teal-deep);
    font-size: 12px;
    font-weight: 700;
    margin-top: 2px;
    line-height: 1.4;
}
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 8px; color: var(--teal-deep); line-height: 1.2; }
.kpi .value-money { font-size: 18px; }
.kpi .hint { margin-top: auto; padding-top: 8px; font-size: 12px; color: var(--gold); }
a.kpi {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(13, 79, 74, 0.14);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
a.kpi:hover, a.kpi:focus {
    border-color: var(--teal);
    background: #f4faf8;
    box-shadow: 0 8px 22px rgba(13, 79, 74, 0.12);
    outline: none;
}
a.ledger-head {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    padding: 8px 10px;
    margin: 0 -10px 10px;
    border-radius: 10px;
    -webkit-tap-highlight-color: rgba(13, 79, 74, 0.14);
}
a.ledger-head:hover, a.ledger-head:focus {
    background: var(--teal-soft);
    outline: none;
}

.dash { display: grid; gap: 16px; }
.dash-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.dash-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}
.dash-eq {
    display: flex;
    flex-direction: column;
    min-height: 280px;
}
.dash-eq h3 {
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
.dash-stats {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    display: grid;
    gap: 8px;
}
.dash-stats li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
}
.dash-stats li:last-child { border-bottom: 0; }
.dash-stats span { color: var(--muted); }
.dash-stats strong { color: var(--teal-deep); font-variant-numeric: tabular-nums; white-space: nowrap; }

.dash-table-card { margin-bottom: 0; }
.table-wrap.compact { max-height: 380px; }
.collect-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
table.data td.cell-start {
    text-align: start;
    white-space: normal;
    max-width: 220px;
}

.quick-card {
    display: flex;
    flex-direction: column;
    min-height: 148px;
}
.quick-card p { margin-top: auto; }

.table-wrap {
    overflow: auto;
    max-height: calc(100vh - 210px);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.card .table-wrap {
    margin-top: 4px;
}

table.data {
    width: 100%;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

table.data th,
table.data td {
    padding: 7px 8px;
    border-bottom: 1px solid var(--line);
    text-align: center;
    font-size: 12.5px;
    white-space: nowrap;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}

table.data th {
    background: #f3eee4;
    color: var(--teal-deep);
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 3;
    box-shadow: 0 1px 0 var(--line);
}

table.data tr:hover td { background: #faf6ee; }

table.data tr.total-row th {
    background: #e8f3f1;
    color: var(--teal);
    font-weight: 800;
    top: 0;
    z-index: 4;
}

table.smart-table tr.sort-row th {
    top: 42px;
}

.acct-actions {
    white-space: normal !important;
    min-width: 220px;
    max-width: 280px;
    text-align: start;
    vertical-align: top;
}

.acct-actions form {
    display: grid;
    gap: 6px;
    margin: 0;
}

.acct-actions .acct-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
}

.acct-actions input[type="date"],
.acct-actions input[type="password"],
.acct-actions select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 7px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: inherit;
    font-size: 12px;
    background: #fff;
}

.th-sort {
    cursor: pointer;
    user-select: none;
}
.th-sort:hover { background: #eadfc8; }
.th-sort.sorted-asc::after,
.th-sort.sorted-desc::after {
    font-size: 10px;
    color: var(--gold);
    margin-inline-start: 4px;
}
.th-sort.sorted-asc::after { content: "أ→ي"; }
.th-sort.sorted-desc::after { content: "ي→أ"; }

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-off { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-gold { background: var(--gold-soft); color: #7a5d1d; }
.badge-teal { background: var(--teal-soft); color: var(--teal); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-grid .full { grid-column: 1 / -1; }

.js-ejar-only[hidden],
.js-not-hold[hidden],
.js-hold-only[hidden],
.js-agent-only[hidden],
.js-no-contract[hidden] {
    display: none !important;
}

label.field {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #3f4a47;
}

label.field input,
label.field select,
label.field textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
}

label.field textarea { min-height: 90px; resize: vertical; }

label.field input[type="date"],
label.field input[type="number"] {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.kpi-inline {
    margin-top: 10px;
    font-weight: 800;
    color: var(--teal);
}

.flash {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 600;
}

.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-info { background: var(--info-soft); color: var(--info); }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.toolbar h3 { margin: 0; }
.toolbar > div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.report-bar {
    align-items: flex-end;
    margin-bottom: 10px;
}
.report-kind {
    flex: 1;
    min-width: 240px;
    margin: 0;
}
.report-kind select { margin-top: 6px; }
.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.report-title {
    margin: 0 0 10px;
    font-size: 16px;
    color: var(--teal-deep);
}

td.q-ok { color: var(--success); font-weight: 700; }
td.q-off { color: var(--danger); font-weight: 700; }
td.q-warn { color: var(--warn); font-weight: 700; }
td.q-info { color: var(--muted); }

.pay-accs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.pay-acc {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    min-width: 180px;
    flex: 1 1 200px;
}
.pay-acc-kind {
    font-size: 11px;
    color: var(--gold);
    font-weight: 700;
    margin-bottom: 4px;
}
.pay-acc-meta {
    font-size: 12px;
    color: var(--muted);
    margin: 4px 0 8px;
}
.split-box {
    margin-top: 8px;
    padding: 12px 14px;
    border: 1px dashed var(--gold);
    border-radius: 10px;
    background: var(--gold-soft);
    color: var(--teal-deep);
    font-weight: 700;
    font-size: 13px;
    line-height: 1.7;
}

table.data thead th:first-child,
table.data tbody td:first-child {
    position: sticky;
    right: 0;
    z-index: 2;
}
table.data thead th:first-child {
    z-index: 5;
    background: #f3eee4;
}
table.data tr.total-row th:first-child {
    z-index: 6;
    background: #e8f3f1;
}
table.data tbody td:first-child {
    background: var(--paper);
}
table.data tbody tr:hover td:first-child {
    background: #faf6ee;
}

.empty {
    text-align: center;
    padding: 36px 12px;
    color: var(--muted);
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 12% 18%, rgba(184, 149, 74, 0.18), transparent 28%),
        radial-gradient(circle at 88% 80%, rgba(13, 79, 74, 0.16), transparent 32%),
        var(--cream);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.login-card h2 { margin: 8px 0 4px; color: var(--teal-deep); text-align: center; }
.login-card .tag { text-align: center; color: var(--muted); margin-bottom: 22px; font-size: 13px; }

.menu-btn {
    display: inline-flex;
    align-items: center;
    background: var(--teal);
    color: #fff;
    border: 0;
    border-radius: 10px;
    padding: 8px 12px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    margin-left: 8px;
}

.hint-line { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.term-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 0 0 14px;
    padding: 10px 14px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--teal-deep);
    line-height: 1.7;
}
.term-legend span { white-space: normal; }

.meter-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.meter {
    height: 12px;
    background: #efe8da;
    border-radius: 999px;
    overflow: hidden;
}

.meter span {
    display: block;
    height: 100%;
    border-radius: 999px;
}

.meter-ok { background: var(--success); }
.meter-off { background: var(--danger); }
.meter-gold { background: var(--gold); }
.meter-teal { background: var(--teal); }

.mini-meter {
    height: 8px;
    background: #efe8da;
    border-radius: 999px;
    overflow: hidden;
    min-width: 70px;
}

.mini-meter span {
    display: block;
    height: 100%;
    background: var(--teal);
}

.svc-bars { display: grid; gap: 10px; }
.svc-row {
    display: grid;
    grid-template-columns: 140px 1fr 120px;
    gap: 10px;
    align-items: center;
    font-size: 13px;
}

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-3, .dash-4, .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    html, body { height: auto; overflow: auto; }
    .app { height: auto; overflow: visible; }
    .sidebar { display: none; }
    .sidebar.open {
        display: flex;
        position:fixed;
        top: 0;
        right: 0;
        z-index: 30;
        box-shadow: -12px 0 30px rgba(0,0,0,.25);
    }
    .grid-3, .grid-2, .form-grid, .dash-4, .hub-grid, .report-filters { grid-template-columns: 1fr; }
    .svc-row { grid-template-columns: 1fr; }
    .main { padding: 16px; height: auto; overflow: visible; }
    .table-wrap { max-height: min(70vh, 640px); }
    .dash-eq { min-height: 0; }
    .ops-log { inset-inline-end: 12px; bottom: 12px; }
}

.ops-log {
    position: fixed;
    bottom: 16px;
    inset-inline-end: 18px;
    z-index: 40;
    width: min(420px, calc(100vw - 36px));
    font-size: 13px;
}
.ops-log.is-hidden { display: none; }
.ops-log-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: var(--teal);
    color: #fff;
    border-radius: 999px;
    padding: 8px 14px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.ops-log-tab span {
    background: rgba(255,255,255,.18);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
}
.ops-log.is-open .ops-log-tab { display: none; }
.ops-log:not(.is-open) .ops-log-panel { display: none; }
.ops-log-panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.ops-log-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    background: var(--teal-soft);
    border-bottom: 1px solid var(--line);
}
.ops-log-lock {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    margin-top: 2px;
}
.ops-log-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ops-log-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow: auto;
}
.ops-log-list li {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}
.ops-log-list li:last-child { border-bottom: 0; }
.ops-log-list time {
    display: block;
    font-size: 11px;
    color: var(--muted);
}
.ops-log-role {
    font-size: 11px;
    color: var(--gold);
    margin-inline-start: 6px;
}
.ops-log-act { margin-top: 4px; color: var(--ink); }
.ops-log-empty { padding: 16px; color: var(--muted); margin: 0; }

/* —— تنظيم بصري ومحاسبي 1.3.28 —— */
.sar {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
    unicode-bidi: isolate;
}
.sar-debit { color: var(--debit); }
.sar-credit { color: var(--credit); }
.sar-due { color: var(--due); }
.sar-clear { color: var(--success); }
td.num, th[dir="ltr"] {
    text-align: left;
    font-variant-numeric: tabular-nums;
}
td.num-balance .sar { font-weight: 800; }

.acct-eq {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    gap: 10px;
    align-items: stretch;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow);
}
.acct-eq-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fbfa;
    min-width: 0;
}
.acct-eq-item em {
    font-style: normal;
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
}
.acct-eq-item .sar { font-size: 18px; }
.acct-eq-item small { color: var(--muted); font-size: 11px; }
.acct-eq-item.debit { background: #eef7f5; }
.acct-eq-item.credit { background: #eef8f2; }
.acct-eq-item.balance { background: #fdf4f3; }
.acct-eq-op {
    display: grid;
    place-items: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--gold);
}

.acct-legend {
    align-items: center;
    gap: 10px;
    background: linear-gradient(180deg, #fffdf8, #f7f1e6);
}
.acct-legend .lg-op {
    font-weight: 800;
    color: var(--gold);
    font-size: 16px;
}
.acct-legend .lg-debit strong { color: var(--debit); }
.acct-legend .lg-credit strong { color: var(--credit); }
.acct-legend .lg-balance strong { color: var(--due); }

.kpi-debit { border-top: 3px solid var(--debit); }
.kpi-credit { border-top: 3px solid var(--credit); }
.kpi-balance { border-top: 3px solid var(--due); }
.kpi-risk { border-top: 3px solid var(--warn); }
.kpi .value { font-variant-numeric: tabular-nums; }
.kpi .value-money { font-size: 20px; }
.kpi-debit .value, .kpi-debit .sar { color: var(--debit); }
.kpi-credit .value, .kpi-credit .sar { color: var(--credit); }
.kpi-balance .sar-due, .kpi-balance .value { color: var(--due); }
.kpi-balance .sar-clear { color: var(--success); }

.ledger-head {
    align-items: center;
    background: #f7fbfa;
    border: 1px solid var(--line);
    padding: 10px 12px;
    margin: 0 0 12px;
    gap: 16px;
}
.lh-item {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
}
.lh-item em {
    font-style: normal;
    font-size: 11px;
    color: var(--muted);
    font-weight: 700;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    background: rgba(243, 238, 228, 0.94);
    backdrop-filter: blur(10px);
    margin: -18px -22px 18px;
    padding: 14px 22px 12px;
    border-bottom: 1px solid var(--line);
    align-items: center;
}
.topbar-start {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.topbar-start h2 { font-weight: 800; letter-spacing: -0.02em; }
.topbar-find {
    flex: 1;
    min-width: 180px;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
}
.topbar-find input {
    width: 100%;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
}
.topbar-find input:focus,
label.field input:focus,
label.field select:focus,
label.field textarea:focus,
.period-bar select:focus,
.period-bar input:focus {
    outline: 0;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(13, 79, 74, 0.12);
}
.user-chip-meta { font-size: 12px; color: var(--muted); }

.nav a {
    padding: 8px 12px;
    border-radius: 10px;
    transition: background .12s ease, color .12s ease;
}
.nav-group {
    margin-top: 14px;
    font-weight: 800;
}

.period-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
}
.period-bar .field { min-width: 160px; }

.btn, button.btn, a.btn { transition: background .12s ease, border-color .12s ease, transform .08s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-ghost:hover { background: var(--teal-soft); color: var(--teal-deep); }

.card, .kpi { box-shadow: var(--shadow); }
.ledger-card h3 { font-weight: 800; }

table.data tbody tr.smart-row:nth-child(even) td { background: #fbf8f2; }
table.data tbody tr.smart-row:nth-child(even) td:first-child { background: #fbf8f2; }
table.data tr.total-row th {
    font-variant-numeric: tabular-nums;
    font-size: 13px;
}

.form-grid { gap: 16px; }
label.field { color: var(--teal-deep); }
.toolbar h3 { color: var(--teal-deep); font-weight: 800; }

.login-mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 16px;
    background: var(--gold);
    color: var(--teal-deep);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 18px;
}
.login-card .field { margin-bottom: 12px; }
.login-submit { width: 100%; padding: 12px; margin-top: 8px; }

.page { min-width: 0; }

@media (max-width: 1100px) {
    .acct-eq { grid-template-columns: 1fr; }
    .acct-eq-op { display: none; }
    .topbar-find { max-width: none; }
}
@media (max-width: 860px) {
    .topbar {
        margin: -16px -16px 16px;
        padding: 12px 16px;
        position: static;
        flex-wrap: wrap;
    }
    .topbar-find { max-width: none; flex-basis: 100%; }
}

@media print {
    html, body { height: auto; overflow: visible; background: #fff; }
    .sidebar, .topbar, .ops-log, .tbl-tools, .menu-btn, .report-actions, .assist-bar .report-actions { display: none !important; }
    .app { display: block; height: auto; }
    .main { padding: 0; height: auto; overflow: visible; }
    .card, .kpi { box-shadow: none; }
    .table-wrap { max-height: none; overflow: visible; }
}

