/* מסמך סיכום החיוב (תצוגה מקדימה ו-PDF). תמיד בהיר, בלי קשר למצב הכהה של האפליקציה. */

.doc-preview {
  background: #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
}
.doc-preview .doc {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  margin: 0 auto;
}
.doc-preview .doc + .doc {
  margin-top: 14px;
}
.doc-scale {
  transform-origin: top right;
}

.doc {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f8fafc;
  --accent: #1d4ed8;
  --accent-soft: #eff6ff;
  width: 794px;
  max-width: none;
  background: #fff;
  color: var(--ink);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  direction: rtl;
  padding: 44px 48px 40px;
}
.doc .num {
  direction: rtl;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}
.doc .muted {
  color: var(--muted);
}

/* ראש המסמך: פרטי המנפיק מימין, סוג המסמך ומספרו משמאל */
.doc .d-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ink);
}
.doc .d-brand-name {
  font-size: 19px;
  font-weight: 800;
}
.doc .d-brand-details {
  color: var(--muted);
  font-size: 12px;
  white-space: pre-line;
  margin-top: 2px;
}
.doc .d-doctitle {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}
.doc .d-docmeta {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 14px;
  margin-top: 6px;
  font-size: 12.5px;
}
.doc .d-docmeta span {
  color: var(--muted);
}
.doc .d-docmeta b {
  font-weight: 700;
}
.doc .d-paid {
  display: inline-block;
  margin-top: 8px;
  padding: 2px 10px;
  border-radius: 99px;
  background: #dcfce7;
  color: #15803d;
  font-weight: 800;
  font-size: 12px;
}

/* שלושה כרטיסים: לכבוד, תקופה, סכום לתשלום */
.doc .d-info {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}
.doc .d-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.doc .d-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.doc .d-name {
  font-size: 16px;
  font-weight: 800;
}
.doc .d-strong {
  font-size: 14px;
  font-weight: 700;
}
.doc .d-small {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.doc .d-due {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.doc .d-due .d-label,
.doc .d-due .d-small {
  color: rgba(255, 255, 255, 0.85);
}
.doc .d-due-amt {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

/* קריאות מונה */
.doc .d-meter {
  margin-top: 18px;
}
.doc .d-meter-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 8px;
}
.doc .d-meter-head svg {
  width: 18px;
  height: 18px;
}
.doc .d-meter.elec .d-meter-head svg {
  color: #d97706;
}
.doc .d-meter.water .d-meter-head svg {
  color: #0284c7;
}
.doc .d-meter-no {
  margin-inline-start: auto;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
}
.doc .d-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.doc .d-tile {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
}
.doc .d-tile .k {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 700;
}
.doc .d-tile .v {
  font-size: 16px;
  font-weight: 800;
  margin-top: 1px;
}
.doc .d-tile .s {
  font-size: 11.5px;
  color: var(--muted);
}

/* טבלת החיובים */
.doc .d-h2 {
  margin-top: 22px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 800;
}
.doc table.d-charges {
  width: 100%;
  border-collapse: collapse;
}
.doc .d-charges th {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  background: var(--soft);
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.doc .d-charges td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.doc .d-charges .c-desc {
  text-align: start;
  width: 44%;
  font-weight: 600;
}
.doc .d-charges .c-qty,
.doc .d-charges .c-price {
  text-align: end;
  width: 19%;
  color: #334155;
}
.doc .d-charges .c-amt {
  text-align: end;
  width: 18%;
  font-weight: 700;
}
.doc .d-charges th.c-desc {
  font-weight: 700;
}
.doc .d-charges .c-detail {
  display: none;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.doc .d-charges tr.c-group td {
  background: #fff;
  font-weight: 800;
  font-size: 12.5px;
  color: var(--accent);
  padding-top: 12px;
  border-bottom: 1px solid var(--line);
}
.doc .d-footnote {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

/* סיכום סכומים בצד שמאל */
.doc .d-totals {
  width: 300px;
  margin-inline-start: auto;
  margin-top: 14px;
}
.doc .d-trow {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 2px;
  font-size: 13.5px;
}
.doc .d-trow span {
  color: #334155;
}
.doc .d-trow b {
  font-weight: 700;
}
.doc .d-trow.d-grand {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
}
.doc .d-trow.d-grand span {
  color: var(--accent);
  font-weight: 800;
}
.doc .d-trow.d-grand b {
  font-weight: 800;
}

/* הערות, חתימות ותחתית */
.doc .d-notes-box {
  margin-top: 20px;
  border-inline-start: 3px solid var(--accent);
  background: var(--soft);
  border-radius: 8px 0 0 8px;
  padding: 10px 14px;
}
.doc .d-notes {
  white-space: pre-wrap;
  font-size: 13px;
}
.doc .d-sign {
  margin-top: 36px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  font-size: 12px;
  color: var(--muted);
}
.doc .d-sign div {
  border-top: 1px solid #94a3b8;
  padding-top: 6px;
}
.doc .d-footline {
  margin-top: 22px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* עמודי צילומים */
.doc .d-photos-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--ink);
}
.doc .d-photo {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.doc .d-photo img {
  display: block;
  width: 100%;
  max-height: 430px;
  object-fit: contain;
  background: var(--soft);
}
.doc .d-photo .cap {
  padding: 8px 12px;
  font-weight: 700;
  font-size: 12.5px;
  border-top: 1px solid var(--line);
}

/* תצוגה מקדימה במסך צר: המסמך מתאים את עצמו לרוחב (ה-PDF נשאר A4) */
@media (max-width: 560px) {
  .doc-preview {
    padding: 6px;
  }
}
.doc-preview.fluid {
  padding: 0;
  background: none;
}
.doc-preview.fluid .doc {
  width: auto;
  padding: 18px 14px;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
}
.doc-preview.fluid .d-top {
  flex-direction: column;
  gap: 10px;
}
.doc-preview.fluid .d-info {
  grid-template-columns: 1fr;
}
.doc-preview.fluid .d-tiles {
  grid-template-columns: repeat(2, 1fr);
}
.doc-preview.fluid .d-charges .c-qty,
.doc-preview.fluid .d-charges .c-price {
  display: none;
}
.doc-preview.fluid .d-charges .c-detail {
  display: block;
}
.doc-preview.fluid .d-charges .c-desc {
  width: auto;
}
.doc-preview.fluid .d-charges td,
.doc-preview.fluid .d-charges th {
  padding: 8px;
}
.doc-preview.fluid .d-totals {
  width: 100%;
}
.doc-preview.fluid .d-sign {
  gap: 16px;
}
.doc-preview.fluid .doc[style*='min-height'] {
  min-height: 0 !important;
}
.doc-preview.fluid .d-photo img {
  max-height: 320px;
}

/* טבלת קריאות קומפקטית (חשמל ומים יחד) */
.doc .d-readings td {
  padding: 7px 12px;
}
.doc .d-readings .c-desc {
  width: 22%;
}
.doc .d-readings .c-qty,
.doc .d-readings .c-amt {
  width: auto;
  font-weight: 700;
  color: var(--ink);
}
.doc .d-readings .c-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.doc .d-type {
  display: inline-flex;
  vertical-align: -3px;
  margin-inline-end: 4px;
}
.doc .d-type svg {
  width: 15px;
  height: 15px;
}
.doc .d-type.elec {
  color: #d97706;
}
.doc .d-type.water {
  color: #0284c7;
}
.doc-preview.fluid .d-readings th:nth-child(5),
.doc-preview.fluid .d-readings td:nth-child(5) {
  display: none;
}
.doc-preview.fluid .d-readings .c-qty {
  display: table-cell;
}

/* ריווח מהודק כדי שחיוב רגיל (גם חשמל וגם מים) ייכנס לעמוד A4 אחד */
.doc {
  padding: 34px 44px 30px;
}
.doc .d-top {
  padding-bottom: 14px;
}
.doc .d-paid {
  margin-top: 5px;
}
.doc .d-info {
  margin-top: 16px;
  gap: 10px;
}
.doc .d-card {
  padding: 10px 12px;
}
.doc .d-meter {
  margin-top: 14px;
}
.doc .d-h2 {
  margin-top: 16px;
  margin-bottom: 6px;
}
.doc .d-charges th {
  padding: 6px 12px;
}
.doc .d-charges td {
  padding: 6px 12px;
}
.doc .d-charges tr.c-group td {
  padding-top: 8px;
}
.doc .d-readings td {
  padding: 5px 12px;
}
.doc .d-footnote {
  margin-top: 4px;
}
.doc .d-totals {
  margin-top: 10px;
}
.doc .d-trow {
  padding: 4px 2px;
}
.doc .d-trow.d-grand {
  padding: 8px 12px;
}
.doc .d-notes-box {
  margin-top: 14px;
  padding: 8px 12px;
}
.doc .d-sign {
  margin-top: 28px;
}
.doc .d-footline {
  margin-top: 14px;
  padding-top: 8px;
}
.doc .d-doctitle .d-paid {
  margin: 0;
  margin-inline-start: 10px;
  vertical-align: 4px;
}
