/* ════════════════════════════════════════════════════════════
   شركة بكور الأثر التجارية — ورقة الأنماط  v1.2
   تصميم عربي أصيل: الاتجاه من اليمين لليسار في كل طبقة
   ════════════════════════════════════════════════════════════ */

:root {
  /* الحبر */
  --ink: #15191C;
  --ink-2: #4A5560;
  --ink-3: #838F9B;

  /* الأسطح — قماش دافئ لا أبيض صريح */
  --canvas: #F6F6F2;
  --surface: #FFFFFF;
  --surface-2: #F2F3EF;
  --surface-3: #E8EAE4;
  --line: #E3E5DF;
  --line-soft: #EFF0EC;

  /* الهوية */
  --brand: #17544D;
  --brand-2: #1F6F65;
  --brand-soft: #E6F0ED;
  --accent: #C59D46;
  /* لمسة واحدة فاقعة — للبطاقة الرئيسية فقط */
  --accent-ink: #232B16;

  /* الحالات */
  --amber: #A2661A;
  --amber-soft: #FBF1E0;
  --red: #A32B22;
  --red-soft: #FBEAE8;
  --green: #1F6B46;
  --green-soft: #E4F2EA;

  --radius-xl: 18px;
  --radius: 12px;
  --radius-s: 8px;
  --pill: 999px;

  --shadow-sm: 0 1px 2px rgba(21, 25, 28, .05);
  --shadow: 0 2px 4px rgba(21, 25, 28, .04), 0 12px 32px rgba(21, 25, 28, .07);
  --shadow-lg: 0 8px 20px rgba(21, 25, 28, .08), 0 32px 64px rgba(21, 25, 28, .12);

  --sidebar-w: 244px;
  --topbar-h: 64px;

  --font: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", system-ui, Tahoma, sans-serif;
}

[data-theme="dark"] {
  --ink: #EEF1F3;
  --ink-2: #A6B1BB;
  --ink-3: #6F7B86;
  --canvas: #121619;
  --surface: #191E22;
  --surface-2: #202629;
  --surface-3: #2A3135;
  --line: #2D3438;
  --line-soft: #242A2E;
  --brand: #55A599;
  --brand-2: #6FBFB2;
  --brand-soft: #1A2E2B;
  --accent: #C2D96A;
  --accent-ink: #1A1F10;
  --amber: #D7A660;
  --amber-soft: #2C2418;
  --red: #DE8279;
  --red-soft: #2D1B19;
  --green: #63B189;
  --green-soft: #16271E;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
  --shadow-lg: 0 8px 20px rgba(0, 0, 0, .4), 0 32px 64px rgba(0, 0, 0, .5);
}

* {
  box-sizing: border-box;
}

html {
  direction: rtl;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-align: start;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -.015em;
}

a {
  color: var(--brand);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ════════ الهيكل — الشريط الجانبي على اليمين ════════ */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  /* في RTL = أقصى اليمين */
  z-index: 40;
}

.brand {
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: block;
  color: inherit;
  text-decoration: none;
}

a.brand:hover {
  background: var(--surface-2);
}

.brand-mark {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  display: block;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: .14em;
  text-transform: uppercase;
}

#sidebar-nav {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 13px;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: start;
  width: 100%;
  transition: background .12s, color .12s;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.nav-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  opacity: .9;
  flex: none;
}

.sidebar-foot {
  padding: 14px;
  border-top: 1px solid var(--line-soft);
}

.user-box {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

#user-name {
  font-weight: 600;
  font-size: 13px;
}

#user-role {
  font-size: 11.5px;
  color: var(--ink-3);
}

.main {
  flex: 1;
  margin-inline-start: var(--sidebar-w);
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 30;
}

[data-theme="dark"] .topbar {
  background: rgba(25, 30, 34, .86);
}

#page-title {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
}

#project-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--pill);
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.project-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

.project-none {
  color: var(--ink-3);
  font-size: 12px;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--pill);
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

#menu-toggle {
  display: none;
}

.content {
  padding: 24px 26px 48px;
  max-width: 1440px;
}

/* ════════ بطاقة ملف المشروع ════════ */
.profile-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.profile-hero::before {
  content: '';
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  width: 4px;
  height: 100%;
  background: var(--hero-color, var(--brand));
}

.profile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.profile-id {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-badge {
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  flex: none;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .04em;
  background: var(--hero-color, var(--brand));
  color: #fff;
}

.profile-name {
  font-size: 19px;
  line-height: 1.3;
}

.profile-tagline {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 14px 22px;
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.profile-grid>div {
  min-width: 0;
}

.profile-grid dt {
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 3px;
  letter-spacing: .02em;
}

.profile-grid dd {
  margin: 0;
  font-size: 13.5px;
  font-weight: 550;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.profile-grid dd.is-empty {
  color: var(--ink-3);
  font-weight: 400;
}

.profile-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

/* ════════ البطاقات الإحصائية ════════ */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  display: block;
}

.stat-accent {
  background: var(--accent);
  border-color: transparent;
}

.stat-accent .stat-label {
  color: var(--accent-ink);
  opacity: .72;
}

.stat-accent .stat-value {
  color: var(--accent-ink);
}

.stat-warn {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.stat-warn .stat-value {
  color: var(--amber);
}

.stat-danger {
  border-color: var(--red);
  background: var(--red-soft);
}

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

/* ════════ شريط الأدوات ════════ */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  margin-bottom: 18px;
}

.toolbar .input {
  max-width: 250px;
}

.page-note {
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 0 0 14px;
  flex-basis: 100%;
}

/* ════════ الحقول ════════ */
.input {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-s);
  padding: 9px 13px;
  font: inherit;
  font-size: 13.5px;
  width: 100%;
  text-align: start;
}

.input:hover {
  border-color: var(--ink-3);
}

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  outline: none;
}

.input[readonly] {
  background: var(--surface-2);
  color: var(--ink-2);
}

select.input {
  cursor: pointer;
}

input[type="date"].input,
input[type="number"].input {
  font-variant-numeric: tabular-nums;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field-full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
}

.field-hint {
  font-size: 11.5px;
  color: var(--ink-3);
  margin: 0;
}

.static-value {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

.form-actions {
  margin-top: 20px;
  display: flex;
  gap: 9px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.check input {
  accent-color: var(--brand);
  width: 15px;
  height: 15px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0;
}

legend {
  font-size: 13px;
  font-weight: 600;
  padding: 0 6px;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  font-size: 13px;
}

.preset-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

/* ════════ الأزرار ════════ */
.btn {
  border: 1px solid transparent;
  border-radius: var(--pill);
  padding: 9px 18px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
  transition: filter .12s, background .12s, border-color .12s;
}

.btn:disabled {
  opacity: .55;
  cursor: default;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-2);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--ink-3);
}

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

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

/* ════════ الجداول ════════ */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: start;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  letter-spacing: .02em;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.data-table tfoot td {
  padding: 13px 16px;
  background: var(--surface-2);
  font-weight: 600;
}

.data-table-compact td,
.data-table-compact th {
  padding: 8px 13px;
  font-size: 12.5px;
}

.cell-strong {
  font-weight: 600;
}

.cell-num {
  text-align: start;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-in {
  color: var(--green);
}

.cell-out {
  color: var(--red);
}

.cell-actions {
  white-space: nowrap;
}

.cell-detail {
  color: var(--ink-2);
  font-size: 12px;
  max-width: 320px;
}

.sub {
  display: block;
  font-size: 11.5px;
  color: var(--ink-3);
  font-weight: 400;
  margin-top: 2px;
}

.muted {
  color: var(--ink-3);
}

tr.is-disabled {
  opacity: .5;
}

tr.row-danger td:first-child {
  box-shadow: inset 3px 0 0 var(--red);
}

/* ════════ الشارات ════════ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--pill);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}

.badge-ok {
  background: var(--green-soft);
  color: var(--green);
}

.badge-warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-danger {
  background: var(--red-soft);
  color: var(--red);
}

.badge-muted {
  background: var(--surface-3);
  color: var(--ink-3);
}

.badge-xs {
  font-size: 10.5px;
  padding: 1px 7px;
}

.acc-chip {
  font-variant-numeric: tabular-nums;
  background: var(--surface-3);
  border-radius: var(--radius-s);
  padding: 1px 7px;
  font-size: 12px;
  color: var(--ink-2);
}

.link-chip {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: var(--radius-s);
  padding: 2px 8px;
  font-size: 12px;
}

.doc-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  border-radius: var(--pill);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}

.doc-count-zero {
  background: var(--red-soft);
  color: var(--red);
}

/* ════════ الحالات ════════ */
.state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-3);
}

.state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 6px;
}

.state-hint {
  margin: 0 0 16px;
  font-size: 13px;
}

.state-error {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

/* ════════ الألواح ════════ */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--ink-2);
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  height: 170px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.bar {
  width: 100%;
  background: var(--brand);
  border-radius: 5px 5px 0 0;
  min-height: 2px;
  opacity: .85;
}

.bar-col:hover .bar {
  opacity: 1;
}

.bar-label {
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 6px;
}

.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rank-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.rank-list li:last-child {
  border-bottom: 0;
}

.rank-name {
  flex: 1;
  font-weight: 550;
}

.rank-sub {
  color: var(--ink-3);
  font-size: 12px;
}

.rank-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.count-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
}

.count-item {
  background: var(--surface-2);
  border-radius: var(--radius-s);
  padding: 13px;
  text-align: center;
}

.count-value {
  display: block;
  font-size: 19px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.count-label {
  font-size: 11px;
  color: var(--ink-3);
  word-break: break-all;
}

/* ════════ التنبيهات ════════ */
.alert-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.alert-chip {
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: var(--pill);
  padding: 7px 16px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.alert-chip:hover {
  filter: brightness(.97);
}

.alert-chip strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ════════ شجرة الحسابات ════════ */
.tree {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow-sm);
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-s);
  padding-inline-start: calc(10px + var(--depth) * 24px);
  font-size: 13.5px;
}

.tree-row:hover {
  background: var(--surface-2);
}

.tree-node.is-disabled>.tree-row {
  opacity: .5;
}

.tree-toggle {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  width: 18px;
  font-size: 12px;
  padding: 0;
}

.tree-toggle.is-leaf {
  cursor: default;
  opacity: .3;
}

.tree-code {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 60px;
}

.tree-name {
  flex: 1;
}

.tree-type {
  font-size: 11.5px;
  color: var(--ink-3);
}

.tree-spend {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--brand);
  font-weight: 600;
}

.tree-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
}

.tree-row:hover .tree-actions {
  opacity: 1;
}

/* ════════ البنك ════════ */
.bank-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.bank-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: start;
  font: inherit;
  cursor: pointer;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.bank-card:hover {
  border-color: var(--brand);
}

.bank-card.is-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.bank-card.is-disabled {
  opacity: .5;
}

.bank-name {
  font-weight: 600;
  font-size: 13.5px;
}

.bank-account {
  font-size: 12px;
  color: var(--ink-3);
}

.bank-balance {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  margin-top: 5px;
}

.bank-meta {
  font-size: 11.5px;
  color: var(--ink-3);
}

.bank-card-add {
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  border-style: dashed;
}

/* ════════ التبويبات ════════ */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  padding: 10px 16px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* ════════ النوافذ ════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 22, 25, .45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 44px 16px;
  z-index: 100;
  overflow-y: auto;
}

body.modal-open {
  overflow: hidden;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 540px;
}

.modal-wide {
  max-width: 840px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-head h3 {
  font-size: 16px;
}

.modal-body {
  padding: 24px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding: 16px 24px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.confirm-text {
  margin: 0;
  font-size: 14px;
}

.code-display {
  font-family: ui-monospace, monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .14em;
  text-align: center;
  padding: 18px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: var(--radius);
}

/* ════════ التفاصيل ════════ */
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 18px;
}

.detail-title {
  font-size: 18px;
}

.detail-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.detail-amount {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}

.detail-amount strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

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

.detail-grid>div {
  min-width: 0;
}

.detail-grid dt {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 3px;
}

.detail-grid dd {
  margin: 0;
  font-size: 13.5px;
  font-weight: 550;
  overflow-wrap: anywhere;
}

.detail-full {
  grid-column: 1 / -1;
}

.detail-section {
  margin-top: 22px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 13.5px;
  font-weight: 600;
}

.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.doc-item:last-child {
  border-bottom: 0;
}

.doc-type {
  background: var(--surface-3);
  border-radius: var(--radius-s);
  padding: 2px 8px;
  font-size: 11.5px;
}

.doc-name {
  flex: 1;
  font-weight: 550;
}

.doc-meta {
  font-size: 11.5px;
  color: var(--ink-3);
}

.chip-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}

.chip-choice:hover {
  border-color: var(--brand);
}

/* ════════ الإشعارات ════════ */
#toast-host {
  position: fixed;
  inset-block-end: 22px;
  inset-inline-start: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--ink);
  color: var(--canvas);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
}

.toast-error {
  background: var(--red);
  color: #fff;
}

.toast-out {
  opacity: 0;
  transition: opacity .4s;
}

/* ════════ صفحات الدخول ════════ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--canvas);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  padding: 36px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-brand h1 {
  font-size: 20px;
  margin-bottom: 5px;
}

.auth-brand p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-form .btn {
  justify-content: center;
}

.auth-msg {
  font-size: 13px;
  padding: 11px 14px;
  border-radius: var(--radius-s);
  background: var(--red-soft);
  color: var(--red);
  display: none;
}

.auth-msg.show {
  display: block;
}

.auth-msg.ok {
  background: var(--green-soft);
  color: var(--green);
}

.auth-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
}

.step {
  display: none;
  flex-direction: column;
  gap: 15px;
}

.step.active {
  display: flex;
}

.auth-steps {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 20px;
}

.auth-dot {
  width: 22px;
  height: 3px;
  border-radius: 2px;
  background: var(--surface-3);
}

.auth-dot.is-on {
  background: var(--brand);
}

/* ════════ الأرشيف الذكي ════════ */
.cat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 16px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--pill);
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.cat-chip:hover {
  border-color: var(--brand);
  color: var(--ink);
}

.cat-chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.cat-chip.is-active .cat-count {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}

.cat-count {
  background: var(--surface-3);
  color: var(--ink-3);
  border-radius: var(--pill);
  padding: 0 7px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.cat-chip-add {
  border-style: dashed;
  color: var(--ink-3);
}

.exp-pill {
  display: inline-block;
  border-radius: var(--pill);
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.exp-ok {
  background: var(--green-soft);
  color: var(--green);
}

.exp-soon {
  background: var(--amber-soft);
  color: var(--amber);
}

.exp-critical {
  background: var(--red-soft);
  color: var(--red);
}

.exp-over {
  background: var(--red);
  color: #fff;
}

.exp-track {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 7px;
  max-width: 180px;
}

.exp-fill {
  height: 100%;
  border-radius: 2px;
}

.exp-fill.exp-ok {
  background: var(--green);
}

.exp-fill.exp-soon {
  background: var(--amber);
}

.exp-fill.exp-critical {
  background: var(--red);
}

.exp-fill.exp-over {
  background: var(--red);
}

.cell-expiry {
  min-width: 195px;
}

.version-chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: var(--pill);
  padding: 3px 11px;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.version-chip:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.version-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.version-item {
  border-inline-start: 2px solid var(--line);
  padding: 0 18px 20px;
  margin-inline-start: 6px;
  position: relative;
}

.version-item::before {
  content: '';
  position: absolute;
  inset-inline-start: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
}

.version-item.is-current {
  border-inline-start-color: var(--brand);
}

.version-item.is-current::before {
  background: var(--brand);
  border-color: var(--brand);
}

.version-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.version-no {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.version-meta {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

.version-note {
  margin: 6px 0 0;
  font-size: 13px;
}

.version-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.renew-banner {
  background: var(--brand-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.renew-banner strong {
  font-size: 14px;
  color: var(--brand);
}

.renew-banner span {
  font-size: 12.5px;
  color: var(--ink-2);
}

/* ════════ الاشتراكات ════════ */
.sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.sub-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: var(--shadow-sm);
}

.sub-card.exp-critical,
.sub-card.exp-over {
  border-color: var(--red);
}

.sub-card.exp-soon {
  border-color: var(--amber);
}

.sub-card.is-inactive {
  opacity: .62;
}

.sub-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.sub-name {
  font-size: 15px;
}

.sub-provider {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

.sub-amount {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.sub-amount strong {
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.sub-cycle {
  font-size: 12px;
  color: var(--ink-3);
}

.sub-renewal {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sub-date {
  font-size: 12px;
  color: var(--ink-2);
}

.sub-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 0;
}

.sub-meta dt {
  font-size: 11px;
  color: var(--ink-3);
}

.sub-meta dd {
  margin: 0;
  font-size: 13px;
  font-weight: 550;
}

.sub-actions {
  display: flex;
  gap: 7px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

/* ════════ التكاليف والتسعير ════════ */
.prod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.prod-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  box-shadow: var(--shadow-sm);
}

.prod-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.prod-name {
  font-size: 15px;
}

.prod-sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}

.prod-foot {
  margin: 0;
  font-size: 12px;
  color: var(--ink-3);
}

.cost-stack {
  display: flex;
  flex-direction: column;
}

.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px dashed var(--line);
}

.cost-row:last-child {
  border-bottom: 0;
}

.cost-row span {
  color: var(--ink-2);
}

.cost-row strong {
  font-variant-numeric: tabular-nums;
}

.cost-total {
  border-bottom: 1px solid var(--ink-3);
  padding-top: 9px;
}

.cost-total span,
.cost-total strong {
  font-weight: 650;
  color: var(--ink);
}

.price-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.price-box {
  background: var(--brand-soft);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.price-label {
  font-size: 11px;
  color: var(--ink-2);
}

.price-value {
  font-size: 18px;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.price-warn {
  background: var(--amber-soft);
}

.price-warn .price-value {
  color: var(--amber);
}

/* ════════ الجوال ════════ */
@media (max-width: 880px) {
  .sidebar {
    transform: translateX(calc(100% * var(--rtl-dir, 1)));
    transition: transform .22s ease;
  }

  body.sidebar-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-lg);
  }

  .main {
    margin-inline-start: 0;
  }

  #menu-toggle {
    display: inline-flex;
  }

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

  .content {
    padding: 18px 16px 40px;
  }

  .topbar {
    padding: 0 16px;
  }

  .toolbar .input {
    max-width: none;
    flex: 1 1 150px;
  }

  .profile-hero {
    padding: 18px;
  }
}

/* في RTL يخرج الشريط جهة اليمين، وفي LTR جهة اليسار */
html[dir="rtl"] .sidebar {
  --rtl-dir: 1;
}

html[dir="ltr"] .sidebar {
  --rtl-dir: -1;
}

@media (prefers-reduced-motion: reduce) {

  .sidebar,
  .btn,
  .nav-item {
    transition: none;
  }

  .toast-out {
    transition: none;
  }
}