:root {
  --ink: #17201c;
  --muted: #64736e;
  --line: #d7ded9;
  --paper: #fbfaf4;
  --panel: #ffffff;
  --green: #1f6b4d;
  --green-deep: #154633;
  --gold: #b8842f;
  --red: #9f2f2f;
  --shadow: 0 18px 50px rgba(23, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(31, 107, 77, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(31, 107, 77, 0.06) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

button,
input {
  font: inherit;
}

button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  padding: 10px 14px;
  min-height: 42px;
}

button:hover,
.file-button:hover {
  border-color: var(--green);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.icon-button svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}

.primary:hover {
  background: var(--green-deep);
}

.danger {
  color: var(--red);
}

.file-button {
  display: inline-flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
}

header.app-shell {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: 32px 0 18px;
}

.form-mode header.app-shell {
  display: none;
}

.form-mode main.app-shell {
  width: min(100vw - 20px, 760px);
  padding: 10px 0 36px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.4rem, 5vw, 4.7rem);
  line-height: 0.92;
}

.lead {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.05rem;
  margin-bottom: 0;
}

.top-actions,
.form-actions,
.report-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.layout,
.admin-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(620px, 1.4fr);
  gap: 18px;
  align-items: start;
  padding-bottom: 48px;
}

.login-panel,
.individual-panel {
  max-width: 980px;
  margin: 0 auto 48px;
}

.form-mode .individual-panel {
  margin-bottom: 0;
  box-shadow: none;
}

.form-mode #newEntry {
  display: none;
}

.login-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

#loginMessage,
#copyMessage,
.helper-text {
  color: var(--muted);
  margin: 0;
}

.helper-text {
  margin-top: 12px;
  font-size: 0.92rem;
}

.admin-layout {
  padding-bottom: 48px;
}

.admin-groups {
  display: grid;
  gap: 18px;
}

.admin-group {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef9;
}

.admin-group > span,
.share-link > span {
  color: var(--muted);
  font-size: 0.9rem;
}

.link-copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.link-copy-row .icon-button {
  white-space: nowrap;
}

.report-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.report-actions button {
  color: white;
  border: 0;
}

.report-de {
  background: var(--green-deep);
}

.report-ur {
  background: var(--gold);
}

.report-de:hover,
.report-ur:hover {
  filter: brightness(0.94);
}

.danger-zone {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.subtle-danger {
  min-height: 36px;
  padding: 7px 10px;
  border-color: transparent;
  background: transparent;
  color: rgba(159, 47, 47, 0.72);
  font-size: 0.9rem;
}

.subtle-danger:hover {
  border-color: rgba(159, 47, 47, 0.2);
  background: rgba(159, 47, 47, 0.05);
  color: var(--red);
}

.submission-list {
  display: grid;
  gap: 10px;
  max-height: 300px;
  overflow: auto;
}

.submission-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef9;
}

.submission-item span,
.empty-state {
  color: var(--muted);
}

.panel,
.report-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-heading,
.report-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-heading h2,
.report-toolbar h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.panel-heading span,
.report-toolbar p {
  color: var(--muted);
  margin: 0;
}

.settings-grid,
.identity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef9;
  color: var(--ink);
}

input:focus {
  outline: 2px solid rgba(31, 107, 77, 0.2);
  border-color: var(--green);
}

.task-form {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.day-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fffef9;
}

.day-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  background: #eef4ef;
  color: var(--green-deep);
  font-weight: 700;
}

.task-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.task-label {
  display: grid;
  gap: 5px;
}

.task-label .de {
  line-height: 1.35;
}

.task-label .ur {
  color: #2d3d37;
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  font-family: "Geeza Pro", "Noto Nastaliq Urdu", "Times New Roman", serif;
}

.toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-width: 112px;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle label {
  padding: 8px 10px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
}

.toggle input:checked + label {
  background: var(--green);
  color: white;
}

.form-mode .panel {
  padding: 14px;
}

.form-mode .panel-heading {
  display: block;
  margin-bottom: 14px;
}

.form-title-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.form-mode .panel-heading h2,
.form-title-grid h2 {
  margin: 0;
  font-size: clamp(1.55rem, 7vw, 2rem);
  line-height: 1.1;
}

.form-title-grid h2[dir="rtl"] {
  font-family: "Geeza Pro", "Noto Nastaliq Urdu", "Times New Roman", serif;
}

.form-mode .panel-heading h2 span,
.form-title-grid h2 span {
  color: var(--muted);
  font-size: 0.72em;
  font-weight: 700;
}

.form-mode .identity-grid {
  grid-template-columns: 1fr;
}

.form-mode input {
  min-height: 54px;
  font-size: 1.1rem;
}

.form-mode .task-form {
  gap: 14px;
}

.form-mode .day-group {
  border-radius: 8px;
}

.form-mode .day-title {
  padding: 14px;
  font-size: 1.08rem;
}

.form-mode .task-row {
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px 14px;
  align-items: stretch;
}

.form-mode .task-label {
  gap: 8px;
}

.form-mode .task-label .de {
  font-size: 1.08rem;
}

.form-mode .task-label .ur {
  font-size: 1.04rem;
  text-align: right;
}

.form-mode .toggle {
  width: 100%;
  min-width: 0;
}

.form-mode .toggle label {
  min-height: 52px;
  display: grid;
  place-items: center;
  padding: 10px 8px;
  font-size: 1.05rem;
  font-weight: 700;
}

.form-mode .form-actions {
  display: grid;
  gap: 10px;
}

.form-mode .form-actions button {
  width: 100%;
  min-height: 56px;
}

.form-mode .submitted-lock input,
.form-mode .submitted-lock button,
.form-mode .submitted-lock .toggle label {
  cursor: not-allowed;
}

.success-screen {
  min-height: 64vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 30px 16px;
  text-align: center;
}

.success-icon {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: white;
  box-shadow: 0 14px 35px rgba(31, 107, 77, 0.28);
}

.success-icon svg {
  width: 48px;
  height: 48px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.success-screen h2 {
  margin: 10px 0 0;
  font-size: clamp(2rem, 8vw, 3.25rem);
  line-height: 1;
}

.success-screen p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.1rem, 4vw, 1.45rem);
  font-weight: 700;
}

.success-screen .success-urdu {
  color: var(--green-deep);
  font-family: "Geeza Pro", "Noto Nastaliq Urdu", "Times New Roman", serif;
}

.form-actions {
  margin-top: 16px;
}

.report-panel {
  grid-row: span 2;
  overflow: hidden;
}

.report-toolbar {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #f7f7f0;
}

.report {
  padding: 22px;
  background: white;
}

.bismillah {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 8px;
}

.report h2,
.report h3 {
  text-align: center;
  margin-bottom: 6px;
}

.report h3 {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 400;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
  font-size: 0.95rem;
}

.meta-grid div {
  border-bottom: 1px solid var(--line);
  min-height: 30px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.report-table th,
.report-table td {
  border: 1px solid #9da8a2;
  padding: 7px 8px;
  vertical-align: top;
}

.report-table th {
  background: #eef4ef;
}

.report-table .task-cell {
  display: grid;
  gap: 5px;
}

.report-table .ur {
  direction: rtl;
  text-align: right;
  font-family: "Geeza Pro", "Noto Nastaliq Urdu", "Times New Roman", serif;
}

.urdu-report,
.urdu-report .report-table,
.urdu-report .note {
  font-family: "Geeza Pro", "Noto Nastaliq Urdu", "Times New Roman", serif;
}

.urdu-report .report-table th,
.urdu-report .report-table td {
  text-align: right;
}

.count-cell {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
}

.note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 1080px) {
  header.app-shell {
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .report-panel {
    grid-row: auto;
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100vw - 20px, 1480px);
  }

  .settings-grid,
  .identity-grid,
  .meta-grid,
  .login-form,
  .submission-item,
  .link-copy-row,
  .report-actions,
  .form-title-grid {
    grid-template-columns: 1fr;
  }

  .task-row {
    grid-template-columns: 1fr;
  }

  .toggle {
    width: 100%;
  }
}

@media print {
  body {
    background: white;
  }

  .no-print,
  .report-toolbar {
    display: none !important;
  }

  .app-shell,
  .layout,
  .admin-layout,
  .report-panel {
    width: 100%;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .report {
    padding: 0;
  }

  .report-table {
    font-size: 9.5pt;
  }

  .report-table th,
  .report-table td {
    padding: 4px 5px;
  }
}
