/* راتبي — فوق توكنز فلوسنا. موبايل أولًا. */

body {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: 84px; /* مساحة التبويبات */
}

.view { padding: 18px 20px 24px; }
.view[hidden], .sheet[hidden], [hidden] { display: none !important; }

/* ─── رأس الشاشة ─── */
.app-head { padding: 10px 0 18px; display: flex; flex-direction: column; gap: 10px; }
.brand { font-size: 22px; font-weight: 700; line-height: 1.4; }
.payday-line { color: var(--text-2); font-size: 14.5px; }

/* ─── الإعداد ─── */
.ob-wrap { padding-top: 26px; }
.ob-brand { font-size: 17px; font-weight: 700; margin-bottom: 34px; }
.ob-brand span { color: var(--text-2); font-weight: 400; font-size: 14px; }
.ob-step h1 { font-size: 27px; font-weight: 700; line-height: 1.45; margin-bottom: 6px; }
.hint { color: var(--text-2); font-size: 14.5px; margin-bottom: 18px; }

.money-field {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 18px; margin-bottom: 12px;
}
.money-field input {
  flex: 1; border: 0; outline: 0; background: none; color: var(--text);
  font-family: inherit; font-size: 26px; font-weight: 600;
  direction: ltr; text-align: left; font-variant-numeric: tabular-nums; min-width: 0;
}
.money-field span { color: var(--text-2); font-size: 15px; }
.money-field.big input { font-size: 34px; }

.select-field {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px;
}
.select-field > span { font-size: 13.5px; color: var(--text-2); }
.select-field select {
  appearance: none; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font-family: inherit; font-size: 17px;
  border-radius: var(--r-sm); padding: 12px 14px;
}

.check-field {
  display: flex; align-items: center; gap: 10px; margin: 6px 0 18px;
  color: var(--text-2); font-size: 14.5px;
}
.check-field input { width: 20px; height: 20px; accent-color: var(--primary); }

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

.commit-rows { display: grid; gap: 8px; margin-bottom: 10px; }
.commit-row { display: flex; gap: 8px; }
.commit-row input {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 15.5px; border-radius: var(--r-sm); padding: 11px 12px; min-width: 0;
}
.commit-row .c-name { flex: 1.4; }
.commit-row .c-amount { flex: 1; direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.commit-row .c-del {
  border: 0; background: none; color: var(--danger); font-size: 20px; cursor: pointer; padding: 0 4px;
}

/* ─── أزرار ─── */
.btn {
  display: block; width: 100%; border: 0; cursor: pointer; text-align: center;
  font-size: 16.5px; font-weight: 600; border-radius: 999px; padding: 14px 22px; margin-top: 10px;
}
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:active { transform: scale(0.985); }
.btn.ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.btn.link, .btn.danger-link { background: none; font-weight: 400; font-size: 14.5px; color: var(--text-2); }
.btn.danger-link { color: var(--danger); }
.btn.wide { flex: 1; }
.field-error { color: var(--danger); font-size: 13.5px; margin: 2px 0 6px; }

/* ─── حلقة العد ─── */
.ring-wrap { position: relative; width: 232px; margin: 8px auto 4px; }
.ring { width: 232px; height: 232px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 13; stroke-linecap: round; }
.ring .track { stroke: var(--ring-track); }
.ring .prog { stroke: var(--primary); transition: stroke-dashoffset 0.7s cubic-bezier(0.4, 0, 0.2, 1); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0;
}
.days-label { color: var(--text-2); font-size: 14.5px; line-height: 1.4; }
.days-num { font-size: 56px; font-weight: 700; line-height: 1.4; }
.days-num.txt { font-size: 38px; }

/* ─── بطاقة المتاح ─── */
.today-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 20px 22px; text-align: center; margin-top: 14px;
}
.tc-label { color: var(--text-2); font-size: 14.5px; }
.tc-amount { font-size: 42px; font-weight: 700; line-height: 1.4; }
.tc-amount small { font-size: 17px; font-weight: 400; color: var(--text-2); }
.today-card.over .tc-amount { color: var(--danger); }
.tc-sub { color: var(--text-2); font-size: 13.5px; }

.home-actions { display: flex; gap: 10px; margin-top: 16px; }
.home-actions .btn { margin-top: 0; }
.home-actions .ghost { width: auto; }

/* ─── السجل ─── */
.log-list { display: grid; gap: 16px; }
.log-day-title { font-size: 14px; color: var(--text-2); margin-bottom: 8px; }
.log-day-total { float: left; font-variant-numeric: tabular-nums; }
.log-items { display: grid; gap: 6px; }
.log-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 12px 14px;
}
.log-item .cat { flex: 1; font-size: 15.5px; }
.log-item .amt { font-weight: 600; font-size: 16px; }
.log-item .del {
  border: 0; background: none; color: var(--text-2); cursor: pointer; font-size: 17px; padding: 2px 4px;
}
.empty { color: var(--text-2); text-align: center; padding: 40px 10px; font-size: 15px; }

/* ─── التقرير ─── */
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 4px; }
.seg-btn {
  flex: 1; border: 0; background: none; color: var(--text-2); font-family: inherit;
  font-size: 14.5px; font-weight: 600; padding: 8px 10px; border-radius: 999px; cursor: pointer;
}
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.report-body { display: grid; gap: 14px; }
.rep-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px 20px;
}
.rep-range { color: var(--text-2); font-size: 13.5px; margin-bottom: 4px; }
.rep-total { font-size: 32px; font-weight: 700; line-height: 1.4; }
.rep-total small { font-size: 15px; font-weight: 400; color: var(--text-2); }
.rep-vs { color: var(--text-2); font-size: 13.5px; }

.bar-row { margin-bottom: 12px; }
.bar-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.bar-head .v { color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; background: var(--ring-track); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 99px; }
.rep-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; line-height: 1.4; }
.top-item { display: flex; justify-content: space-between; font-size: 14.5px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.top-item:last-child { border-bottom: 0; }
.top-item .v { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ─── الإعدادات ─── */
.set-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px; margin-bottom: 14px;
}
.set-title { font-weight: 700; margin-bottom: 4px; }
.saved-note { color: var(--primary); font-size: 14px; margin-top: 8px; text-align: center; }
.foot-sign { text-align: center; color: var(--text-2); font-size: 13.5px; padding: 10px 0 20px; }
.foot-sign a { color: var(--text-2); }

/* ─── ورقة المصروف ─── */
.sheet {
  position: fixed; inset: 0; background: rgba(8, 14, 11, 0.55); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-panel {
  width: 100%; max-width: 460px; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
}
.sheet-title { font-size: 19px; font-weight: 700; margin-bottom: 12px; line-height: 1.4; }
.cats { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.cat-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 14.5px; border-radius: 999px; padding: 9px 16px; cursor: pointer;
}
.cat-chip.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* ─── التبويبات ─── */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 460px; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
}
.tab {
  flex: 1; border: 0; background: none; color: var(--text-2); font-family: inherit;
  font-size: 13.5px; font-weight: 600; padding: 10px 4px; border-radius: var(--r-sm); cursor: pointer;
}
.tab.active { color: var(--primary); background: var(--surface-2); }

/* ─── طباعة التقرير A4 ─── */
@media print {
  body { max-width: none; padding: 0; background: #fff; color: #111; }
  .view, .tabbar, .sheet { display: none !important; }
  #view-report { display: block !important; padding: 0; }
  .no-print { display: none !important; }
  .rep-card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; margin-bottom: 10mm; }
  .report-body::before {
    content: 'راتبي · فلوسنا من بذرة — flosna.bithrah.sa';
    display: block; font-size: 11px; color: #666; margin-bottom: 8mm;
  }
}
