:root {
  --green: #15803d;
  --green-dark: #14532d;
  --green-soft: #eaf5ee;
  --ink: #1c2321;
  --muted: #6b7280;
  --line: #e2e6e3;
  --bg: #f3f5f3;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* header */
.top {
  background: linear-gradient(160deg, #14532d, #15803d);
  color: #fff;
  padding: 26px 0 22px;
  border-radius: 0 0 22px 22px;
  margin-bottom: 18px;
}
.top h1 { margin: 0 0 6px; font-size: 1.45rem; letter-spacing: 0; }
.top .lead { margin: 0; font-size: .95rem; color: #d7ecdd; }

/* cards */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
  box-shadow: 0 1px 2px rgba(16, 40, 24, .04);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.step {
  width: 26px; height: 26px; flex: 0 0 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--green-soft); color: var(--green-dark);
  font-weight: 700; font-size: .85rem;
}
.step.done { background: var(--green); color: #fff; }

/* file drop */
.drop {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-align: center; cursor: pointer;
  border: 2px dashed #cfd8d1; border-radius: 14px;
  background: #fbfcfb; padding: 16px 12px; margin-bottom: 10px;
  transition: border-color .15s, background .15s;
  min-height: 92px;
}
.drop:active { background: var(--green-soft); border-color: var(--green); }
.drop.has-file { border-style: solid; border-color: var(--green); background: var(--green-soft); }
.drop input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; font-size: 0;
}
.drop-icon { font-size: 1.4rem; line-height: 1; }
.drop-title { font-weight: 700; font-size: .98rem; }
.drop-sub { font-size: .82rem; color: var(--muted); padding: 0 4px; }
.drop.has-file .drop-sub { color: var(--green-dark); }

.hint { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }

/* settings grid */
.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.grid.three { grid-template-columns: 1fr 1fr 1fr; }
.grid label, .row-line { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--muted); }
.grid select, .grid input, .row-line select {
  width: 100%; padding: 9px 10px; font-size: .95rem; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font-family: inherit;
}
.grid select:focus, .grid input:focus, .row-line select:focus { outline: 2px solid var(--green); outline-offset: 1px; }

/* collapsible settings */
.panel { margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.panel summary {
  cursor: pointer; padding: 11px 12px; font-weight: 600; font-size: .92rem;
  background: #f7f9f7; list-style: none;
}
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: "▾"; float: left; color: var(--muted); }
.panel[open] summary::after { content: "▴"; }
.panel-body { padding: 12px; border-top: 1px solid var(--line); }

.mini { width: 100%; border-collapse: collapse; margin: 6px 0 10px; font-size: .9rem; }
.mini th, .mini td { border-bottom: 1px solid var(--line); padding: 7px 6px; text-align: center; }
.mini th { font-weight: 600; color: var(--muted); font-size: .8rem; }
.mini input[type="number"] {
  width: 84px; padding: 6px; text-align: center; font-family: inherit; font-size: .92rem;
  border: 1px solid var(--line); border-radius: 8px;
}
.mini input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--green); }
.row-line { margin-bottom: 12px; }

/* action */
.go {
  width: 100%; padding: 15px; margin: 4px 0 16px;
  font-family: inherit; font-size: 1.05rem; font-weight: 700; color: #fff;
  background: var(--green); border: 0; border-radius: 14px;
  cursor: pointer; box-shadow: 0 2px 0 #0f5c2c;
}
.go:disabled { background: #b9c7bd; box-shadow: none; cursor: default; }
.go:not(:disabled):active { transform: translateY(1px); box-shadow: none; }

.status {
  padding: 12px 14px; border-radius: 12px; font-size: .9rem; margin-bottom: 14px;
  background: #fff; border: 1px solid var(--line);
}
.status.error { background: #fef2f2; border-color: #fecaca; color: var(--bad); }
.status.work { background: var(--green-soft); border-color: #c8e6d3; color: var(--green-dark); }

/* results */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { background: #f8faf8; border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; }
.stat .k { display: block; font-size: .74rem; color: var(--muted); }
.stat .v { display: block; font-size: 1.12rem; font-weight: 700; }
.stat.warn { background: #fffbeb; border-color: #fde68a; }
.stat.warn .v { color: var(--warn); }
.stat.bad { background: #fef2f2; border-color: #fecaca; }
.stat.bad .v { color: var(--bad); }

.notes-line {
  font-size: .86rem; background: var(--green-soft); border: 1px solid #c8e6d3;
  border-radius: 10px; padding: 9px 12px; margin: 0 0 12px; color: var(--green-dark);
}
.notes-line b { font-variant-numeric: tabular-nums; }

.issues { margin: 0 0 12px; padding: 0; list-style: none; font-size: .85rem; }
.issues li { padding: 7px 10px; border-radius: 10px; background: #fffbeb; border: 1px solid #fde68a; margin-bottom: 6px; color: #78350f; }
.issues li.bad { background: #fef2f2; border-color: #fecaca; color: var(--bad); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.preview { border-collapse: collapse; width: 100%; font-size: .8rem; white-space: nowrap; }
.preview th, .preview td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.preview th { background: #f4f7f4; font-weight: 600; font-size: .74rem; color: #40544a; }
.preview td.name { text-align: right; max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.preview tr.total td { background: var(--green-soft); font-weight: 700; }
.preview td.bad { color: var(--bad); font-weight: 700; }

.download {
  display: block; text-align: center; text-decoration: none;
  padding: 13px; border-radius: 12px; font-weight: 700;
  background: var(--green-dark); color: #fff;
}
.download.off { background: #cbd5cf; pointer-events: none; }

footer { padding: 8px 0 34px; }
footer p { font-size: .78rem; color: var(--muted); text-align: center; margin: 0; }

@media (min-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 640px) {
  .top h1 { font-size: 1.7rem; }
  .grid { grid-template-columns: 1fr 1fr 1fr; }
  .card { padding: 20px; }
  .drop { min-height: 104px; }
}
