/* مكونات فلوسنا المشتركة (قسمها، جمعيتنا) — فوق tokens.css.
   الهيكل: .shell = شبكة سطح المكتب (سكة تعريف يمنى ثابتة + مساحة عمل)،
   وعلى الجوال عمود واحد. كل صف داخل grid يحمل min-width:0 — درس «المفقعة». */

body { min-height: 100dvh; }

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 22px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 26px;
}

@media (min-width: 960px) {
  .shell {
    grid-template-columns: 340px minmax(0, 560px);
    justify-content: center;
    gap: 44px;
    padding-top: 34px;
  }
  .rail { position: sticky; top: 34px; align-self: start; }
}

/* ─── السكة: هوية الأداة ─── */
.rail { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.rail .r-glyph {
  width: 58px; height: 58px; border-radius: 17px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--mint), var(--primary));
  color: var(--on-primary);
  box-shadow: 0 10px 26px var(--mint-glow);
  margin-bottom: 16px;
}
.rail .r-glyph svg { width: 30px; height: 30px; }
.rail h1 { font-size: 34px; font-weight: 700; line-height: 1.4; }
.rail .r-tag { color: var(--text-2); font-size: 16.5px; margin-top: 4px; }
.rail .r-points { list-style: none; margin-top: 22px; display: grid; gap: 12px; }
.rail .r-points li {
  color: var(--text-2); font-size: 14.5px; line-height: 1.7;
  padding-right: 26px; position: relative;
}
.rail .r-points li::before {
  content: ''; position: absolute; right: 0; top: 9px;
  width: 14px; height: 14px; border-radius: 5px;
  background: var(--mint-glow); border: 1px solid var(--primary);
}
.rail .r-from {
  display: inline-block; margin-top: 26px; color: var(--text-3); font-size: 13.5px;
  text-decoration: none; border-top: 1px solid var(--line-2); padding-top: 14px;
}
.rail .r-from b { color: var(--text-2); font-weight: 600; }
.mob-head { padding-top: 26px; }
@media (max-width: 959.9px) {
  .rail h1 { font-size: 27px; }
  .rail .r-points { display: none; }
  .rail .r-glyph { width: 46px; height: 46px; border-radius: 14px; margin-bottom: 10px; }
  .rail .r-glyph svg { width: 24px; height: 24px; }
  .rail .r-from { margin-top: 10px; border: 0; padding: 0; }
}

/* ─── مساحة العمل ─── */
.work { display: grid; gap: 16px; align-content: start; }
.work > * { animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both; animation-delay: calc(var(--d, 0) * 70ms); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: var(--glass);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 24px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.card h2 { font-size: 19px; font-weight: 700; line-height: 1.45; margin-bottom: 4px; }
.hint { color: var(--text-2); font-size: 14px; margin-bottom: 14px; line-height: 1.7; }

/* ─── الحقول ─── */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; min-width: 0; }
.field > span { font-size: 13.5px; color: var(--text-2); font-weight: 600; }
.field input, .field select {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 16.5px; border-radius: var(--r-sm); padding: 13px 15px;
  appearance: none; min-width: 0; width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--mint-glow);
}
.field input[inputmode='decimal'], .field input[type='number'] {
  direction: ltr; text-align: left; font-variant-numeric: tabular-nums;
}

.row { display: flex; gap: 10px; align-items: center; min-width: 0; }
.grow { flex: 1; min-width: 0; }

/* ─── الأزرار ─── */
.btn {
  display: block; width: 100%; border: 0; cursor: pointer; text-align: center;
  font-family: inherit; font-size: 16.5px; font-weight: 600;
  border-radius: 999px; padding: 14px 20px; margin-top: 10px;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
}
.btn.primary {
  background: linear-gradient(160deg, var(--mint), var(--primary));
  color: var(--on-primary);
  box-shadow: 0 8px 22px var(--mint-glow);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px var(--mint-glow); }
.btn.primary:active { transform: scale(0.985); }
.btn.ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--text-3); }
.btn.small { width: auto; font-size: 14px; padding: 8px 16px; margin: 0; }
.field-error { color: var(--danger); font-size: 13.5px; margin: 2px 0 8px; }

/* ─── مبدّل الوضع ─── */
.seg {
  display: flex; background: var(--surface-2); border: 1px solid var(--line-3);
  border-radius: 999px; padding: 4px; gap: 4px; margin-bottom: 14px;
}
.seg-btn {
  flex: 1; border: 0; background: none; color: var(--text-2); font-family: inherit;
  font-size: 14.5px; font-weight: 600; padding: 10px; border-radius: 999px; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }

/* ─── صفوف البنود/الأعضاء — min-width:0 على كل مستوى ─── */
.item-rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; margin-bottom: 10px; }
.item-row { display: flex; gap: 8px; min-width: 0; }
.item-row input {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 15px; border-radius: var(--r-sm); padding: 12px;
  min-width: 0; width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.item-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--mint-glow); }
.item-row .i-name { flex: 3; }
.item-row .i-price { flex: 1.6; direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.item-row .i-qty { flex: 1; direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.item-row .i-del {
  border: 0; background: none; color: var(--text-3); font-size: 17px; cursor: pointer;
  padding: 0 4px; flex: none; transition: color 0.2s;
}
.item-row .i-del:hover { color: var(--danger); }
.cols-note { display: flex; gap: 8px; margin-bottom: 6px; }
.cols-note span { font-size: 12.5px; color: var(--text-3); }
.cols-note .n1 { flex: 3; } .cols-note .n2 { flex: 1.6; } .cols-note .n3 { flex: 1; margin-inline-end: 25px; }

/* ─── القوائم ─── */
.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
.list-item {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 13px 15px;
  transition: border-color 0.2s, transform 0.15s;
}
.list-item:hover { border-color: var(--line); }
.list-item .grow { min-width: 0; }
.list-item .t { font-size: 15.5px; font-weight: 600; display: block; }
.list-item .s { font-size: 13px; color: var(--text-2); display: block; }
.list-item .v { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; direction: ltr; }
.list-item.me { border-color: var(--primary); background: var(--mint-glow); }

.pill {
  font-size: 12.5px; border-radius: 999px; padding: 4px 13px; font-weight: 600; flex: none;
}
.pill.ok { background: var(--primary); color: var(--on-primary); }
.pill.wait { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line-2); }
.pill.gold { background: linear-gradient(100deg, #f4d491, #e7c185); color: #3d2f14; }

/* ─── شريط الإجمالي الحي ─── */
.live-total {
  position: sticky; bottom: 14px; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 12px 22px;
  box-shadow: var(--shadow);
}
.live-total .lt-label { color: var(--text-2); font-size: 13.5px; }
.live-total .lt-value {
  margin-inline-start: auto; font-size: 22px; font-weight: 700;
  font-variant-numeric: tabular-nums; direction: ltr;
  transition: color 0.2s;
}
.live-total .lt-value small { font-size: 13px; font-weight: 400; color: var(--text-2); }

/* ─── صناديق النسخ ─── */
.copybox {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-sm);
  padding: 13px 15px; font-size: 13.5px; color: var(--text-2); line-height: 1.8;
  word-break: break-all; margin: 8px 0;
}
.copied { color: var(--primary); font-size: 13px; text-align: center; margin-top: 6px; }

.total-line { display: flex; justify-content: space-between; font-size: 15px; padding: 7px 0; }
.total-line b { font-variant-numeric: tabular-nums; direction: ltr; }
.total-line.grand { border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 12px; font-weight: 700; }

/* ─── مصفوفة الجمعية ─── */
.matrix { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.matrix th, .matrix td { border: 1px solid var(--line-2); padding: 9px 7px; text-align: center; }
.matrix th { color: var(--text-2); font-weight: 600; background: var(--surface-2); }
.matrix td.st { cursor: pointer; user-select: none; font-weight: 600; color: var(--text-3); transition: background 0.15s; }
.matrix td.st:hover { background: var(--mint-glow); }
.matrix td.st.marked { color: var(--gold); }
.matrix td.st.confirmed { color: var(--primary); }
.matrix .rowhead { text-align: right; font-weight: 600; }
.matrix-wrap { overflow-x: auto; }

.empty { color: var(--text-2); text-align: center; padding: 30px 10px; font-size: 15px; }
.foot-sign { text-align: center; color: var(--text-3); font-size: 13.5px; padding: 22px 0; }
.foot-sign a { color: var(--text-3); }
