:root {
  --brand-950: #082c23;
  --brand-900: #0d3a2e;
  --brand-800: #124b3b;
  --brand-700: #176047;
  --brand-600: #1e7557;
  --brand-100: #e9f4ef;
  --brand-50: #f4faf7;
  --gold-600: #a87420;
  --gold-500: #c28c34;
  --gold-100: #fbf1df;
  --ink-950: #13211c;
  --ink-800: #273832;
  --ink-700: #3d4e48;
  --ink-500: #6f7f79;
  --ink-400: #8d9a95;
  --line: #dce5e1;
  --line-soft: #eaf0ed;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --page: #eff4f1;
  --danger: #b23b3b;
  --danger-soft: #fff1f1;
  --success: #16724e;
  --success-soft: #eaf8f1;
  --warning: #9a6816;
  --warning-soft: #fff8e8;
  --shadow-sm: 0 4px 16px rgba(8, 44, 35, 0.06);
  --shadow-md: 0 14px 40px rgba(8, 44, 35, 0.10);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --sidebar-width: 270px;
  --content-max: 1500px;
}

* { box-sizing: border-box; }
html { direction: rtl; background: var(--page); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(194, 140, 52, 0.08), transparent 25%),
    linear-gradient(180deg, #f7faf8 0, var(--page) 280px);
  color: var(--ink-950);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* ===== Shared primitives ===== */
.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 34px; height: 34px; }
.money, .number-value {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }
.muted { color: var(--ink-500); }

.btn {
  min-height: 42px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink-800);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 650;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.btn:hover { border-color: #bccbc5; background: var(--surface-soft); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: var(--brand-800); color: #fff; border-color: var(--brand-800); }
.btn-primary:hover { background: var(--brand-900); border-color: var(--brand-900); }
.btn-success { color: var(--success); border-color: #b8dccd; background: var(--success-soft); }
.btn-success:hover { background: #def2e8; border-color: #98cbb5; }
.btn-danger { color: var(--danger); border-color: #efc8c8; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); border-color: #dfabab; }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: rgba(255,255,255,.09); border-color: transparent; box-shadow: none; }
.btn-small { min-height: 36px; padding: 6px 11px; border-radius: 9px; font-size: 13px; }
.btn-icon { width: 42px; padding: 0; }
.btn-block { width: 100%; }

.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.actions-top { margin-top: 16px; }

.input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd8d2;
  border-radius: 11px;
  background: #fff;
  color: var(--ink-950);
  padding: 9px 12px;
  outline: 0;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
textarea { min-height: 96px; resize: vertical; }
.input:hover, select:hover, textarea:hover { border-color: #adc1b8; }
.input:focus, select:focus, textarea:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 4px rgba(30, 117, 87, .10);
}
.input::placeholder, textarea::placeholder { color: #98a59f; }
.input-number { direction: ltr; text-align: center; font-variant-numeric: tabular-nums; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label, label { color: var(--ink-700); font-weight: 700; }
.help-text { color: var(--ink-500); font-size: 12px; }

.card {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { margin: 0; color: var(--brand-900); font-size: 18px; line-height: 1.35; }
.card-subtitle { margin: 4px 0 0; color: var(--ink-500); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-header.compact { margin-bottom: 10px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.notice {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface-soft);
  color: var(--ink-700);
  margin-bottom: 14px;
}
.notice-success { background: var(--success-soft); border-color: #b9ddca; color: #145b3c; }
.notice-warning { background: var(--warning-soft); border-color: #ecd7a8; color: #7b5310; }
.notice-danger { background: var(--danger-soft); border-color: #ebc3c3; color: #932e2e; }
.loading, .empty-state { text-align: center; color: var(--ink-500); padding: 42px 20px; }
.loading::before {
  content: "";
  display: inline-block;
  width: 17px;
  height: 17px;
  margin-left: 8px;
  border: 2px solid #cad7d1;
  border-top-color: var(--brand-700);
  border-radius: 50%;
  vertical-align: -3px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 44%) 1fr;
  background: #fff;
}
.login-brand-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(38px, 7vw, 84px);
  background:
    linear-gradient(145deg, rgba(8,44,35,.96), rgba(23,96,71,.94)),
    var(--brand-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  isolation: isolate;
}
.login-brand-panel::before,
.login-brand-panel::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  z-index: -1;
}
.login-brand-panel::before {
  width: 430px; height: 430px;
  left: -190px; top: -130px;
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 0 0 54px rgba(255,255,255,.035), 0 0 0 108px rgba(255,255,255,.025);
}
.login-brand-panel::after {
  width: 260px; height: 260px;
  right: -90px; bottom: -110px;
  background: rgba(194,140,52,.18);
  filter: blur(1px);
}
.brand-mark {
  width: 64px; height: 64px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14);
  color: #f5d8a0;
}
.login-brand-name { margin: 24px 0 8px; font-size: clamp(29px, 4vw, 46px); line-height: 1.15; }
.login-brand-copy { margin: 0; color: rgba(255,255,255,.74); font-size: 16px; max-width: 480px; }
.login-brand-foot { color: rgba(255,255,255,.58); font-size: 12px; }
.login-form-panel {
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 90% 10%, rgba(30,117,87,.08), transparent 26%),
    #fff;
}
.login-card {
  width: min(100%, 440px);
  padding: 10px;
}
.login-mobile-brand { display: none; }
.login-kicker { color: var(--brand-700); font-weight: 800; font-size: 13px; letter-spacing: .02em; }
.login-title { margin: 5px 0 8px; color: var(--brand-950); font-size: 30px; line-height: 1.25; }
.login-subtitle { margin: 0 0 28px; color: var(--ink-500); }
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn-primary { min-height: 48px; margin-top: 4px; }
.login-footer { margin-top: 20px; text-align: center; color: var(--ink-400); font-size: 12px; }
.login-footer a { color: var(--brand-700); font-weight: 700; }
.password-wrap { position: relative; }
.password-wrap .input { padding-left: 48px; }
.password-toggle { position: absolute; left: 5px; top: 50%; transform: translateY(-50%); width: 38px; height: 36px; border: 0; background: transparent; color: var(--ink-500); cursor: pointer; border-radius: 8px; display: grid; place-items: center; }
.password-toggle:hover { background: var(--surface-soft); color: var(--brand-700); }

/* ===== Application shell ===== */
.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}
.app-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 30;
  padding: 22px 16px 16px;
  background: linear-gradient(180deg, var(--brand-950), #0d3f31 68%, #124b3b);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: -10px 0 38px rgba(8,44,35,.10);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 24px; border-bottom: 1px solid rgba(255,255,255,.10); }
.sidebar-logo { width: 45px; height: 45px; border-radius: 14px; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.15); display: grid; place-items: center; color: #f2cf8a; }
.sidebar-brand-title { font-size: 17px; font-weight: 800; line-height: 1.2; }
.sidebar-brand-subtitle { margin-top: 3px; color: rgba(255,255,255,.58); font-size: 11px; }
.sidebar-label { padding: 23px 12px 8px; color: rgba(255,255,255,.48); font-size: 11px; font-weight: 800; }
.sidebar-nav { display: grid; gap: 7px; }
.nav-link {
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  color: rgba(255,255,255,.74);
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 650;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.08); transform: translateX(-2px); }
.nav-link.active { color: #fff; background: linear-gradient(90deg, rgba(194,140,52,.22), rgba(255,255,255,.09)); box-shadow: inset -3px 0 0 #d2a14d; }
.nav-link .nav-icon { width: 20px; height: 20px; }
.sidebar-spacer { flex: 1; min-height: 22px; }
.sidebar-user {
  border: 1px solid rgba(255,255,255,.11);
  background: rgba(255,255,255,.06);
  border-radius: 15px;
  padding: 12px;
}
.sidebar-user-top { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: var(--brand-900); font-weight: 850; }
.user-name { color: inherit; font-weight: 800; line-height: 1.3; }
.user-category { color: rgba(255,255,255,.58); font-size: 11px; margin-top: 2px; }
.sidebar-user .btn { width: 100%; margin-top: 10px; color: rgba(255,255,255,.83); border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.04); }
.sidebar-user .btn:hover { background: rgba(255,255,255,.10); color: #fff; }

.app-main { grid-column: 2; min-width: 0; }
.mobile-topbar { display: none; }
.main-header {
  min-height: 84px;
  padding: 18px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid rgba(220,229,225,.9);
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.header-breadcrumb { color: var(--ink-500); font-size: 12px; margin-bottom: 3px; }
.header-title { margin: 0; color: var(--brand-950); font-size: 23px; line-height: 1.3; }
.header-description { margin: 3px 0 0; color: var(--ink-500); }
.header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.page-content { width: min(100%, var(--content-max)); margin: 0 auto; padding: 26px clamp(18px, 3vw, 42px) 46px; }

/* ===== Dashboard ===== */
.dashboard-hero {
  position: relative;
  overflow: hidden;
  min-height: 210px;
  padding: clamp(26px, 4vw, 44px);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(120deg, rgba(8,44,35,.98), rgba(23,96,71,.93)),
    var(--brand-900);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  box-shadow: var(--shadow-md);
}
.dashboard-hero::before { content: ""; position: absolute; width: 320px; height: 320px; left: -100px; top: -170px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; box-shadow: 0 0 0 45px rgba(255,255,255,.035), 0 0 0 90px rgba(255,255,255,.02); }
.dashboard-hero::after { content: ""; position: absolute; width: 180px; height: 180px; right: 42%; bottom: -145px; background: rgba(194,140,52,.20); border-radius: 50%; }
.hero-content { position: relative; z-index: 1; max-width: 690px; }
.hero-kicker { color: #f0cc87; font-weight: 800; font-size: 13px; }
.hero-title { margin: 8px 0 8px; font-size: clamp(27px, 4vw, 39px); line-height: 1.25; }
.hero-copy { margin: 0; color: rgba(255,255,255,.70); font-size: 15px; }
.hero-date { position: relative; z-index: 1; min-width: 160px; padding: 18px; border: 1px solid rgba(255,255,255,.16); border-radius: 17px; background: rgba(255,255,255,.08); text-align: center; backdrop-filter: blur(6px); }
.hero-date-day { color: #f1cd87; font-weight: 850; font-size: 13px; }
.hero-date-value { margin-top: 5px; font-size: 19px; font-weight: 800; }
.dashboard-section { margin-top: 24px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 13px; }
.section-title { margin: 0; color: var(--brand-950); font-size: 20px; }
.section-copy { margin: 3px 0 0; color: var(--ink-500); }
.menu-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.menu-card {
  min-height: 170px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.menu-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: #bfd0c8; }
.menu-icon { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; background: var(--brand-100); color: var(--brand-700); }
.menu-card:nth-child(2) .menu-icon { background: var(--gold-100); color: var(--gold-600); }
.menu-card:nth-child(3) .menu-icon { background: #edf1f8; color: #536d9b; }
.menu-title { margin: 16px 0 4px; color: var(--brand-950); font-size: 18px; }
.menu-description { margin: 0; color: var(--ink-500); font-size: 13px; }
.menu-arrow { margin-top: auto; padding-top: 16px; color: var(--brand-700); font-weight: 750; display: flex; align-items: center; gap: 6px; }

/* ===== Prices ===== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.search-control { position: relative; width: min(100%, 420px); }
.search-control .input { padding-right: 43px; }
.search-control .icon { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-400); pointer-events: none; }
.data-note { display: flex; align-items: center; gap: 8px; color: var(--ink-500); font-size: 13px; }
.data-note .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.price-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.price-card {
  min-height: 92px;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 2px 10px rgba(8,44,35,.035);
}
.price-name { min-width: 0; color: var(--ink-950); font-size: 16px; font-weight: 760; line-height: 1.45; }
.price-label { margin-top: 3px; color: var(--ink-400); font-size: 11px; }
.price-box { flex: 0 0 auto; min-width: 92px; padding: 9px 12px; border-radius: 12px; background: var(--brand-50); color: var(--success); text-align: center; }
.price-value { font-size: 21px; font-weight: 900; line-height: 1.1; }
.price-currency { margin-top: 3px; font-size: 11px; font-weight: 700; }

/* ===== Summary cards ===== */
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.summary-card { padding: 15px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.summary-card-label { color: var(--ink-500); font-size: 12px; }
.summary-card-value { margin-top: 4px; color: var(--brand-950); font-size: 20px; font-weight: 850; }
.summary-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.summary-item { border: 1px solid var(--line); background: var(--surface-soft); border-radius: 11px; padding: 9px 13px; }
.summary-item strong { color: var(--brand-900); }
.status-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* ===== Tables ===== */
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
table { width: 100%; border-collapse: separate; border-spacing: 0; direction: rtl; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); border-left: 1px solid var(--line-soft); vertical-align: middle; text-align: center; }
th:last-child, td:last-child { border-left: 0; }
th { position: sticky; top: 0; z-index: 2; background: #eef4f1; color: var(--brand-950); font-size: 12px; font-weight: 800; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfc; }
.custody-table { min-width: 1220px; }
.custody-table th, .custody-table td { padding: 7px; }
.custody-table .input { min-height: 38px; padding: 6px 8px; border-radius: 8px; }
.custody-table .product-input { min-width: 180px; text-align: right; }
.custody-table .note-input { min-width: 150px; text-align: right; }
.computed-cell { background: #f6f9f7; color: var(--ink-700); direction: ltr; font-variant-numeric: tabular-nums; }
.row-number { color: var(--ink-400); width: 42px; }

/* ===== Custody mobile card structure ===== */
.mobile-item-head { display: none; }
.editor-tools { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.editor-tools .date-field { width: 200px; }
.editor-savebar { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.editor-savebar-copy { color: var(--ink-500); font-size: 12px; }

/* ===== Files archive ===== */
.file-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.file-card { border: 1px solid var(--line); border-radius: 15px; background: #fff; padding: 17px; box-shadow: 0 2px 10px rgba(8,44,35,.035); }
.file-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.file-date { color: var(--brand-950); font-size: 18px; font-weight: 850; }
.file-code { color: var(--ink-400); font-size: 10px; margin-top: 3px; direction: ltr; text-align: right; }
.file-cost { min-width: 112px; padding: 9px 11px; border-radius: 11px; background: var(--brand-50); color: var(--success); text-align: center; }
.file-cost strong { display: block; font-size: 17px; }
.file-cost span { font-size: 10px; }
.file-meta { margin: 15px 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.file-meta-item { padding: 9px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-soft); }
.file-meta-label { color: var(--ink-400); font-size: 10px; }
.file-meta-value { margin-top: 2px; color: var(--ink-700); font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.file-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 16px; }

/* ===== Admin ===== */
.admin-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { position: relative; overflow: hidden; padding: 19px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: var(--shadow-sm); }
.stat-card::after { content: ""; position: absolute; width: 70px; height: 70px; left: -22px; bottom: -28px; border-radius: 50%; background: var(--brand-100); }
.stat-value { color: var(--brand-950); font-size: 27px; font-weight: 900; line-height: 1.2; }
.stat-label { margin-top: 5px; color: var(--ink-500); }
.permission-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.permission-chip { padding: 4px 8px; border-radius: 999px; background: var(--brand-50); color: var(--brand-700); font-size: 11px; font-weight: 750; }
.checkbox-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.checkbox-item { min-height: 48px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); display: flex; align-items: center; gap: 8px; font-weight: 650; cursor: pointer; }
.checkbox-item:has(input:checked) { border-color: #96c7b1; background: var(--brand-50); color: var(--brand-800); }
.checkbox-item input { width: 18px; height: 18px; accent-color: var(--brand-700); }

/* ===== Modal / toast ===== */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; padding: 18px; background: rgba(6,28,22,.55); display: grid; place-items: center; backdrop-filter: blur(3px); }
.modal { width: min(100%, 590px); max-height: 90vh; overflow: auto; padding: 22px; border: 1px solid rgba(255,255,255,.4); border-radius: 18px; background: #fff; box-shadow: 0 30px 90px rgba(3,24,18,.28); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.modal-title { margin: 0; color: var(--brand-950); font-size: 20px; }
.modal-actions { display: flex; justify-content: flex-start; gap: 8px; margin-top: 18px; }
.toast-container { position: fixed; z-index: 200; left: 18px; bottom: 18px; width: min(390px, calc(100vw - 36px)); display: grid; gap: 8px; }
.toast { padding: 12px 14px; border: 1px solid var(--line); border-right: 4px solid var(--brand-700); border-radius: 12px; background: #fff; box-shadow: var(--shadow-md); }
.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--danger); }

/* ===== Mobile / tablet ===== */
@media (max-width: 1180px) {
  :root { --sidebar-width: 238px; }
  .price-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  body { padding-bottom: 76px; }
  .app-layout { display: block; }
  .app-sidebar {
    position: fixed;
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 68px;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: rgba(8,44,35,.97);
    backdrop-filter: blur(14px);
    overflow: visible;
    box-shadow: 0 -8px 30px rgba(8,44,35,.15);
  }
  .sidebar-brand, .sidebar-label, .sidebar-user, .sidebar-spacer { display: none; }
  .sidebar-nav { height: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .nav-link { min-height: 54px; padding: 5px 2px; border-radius: 11px; flex-direction: column; justify-content: center; gap: 2px; font-size: 10px; color: rgba(255,255,255,.67); }
  .nav-link:hover { transform: none; }
  .nav-link.active { background: rgba(255,255,255,.12); box-shadow: inset 0 2px 0 #d2a14d; }
  .nav-link .nav-icon { width: 20px; height: 20px; }
  .app-main { min-width: 0; }
  .main-header { display: none; }
  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    min-height: 60px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(12px);
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    align-items: center;
    gap: 8px;
  }
  .mobile-topbar-title { min-width: 0; text-align: center; color: var(--brand-950); font-size: 16px; font-weight: 850; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-topbar .btn-icon { min-height: 40px; width: 40px; padding: 0; border-radius: 11px; }
  .page-content { padding: 16px 11px 28px; }
  .dashboard-hero { min-height: 174px; padding: 24px 20px; border-radius: 19px; }
  .hero-title { font-size: 27px; }
  .hero-copy { font-size: 13px; }
  .hero-date { display: none; }
  .dashboard-section { margin-top: 18px; }
  .section-title { font-size: 18px; }
  .section-copy { font-size: 12px; }
  .menu-grid { grid-template-columns: 1fr; gap: 10px; }
  .menu-card { min-height: 94px; padding: 14px; display: grid; grid-template-columns: 48px minmax(0, 1fr) 22px; grid-template-rows: auto auto; align-items: center; gap: 2px 12px; }
  .menu-icon { width: 48px; height: 48px; grid-row: 1 / 3; border-radius: 14px; }
  .menu-title { margin: 0; font-size: 16px; }
  .menu-description { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-arrow { grid-column: 3; grid-row: 1 / 3; margin: 0; padding: 0; font-size: 0; }
  .menu-arrow .icon { width: 20px; height: 20px; }
  .toolbar { align-items: stretch; flex-direction: column; gap: 10px; }
  .search-control { width: 100%; }
  .data-note { font-size: 11px; }
  .card { padding: 14px; border-radius: 14px; }
  .card-header { margin-bottom: 12px; }
  .card-title { font-size: 16px; }
  .form-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-group.full { grid-column: auto; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .summary-card { padding: 12px; }
  .summary-card-value { font-size: 17px; }
  .price-grid { grid-template-columns: 1fr; gap: 8px; }
  .price-card { min-height: 76px; padding: 12px 13px; border-radius: 13px; }
  .price-name { font-size: 15px; }
  .price-box { min-width: 82px; padding: 8px 10px; }
  .price-value { font-size: 19px; }
  .file-grid { grid-template-columns: 1fr; gap: 10px; }
  .file-card { padding: 14px; border-radius: 14px; }
  .file-date { font-size: 16px; }
  .file-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-meta-item:last-child { grid-column: 1 / -1; }
  .admin-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat-card { padding: 13px 10px; text-align: center; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 10px; }

  /* Responsive data tables become clean cards */
  .responsive-table { border: 0; overflow: visible; background: transparent; }
  .responsive-table table, .responsive-table thead, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
  .responsive-table thead { display: none; }
  .responsive-table tbody { display: grid; gap: 10px; }
  .responsive-table tbody tr { border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; box-shadow: 0 2px 10px rgba(8,44,35,.035); }
  .responsive-table tbody td { min-height: 48px; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line-soft); display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 10px; text-align: right !important; }
  .responsive-table tbody td:last-child { border-bottom: 0; }
  .responsive-table tbody td::before { content: attr(data-label); color: var(--ink-400); font-size: 10px; font-weight: 800; }
  .responsive-table .cell-title { display: block; padding: 12px 13px; background: #eef4f1; color: var(--brand-950); font-size: 15px; font-weight: 850; }
  .responsive-table .cell-title::before, .responsive-table .cell-hidden-mobile { display: none; }
  .responsive-table .cell-actions { display: block; padding: 10px; }
  .responsive-table .cell-actions::before { display: none; }
  .responsive-table .cell-actions .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Custody editor: every product is a spacious card */
  .custody-editor-wrap { border: 0; overflow: visible; background: transparent; }
  .custody-editor-wrap .custody-table, .custody-editor-wrap thead, .custody-editor-wrap tbody, .custody-editor-wrap tr, .custody-editor-wrap td { display: block; width: 100%; min-width: 0; }
  .custody-editor-wrap thead { display: none; }
  .custody-editor-wrap tbody { display: grid; gap: 12px; }
  .custody-editor-wrap tbody tr { position: relative; padding: 54px 10px 10px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 3px 12px rgba(8,44,35,.045); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .custody-editor-wrap tbody td { min-width: 0; padding: 0; border: 0; background: transparent; text-align: right; }
  .custody-editor-wrap tbody td::before { content: attr(data-label); display: block; margin-bottom: 4px; color: var(--ink-500); font-size: 10px; font-weight: 800; }
  .custody-editor-wrap tbody .cell-product { position: absolute; top: 0; right: 0; left: 50px; height: 48px; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); }
  .custody-editor-wrap tbody .cell-product::before { display: none; }
  .custody-editor-wrap tbody .cell-product .input { border: 0; padding: 5px; min-height: 34px; background: transparent; font-size: 15px; font-weight: 800; box-shadow: none; }
  .custody-editor-wrap tbody .cell-row-number { position: absolute; top: 13px; left: 11px; width: 28px; color: var(--ink-400); font-size: 11px; }
  .custody-editor-wrap tbody .cell-row-number::before { display: none; }
  .custody-editor-wrap tbody .cell-note { grid-column: 1 / -1; }
  .custody-editor-wrap tbody .cell-remove { position: absolute; left: 8px; bottom: 8px; width: auto; }
  .custody-editor-wrap tbody .cell-remove::before { display: none; }
  .custody-editor-wrap tbody .cell-remove .btn { min-height: 34px; width: 36px; padding: 0; font-size: 0; }
  .custody-editor-wrap tbody .cell-remove .btn::after { content: "×"; font-size: 20px; line-height: 1; }
  .custody-editor-wrap .computed-cell { min-height: 44px; padding: 10px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-soft); display: flex; align-items: center; justify-content: center; }
  .custody-editor-wrap .input { min-width: 0; min-height: 42px; font-size: 16px; }
  .editor-tools { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .editor-tools .date-field { width: auto; grid-column: 1 / -1; }
  .editor-tools .btn { width: 100%; }
  .editor-savebar { position: sticky; bottom: 78px; z-index: 12; padding: 9px; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); box-shadow: 0 -8px 24px rgba(8,44,35,.08); }
  .editor-savebar-copy { display: none; }
  .editor-savebar .btn { width: 100%; min-height: 48px; }
  .checkbox-list { grid-template-columns: 1fr; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; padding: 18px 14px calc(18px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; }
  .modal-actions { display: grid; grid-template-columns: 1fr; }
  .modal-actions .btn { width: 100%; }
  .toast-container { left: 9px; right: 9px; bottom: 84px; width: auto; }
}

@media (max-width: 560px) {
  body { font-size: 13px; }
  .page-content { padding-inline: 8px; }
  .dashboard-hero { min-height: 158px; padding: 21px 17px; }
  .hero-title { font-size: 24px; }
  .hero-copy { max-width: 94%; }
  .section-heading { align-items: flex-start; }
  .card { padding: 11px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card:nth-child(3) { grid-column: 1 / -1; }
  .status-line { align-items: stretch; flex-direction: column; }
  .status-line .btn { width: 100%; }
  .file-card-top { gap: 8px; }
  .file-cost { min-width: 96px; }
  .admin-stat-grid { gap: 6px; }
  .stat-card { padding: 11px 6px; }
  .stat-value { font-size: 18px; }
  .login-page { display: block; min-height: 100vh; background: linear-gradient(180deg, var(--brand-950) 0, var(--brand-800) 220px, #f6f9f7 220px); padding: 0; }
  .login-brand-panel { display: none; }
  .login-form-panel { min-height: 100vh; display: block; padding: 24px 14px; background: transparent; }
  .login-card { width: 100%; margin: 92px auto 0; padding: 22px 17px; border-radius: 20px; background: #fff; box-shadow: var(--shadow-md); }
  .login-mobile-brand { position: absolute; top: 25px; right: 0; left: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: #fff; }
  .login-mobile-brand .brand-mark { width: 42px; height: 42px; border-radius: 13px; }
  .login-title { font-size: 25px; }
  .login-subtitle { margin-bottom: 22px; }
  .responsive-table tbody td { grid-template-columns: 88px minmax(0, 1fr); }
}

@media print {
  body { background: #fff; padding: 0; }
  .app-sidebar, .mobile-topbar, .main-header, .header-actions, .btn, .actions, .editor-savebar, .toast-container { display: none !important; }
  .app-layout, .app-main { display: block; }
  .page-content { width: 100%; max-width: none; padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .table-wrap { overflow: visible; border: 0; }
  th { position: static; }
}

@media (max-width: 900px) {
  .custody-editor-wrap .computed-cell {
    flex-direction: column;
    align-items: center;
    gap: 3px;
  }
  .custody-editor-wrap .computed-cell::before {
    margin: 0;
  }
}

@media (max-width: 900px) {
  .sidebar-nav {
    display: flex;
  }
  .sidebar-nav .nav-link {
    flex: 1 1 0;
    min-width: 0;
  }
}
.summary-grid-spaced { margin-top: 16px; }
.summary-status-value { font-size: 13px; }
.price-empty-result { grid-column: 1 / -1; }
.mobile-only-action { display: none; }
@media (max-width: 900px) {
  .mobile-only-action { display: inline-flex; }
}

@media (max-width: 560px) {
  .admin-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-stat-grid .stat-card:nth-child(3) { grid-column: 1 / -1; }
  .mobile-only-action { white-space: nowrap; font-size: 11px; padding-inline: 8px; }
  .mobile-only-action .icon { width: 17px; height: 17px; }
}

/* ===== Final custody controls and stable responsive layout ===== */
.collapsible-card {
  padding: 0;
  overflow: hidden;
}
.collapsible-trigger {
  width: 100%;
  min-height: 78px;
  padding: 17px 19px;
  border: 0;
  background: #fff;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-align: right;
  cursor: pointer;
}
.collapsible-trigger:hover { background: var(--surface-soft); }
.collapsible-trigger-copy { min-width: 0; display: grid; gap: 4px; }
.collapsible-trigger-copy .card-title,
.collapsible-trigger-copy .card-subtitle { margin: 0; display: block; }
.collapsible-trigger-side { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.collapsible-hint { color: var(--ink-400); font-size: 11px; font-weight: 700; }
.collapsible-trigger-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--brand-800);
  display: grid;
  place-items: center;
}
.collapsible-trigger-icon .icon { transition: transform .18s ease; }
.collapsible-trigger[aria-expanded="true"] .collapsible-trigger-icon .icon { transform: rotate(180deg); }
.collapsible-panel { padding: 18px; border-top: 1px solid var(--line-soft); }

.unit-select { min-width: 104px; cursor: pointer; }
.computed-cell {
  background: #edf3f0 !important;
  color: var(--brand-950);
  cursor: default;
  user-select: none;
}
.computed-number {
  display: inline-block;
  direction: ltr;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}
.product-delete-note {
  display: block;
  max-width: 94px;
  margin: 4px auto 0;
  color: var(--ink-400);
  font-size: 9px;
  line-height: 1.35;
}
.product-delete-button { white-space: nowrap; }

/* Keep the computer design intact even when the browser window is narrowed. */
@media (min-width: 601px) and (max-width: 900px) {
  :root { --sidebar-width: 190px; }
  body { padding-bottom: 0; }
  .app-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    padding-bottom: 0;
  }
  .app-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: var(--sidebar-width);
    height: auto;
    padding: 16px 11px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--brand-950), #0d3f31 68%, #124b3b);
    box-shadow: -10px 0 38px rgba(8,44,35,.10);
  }
  .sidebar-brand { display: flex; padding: 2px 3px 17px; gap: 8px; }
  .sidebar-logo { width: 39px; height: 39px; border-radius: 12px; }
  .sidebar-brand-title { font-size: 14px; }
  .sidebar-brand-subtitle { font-size: 10px; }
  .sidebar-label { display: block; padding: 16px 8px 7px; }
  .sidebar-spacer { display: block; }
  .sidebar-user { display: block; padding: 9px; }
  .sidebar-nav { height: auto; display: grid; grid-template-columns: 1fr; gap: 5px; }
  .nav-link {
    min-height: 42px;
    padding: 8px 9px;
    border-radius: 10px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    font-size: 12px;
  }
  .nav-link.active { box-shadow: inset -3px 0 0 #d2a14d; }
  .app-main { grid-column: 2; min-width: 0; }
  .main-header {
    display: flex !important;
    min-height: 72px;
    padding: 11px 13px;
    gap: 9px;
  }
  .mobile-topbar { display: none !important; }
  .header-breadcrumb { font-size: 10px; }
  .header-title { font-size: 18px; }
  .header-description { font-size: 11px; }
  .header-actions { flex-wrap: nowrap; gap: 5px; }
  .header-actions .btn { min-height: 36px; padding: 5px 8px; font-size: 11px; white-space: nowrap; }
  .header-actions .icon { width: 16px; height: 16px; }
  .page-content { padding: 16px 13px 30px; }
  .menu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .menu-card { min-height: 126px; padding: 13px; display: flex; }
  .menu-title { font-size: 15px; }
  .menu-description { white-space: normal; font-size: 11px; }
  .price-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .responsive-table { width: 100%; overflow: auto; border: 1px solid var(--line); background: #fff; }
  .responsive-table table { display: table; width: 100%; }
  .responsive-table thead { display: table-header-group; }
  .responsive-table tbody { display: table-row-group; }
  .responsive-table tr { display: table-row; }
  .responsive-table td, .responsive-table th { display: table-cell; width: auto; }
  .responsive-table tbody tr { border: 0; border-radius: 0; box-shadow: none; background: transparent; }
  .responsive-table tbody td {
    min-height: 0;
    padding: 8px;
    border-bottom: 1px solid var(--line-soft);
    border-left: 1px solid var(--line-soft);
    text-align: center !important;
  }
  .responsive-table tbody td::before { display: none; }
  .responsive-table .cell-title { display: table-cell; padding: 8px; background: transparent; font-size: inherit; }

  .custody-editor-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); background: #fff; }
  .custody-editor-wrap .custody-table { display: table; width: 100%; min-width: 1120px !important; }
  .custody-editor-wrap thead { display: table-header-group; }
  .custody-editor-wrap tbody { display: table-row-group; }
  .custody-editor-wrap tbody tr { display: table-row; position: static; padding: 0; border: 0; box-shadow: none; background: transparent; }
  .custody-editor-wrap tbody td {
    display: table-cell;
    width: auto;
    min-width: 0;
    padding: 7px;
    border-bottom: 1px solid var(--line-soft);
    border-left: 1px solid var(--line-soft);
    background: transparent;
    text-align: center;
  }
  .custody-editor-wrap tbody td::before { display: none; }
  .custody-editor-wrap tbody .cell-product,
  .custody-editor-wrap tbody .cell-row-number,
  .custody-editor-wrap tbody .cell-remove {
    position: static;
    width: auto;
    height: auto;
    padding: 7px;
  }
  .custody-editor-wrap tbody .cell-product .input {
    border: 1px solid var(--line);
    padding: 6px 8px;
    min-height: 38px;
    background: #fff;
    font-size: 13px;
    font-weight: 650;
  }
  .custody-editor-wrap tbody .cell-note { grid-column: auto; }
  .custody-editor-wrap tbody .cell-remove .btn {
    width: auto;
    min-height: 34px;
    padding: 5px 8px;
    font-size: 10px;
  }
  .custody-editor-wrap tbody .cell-remove .btn::after { content: none; }
  .custody-editor-wrap .computed-cell { display: table-cell; min-height: 0; border-radius: 0; }
  .custody-editor-wrap .input { min-height: 38px; font-size: 13px; }
  .editor-tools { display: flex; width: auto; grid-template-columns: none; }
  .editor-tools .date-field { width: 180px; grid-column: auto; }
  .editor-tools .btn { width: auto; }
  .editor-savebar { position: static; padding: 13px; box-shadow: none; }
  .editor-savebar-copy { display: block; }
  .editor-savebar .btn { width: auto; min-height: 42px; }
}

/* Phone design keeps every important control visible and proportionally smaller. */
@media (max-width: 600px) {
  .mobile-topbar { display: none !important; }
  .main-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 72px;
    padding: 9px 8px;
    gap: 6px;
    align-items: center;
  }
  .header-breadcrumb { margin-bottom: 1px; font-size: 9px; }
  .header-title { font-size: clamp(14px, 4.3vw, 17px); }
  .header-description { margin-top: 2px; font-size: 9px; line-height: 1.35; }
  .header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    max-width: 142px;
  }
  .header-actions .btn {
    min-height: 33px;
    padding: 4px 7px;
    border-radius: 8px;
    font-size: 10px;
    white-space: nowrap;
  }
  .header-actions .icon { width: 14px; height: 14px; }
  .page-content { padding-top: 10px; }
  .collapsible-trigger { min-height: 66px; padding: 12px; gap: 8px; }
  .collapsible-trigger-side { gap: 5px; }
  .collapsible-hint { display: none; }
  .collapsible-trigger-icon { width: 32px; height: 32px; }
  .collapsible-panel { padding: 10px; }
  .unit-select { width: 100%; min-width: 0; }
  .computed-number { font-size: 14px; }
  .custody-editor-wrap tbody .cell-remove {
    position: static;
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 2px;
  }
  .custody-editor-wrap tbody .cell-remove .btn {
    width: 100%;
    min-height: 36px;
    padding: 5px 8px;
    font-size: 11px;
  }
  .custody-editor-wrap tbody .cell-remove .btn::after { content: none; }
  .product-delete-note { max-width: none; text-align: center; }
  .editor-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-tools .date-field { grid-column: 1 / -1; }
  .editor-tools .btn { min-width: 0; padding-inline: 6px; font-size: 11px; }
}

/* شريط تحريك أعلى جدول العهدة */

.table-scroll-top {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  height: 20px;
  margin: 12px 0 5px;
  overflow-x: auto;
  overflow-y: hidden;
  direction: ltr;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f1f6f3;
  scrollbar-gutter: stable;
}

.table-scroll-top > div {
  height: 1px;
}

.table-scroll-top::-webkit-scrollbar {
  height: 13px;
}

.table-scroll-top::-webkit-scrollbar-track {
  background: #eaf1ed;
  border-radius: 20px;
}

.table-scroll-top::-webkit-scrollbar-thumb {
  background: #91a79d;
  border: 2px solid #eaf1ed;
  border-radius: 20px;
}

/* اتجاه التحريك ثابت */

@media (min-width: 601px) {
  .custody-editor-wrap {
    direction: ltr;
  }

  .custody-editor-wrap .custody-table {
    direction: rtl;
  }

  /* تثبيت رقم السطر جهة اليمين */

  .custody-editor-wrap th:first-child,
  .custody-editor-wrap td:first-child {
    position: sticky;
    right: 0;
    z-index: 6;
    width: 46px;
    min-width: 46px;
    max-width: 46px;
    background: #f4f8f6;
  }

  /* تثبيت اسم الصنف بجانب رقم السطر */

  .custody-editor-wrap th:nth-child(2),
  .custody-editor-wrap td:nth-child(2) {
    position: sticky;
    right: 46px;
    z-index: 6;
    min-width: 205px;
    background: #ffffff;
    box-shadow: -8px 0 12px
      rgba(8, 44, 35, 0.06);
  }

  .custody-editor-wrap th:first-child,
  .custody-editor-wrap th:nth-child(2) {
    z-index: 8;
    background: #e7f0eb;
  }
}

/* الجوال يستخدم بطاقات ولا يحتاج الشريط */

@media (max-width: 600px) {
  .table-scroll-top {
    display: none;
  }
}

/* ===== 2026-08-03: custody naming, editing and fixed computer canvas ===== */

.custody-card-label {
  color: var(--brand-700);
  font-size: 11px;
  font-weight: 850;
}
.custody-current-name {
  margin-top: 1px !important;
  color: var(--brand-950);
  font-size: 19px;
}
.current-custody-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 13px;
}
.editor-mode-badge {
  display: inline-flex;
  margin-bottom: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--brand-100);
  color: var(--brand-700);
  font-size: 10px;
  font-weight: 850;
}
.editor-tools-named .name-field { min-width: 280px; }
.notice-info {
  margin: 12px 0;
  border-color: #bcd8cc;
  background: #eef8f3;
  color: var(--brand-800);
}
.input-locked,
.input:disabled {
  background: #eef3f0;
  color: var(--ink-700);
  cursor: not-allowed;
  opacity: 1;
}
.file-title-wrap { min-width: 0; }
.file-edited-note {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--ink-500);
  font-size: 10px;
}
.file-actions-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* On computers the whole application keeps one fixed layout and scales as a single unit. */
@media (min-width: 601px) {
  html.desktop-fixed-ui {
    --sidebar-width: 270px;
  }

  html.desktop-fixed-ui body {
    padding-bottom: 0 !important;
    overflow-x: hidden;
  }

  html.desktop-fixed-ui .app-layout {
    width: var(--desktop-layout-width) !important;
    min-height: var(--desktop-layout-height) !important;
    padding: 0 !important;
    display: grid !important;
    grid-template-columns: 270px minmax(0, 1fr) !important;
    zoom: var(--desktop-scale);
  }

  html.desktop-fixed-ui .app-sidebar {
    position: sticky !important;
    top: 0 !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 270px !important;
    height: var(--desktop-layout-height) !important;
    padding: 22px 16px 16px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
  }

  html.desktop-fixed-ui .sidebar-brand {
    display: flex !important;
    padding: 4px 6px 24px !important;
    gap: 12px !important;
  }
  html.desktop-fixed-ui .sidebar-logo { width: 45px !important; height: 45px !important; border-radius: 14px !important; }
  html.desktop-fixed-ui .sidebar-brand-title { font-size: 17px !important; }
  html.desktop-fixed-ui .sidebar-brand-subtitle { font-size: 11px !important; }
  html.desktop-fixed-ui .sidebar-label { display: block !important; padding: 23px 12px 8px !important; }
  html.desktop-fixed-ui .sidebar-spacer { display: block !important; }
  html.desktop-fixed-ui .sidebar-user { display: block !important; padding: 12px !important; }

  html.desktop-fixed-ui .sidebar-nav {
    height: auto !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 7px !important;
  }
  html.desktop-fixed-ui .nav-link {
    min-height: 48px !important;
    padding: 10px 12px !important;
    border-radius: 12px !important;
    flex: initial !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: 11px !important;
    font-size: 14px !important;
  }

  html.desktop-fixed-ui .app-main {
    grid-column: 2 !important;
    min-width: 0 !important;
  }
  html.desktop-fixed-ui .main-header {
    display: flex !important;
    min-height: 84px !important;
    padding: 18px 42px !important;
    gap: 18px !important;
  }
  html.desktop-fixed-ui .mobile-topbar { display: none !important; }
  html.desktop-fixed-ui .header-breadcrumb { font-size: 12px !important; }
  html.desktop-fixed-ui .header-title { font-size: 23px !important; }
  html.desktop-fixed-ui .header-description { display: block !important; font-size: 14px !important; }
  html.desktop-fixed-ui .header-actions { display: flex !important; flex-wrap: nowrap !important; gap: 9px !important; }
  html.desktop-fixed-ui .header-actions .btn {
    min-height: 42px !important;
    padding: 8px 15px !important;
    font-size: 14px !important;
    white-space: nowrap !important;
  }
  html.desktop-fixed-ui .header-actions .icon { width: 20px !important; height: 20px !important; }
  html.desktop-fixed-ui .page-content { padding: 26px 42px 46px !important; }

  html.desktop-fixed-ui .editor-tools-named {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(300px, 1.25fr) 200px auto auto !important;
    align-items: end !important;
    gap: 10px !important;
  }
  html.desktop-fixed-ui .editor-tools-named .name-field,
  html.desktop-fixed-ui .editor-tools-named .date-field {
    width: auto !important;
    grid-column: auto !important;
  }
  html.desktop-fixed-ui .editor-tools-named .btn {
    width: auto !important;
    min-height: 44px !important;
  }

  /* The custody table fits fully on the fixed computer canvas. */
  html.desktop-fixed-ui .table-scroll-top { display: none !important; }
  html.desktop-fixed-ui .custody-editor-wrap {
    width: 100% !important;
    overflow: visible !important;
    direction: rtl !important;
    border: 1px solid var(--line) !important;
    background: #fff !important;
  }
  html.desktop-fixed-ui .custody-editor-wrap .custody-editor-table {
    display: table !important;
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    direction: rtl !important;
    font-size: 11px !important;
  }
  html.desktop-fixed-ui .custody-editor-wrap thead { display: table-header-group !important; }
  html.desktop-fixed-ui .custody-editor-wrap tbody { display: table-row-group !important; }
  html.desktop-fixed-ui .custody-editor-wrap tr {
    display: table-row !important;
    position: static !important;
    width: auto !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  html.desktop-fixed-ui .custody-editor-wrap th,
  html.desktop-fixed-ui .custody-editor-wrap td {
    display: table-cell !important;
    position: static !important;
    width: auto;
    min-width: 0 !important;
    height: auto !important;
    padding: 6px 5px !important;
    border-bottom: 1px solid var(--line-soft) !important;
    border-left: 1px solid var(--line-soft) !important;
    background: transparent;
    text-align: center !important;
    vertical-align: middle !important;
    box-shadow: none !important;
  }
  html.desktop-fixed-ui .custody-editor-wrap td::before { display: none !important; }
  html.desktop-fixed-ui .custody-editor-wrap .computed-cell { background: #edf3f0 !important; }
  html.desktop-fixed-ui .custody-editor-wrap .cell-product,
  html.desktop-fixed-ui .custody-editor-wrap .cell-row-number,
  html.desktop-fixed-ui .custody-editor-wrap .cell-remove,
  html.desktop-fixed-ui .custody-editor-wrap .cell-note {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 6px 5px !important;
    grid-column: auto !important;
  }
  html.desktop-fixed-ui .custody-editor-wrap .input {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 34px !important;
    padding: 5px 6px !important;
    border: 1px solid #cbd8d2 !important;
    border-radius: 8px !important;
    background: #fff !important;
    font-size: 11px !important;
    font-weight: 600 !important;
  }
  html.desktop-fixed-ui .custody-editor-wrap .unit-select { min-width: 0 !important; }
  html.desktop-fixed-ui .custody-editor-wrap .computed-number { font-size: 11px !important; }
  html.desktop-fixed-ui .custody-editor-wrap .cell-remove .btn {
    width: 100% !important;
    min-height: 31px !important;
    padding: 4px 4px !important;
    font-size: 9px !important;
    white-space: normal !important;
  }
  html.desktop-fixed-ui .custody-editor-wrap .cell-remove .btn::after { content: none !important; }
  html.desktop-fixed-ui .custody-editor-wrap .product-delete-note { display: none !important; }

  html.desktop-fixed-ui .custody-editor-table th:nth-child(1) { width: 3.5% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(2) { width: 16% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(3) { width: 8% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(4) { width: 7% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(5) { width: 7% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(6) { width: 6.5% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(7) { width: 7.5% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(8) { width: 9% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(9) { width: 8.5% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(10) { width: 7.5% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(11) { width: 11.5% !important; }
  html.desktop-fixed-ui .custody-editor-table th:nth-child(12) { width: 8% !important; }

  html.desktop-fixed-ui .editor-savebar {
    position: static !important;
    padding: 13px !important;
    box-shadow: none !important;
  }
  html.desktop-fixed-ui .editor-savebar-copy { display: block !important; }
  html.desktop-fixed-ui .editor-savebar .btn { width: auto !important; min-height: 42px !important; }
}

@supports not (zoom: 1) {
  @media (min-width: 601px) {
    html.desktop-fixed-ui .app-layout {
      zoom: normal;
      transform: scale(var(--desktop-scale));
      transform-origin: top right;
    }
  }
}

@media (max-width: 600px) {
  .editor-tools-named .name-field,
  .editor-tools-named .date-field {
    grid-column: 1 / -1;
    width: auto;
  }
  .current-custody-actions .btn { width: 100%; }
  .custody-current-name { font-size: 16px; }
  .file-actions-three { grid-template-columns: 1fr 1fr; }
  .file-actions-three .btn-primary { grid-column: 1 / -1; grid-row: 1; }
}


.profit-positive { color: #087f5b !important; }
.profit-negative { color: #c0392b !important; }
.profit-zero { color: var(--ink-700) !important; }
