:root {
  --green: #087166;
  --green-dark: #074f4b;
  --green-soft: #eaf6f3;
  --purple: #715fc1;
  --purple-soft: #f2efff;
  --ink: #173536;
  --muted: #667b7b;
  --line: #d7e3e1;
  --surface: #ffffff;
  --background: #f4f8f7;
  --warning: #8a6418;
  --warning-soft: #fff5dc;
  --danger: #a13f48;
  --danger-soft: #fff0f1;
  --shadow: 0 14px 40px rgba(7, 79, 75, 0.1);
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: Arial, "Noto Sans Arabic", sans-serif;
}

button,
input,
select,
textarea { font: inherit; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(8, 113, 102, 0.2);
  outline-offset: 1px;
}

.hidden,
[hidden] { display: none !important; }

.logo-img { width: 100%; height: 100%; object-fit: contain; display: block; }

.eyebrow {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.btn {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 800;
  cursor: pointer;
}

.btn:hover { border-color: var(--green); }
.btn.primary { color: #fff; border-color: var(--green); background: var(--green); }
.btn.secondary { color: var(--green-dark); border-color: #a9d1ca; background: var(--green-soft); }
.btn.danger { color: var(--danger); border-color: #efc8cb; background: var(--danger-soft); }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 11px; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 9px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.warning { color: var(--warning); background: var(--warning-soft); }
.badge.purple { color: #5f4ea8; background: var(--purple-soft); }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.badge.neutral { color: #526565; background: #edf2f1; }

#login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background:
    radial-gradient(circle at 10% 10%, #e2f4f0 0, transparent 34%),
    radial-gradient(circle at 90% 88%, #eeeaff 0, transparent 30%),
    #fff;
}

.login-story {
  padding: 52px 7vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-story .logo { width: 176px; height: 150px; }
.login-story h1 { max-width: 760px; margin: 18px 0 8px; color: #123f40; font-size: 42px; line-height: 1.35; }
.login-story > p { max-width: 690px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.9; }

.scope-strip {
  max-width: 720px;
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.scope-strip div {
  padding: 12px;
  border: 1px solid #cfe3df;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 800;
}

.demo-notice {
  max-width: 700px;
  margin-top: 18px;
  padding: 13px 16px;
  border: 1px solid #ddd5f4;
  border-inline-start: 5px solid var(--purple);
  border-radius: 12px;
  background: #fbfaff;
  color: #655b88;
  font-size: 11px;
  line-height: 1.8;
}

.login-area { display: grid; place-items: center; padding: 28px; }
.login-card { width: min(470px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.login-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.login-head .logo { width: 90px; height: 78px; }
.login-card h2 { margin: 14px 0 4px; font-size: 28px; }
.login-card .sub { margin-bottom: 18px; color: var(--muted); font-size: 11px; line-height: 1.7; }

.field { display: grid; gap: 6px; margin: 11px 0; }
.field label { font-size: 11px; font-weight: 900; }
.field small { color: var(--muted); font-size: 9px; line-height: 1.5; }
.field input,
.field select,
.field textarea,
.filter-control {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fbfdfd;
}

.field textarea { min-height: 92px; resize: vertical; line-height: 1.7; }
.field input:read-only { color: #5e7473; background: #edf3f2; }
.login-card .primary { width: 100%; margin-top: 8px; }

#app { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; }

.sidebar {
  height: 100vh;
  padding: 17px 14px;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: linear-gradient(180deg, var(--green-dark), #063a38);
}

.brand { padding: 0 4px 15px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #ffffff24; }
.brand .logo { width: 66px; height: 58px; padding: 4px; border-radius: 12px; background: #fff; }
.brand b { display: block; font-size: 12px; line-height: 1.5; }
.brand small { display: block; margin-top: 4px; color: #c6e3df; font-size: 9px; }

.nav { margin-top: 14px; display: grid; gap: 4px; overflow-y: auto; }
.nav button {
  min-height: 38px;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  color: #dff1ef;
  background: transparent;
  text-align: start;
  font-size: 11px;
  cursor: pointer;
}
.nav button:hover,
.nav button.active { color: #fff; background: #ffffff1b; }
.sidebar-note { margin-top: auto; padding-top: 12px; border-top: 1px solid #ffffff20; color: #c1dbd8; font-size: 9px; line-height: 1.7; }

.main { min-width: 0; padding: 22px 26px 52px; }
.topbar { margin-bottom: 17px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.topbar h1 { margin: 0; font-size: 24px; }
.topbar small { color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.demo-chip { padding: 6px 9px; border: 1px solid #ead49b; border-radius: 999px; color: #7c5a10; background: #fff8e4; font-size: 9px; font-weight: 900; }

.page { display: none; }
.page.active { display: block; }
.page-heading { margin-bottom: 13px; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.page-heading h2 { margin: 0 0 4px; font-size: 19px; }
.page-heading p { max-width: 760px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.actions { display: flex; gap: 7px; flex-wrap: wrap; }

.card { border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 8px 24px rgba(7, 79, 75, 0.045); }
.panel { margin-top: 13px; padding: 17px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.panel-header { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-header h3 { margin: 0; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 13px; }
.grid-2 > *,
.grid-3 > *,
.form-grid > * { min-width: 0; }
.form-grid .wide { grid-column: 1 / -1; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px; }
.kpi span { color: var(--muted); font-size: 10px; }
.kpi strong { display: block; margin-top: 7px; font-size: 27px; }
.kpi small { display: block; margin-top: 5px; color: var(--green); font-size: 9px; }

.table-wrap { width: 100%; overflow: auto; }
.data-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.data-table.compact { min-width: 620px; }
.data-table th,
.data-table td { padding: 10px 8px; border-bottom: 1px solid #e9f0ef; text-align: start; vertical-align: middle; font-size: 10px; }
.data-table th { color: #5f7373; background: #f8fbfa; font-size: 9px; font-weight: 900; white-space: nowrap; }
.data-table tbody tr:hover { background: #fbfdfd; }
.data-table input,
.data-table select { min-width: 100px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 10px; }
.data-table .comment-input { min-width: 180px; }

.filters { margin-bottom: 11px; display: flex; align-items: end; gap: 8px; flex-wrap: wrap; }
.filters .field { min-width: 150px; margin: 0; }
.filters .field.search { min-width: 240px; flex: 1; }

.flow { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.step { padding: 11px 6px; border: 1px solid var(--line); border-radius: 10px; text-align: center; font-size: 9px; line-height: 1.5; }
.step.done { color: var(--green-dark); background: var(--green-soft); }
.step.current { color: #fff; border-color: var(--green); background: var(--green); }

.role-guide { margin-bottom: 13px; display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 12px; }
.role-guide > div { padding: 17px; }
.role-guide h2 { margin: 6px 0; font-size: 18px; }
.role-guide p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.8; }
.authority { border-color: #ddd5f4; background: #fbfaff; }
.authority b { display: block; margin-bottom: 6px; color: #6555a0; font-size: 10px; }

.upload-box {
  min-height: 95px;
  padding: 16px;
  display: grid;
  place-items: center;
  border: 1.5px dashed #95c4bd;
  border-radius: 12px;
  background: #f7fcfb;
  text-align: center;
}
.upload-box input { max-width: 100%; }
.upload-box b { display: block; margin-bottom: 5px; font-size: 11px; }
.upload-box small { color: var(--muted); font-size: 9px; }
.file-status { display: block; margin-top: 7px; color: var(--green); font-size: 9px; font-weight: 800; }

.readiness { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 15px; }
.readiness-score { width: 96px; height: 96px; display: grid; place-items: center; direction: ltr; unicode-bidi: isolate; border: 10px solid #c9e6e1; border-radius: 50%; color: var(--green); font-size: 21px; font-weight: 900; }
.progress { height: 8px; overflow: hidden; border-radius: 999px; background: #e5edeb; }
.progress span { width: 0; height: 100%; display: block; border-radius: inherit; background: var(--green); transition: width 0.25s ease; }
.readiness-message { margin-top: 8px; color: var(--muted); font-size: 10px; line-height: 1.6; }

.metric-input { width: 86px !important; direction: ltr; text-align: left; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }
.htvi-box { padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border: 1px solid #aed4cd; border-radius: 14px; background: linear-gradient(135deg, #f7fcfb, #f5f2ff); }
.htvi-box strong { color: var(--green); font-size: 48px; }
.htvi-box p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }

.audit-hash { max-width: 150px; overflow: hidden; color: #617575; font-family: monospace; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.empty-state { padding: 30px; color: var(--muted); text-align: center; font-size: 11px; }

dialog { width: min(820px, calc(100% - 28px)); max-height: 90vh; padding: 0; border: 0; border-radius: 18px; box-shadow: 0 28px 90px rgba(6, 58, 56, 0.28); }
dialog::backdrop { background: rgba(5, 43, 42, 0.56); }
.dialog-head { padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-body { max-height: calc(90vh - 132px); padding: 18px 20px; overflow: auto; }
.dialog-actions { padding: 13px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }

.toast {
  z-index: 20;
  position: fixed;
  inset-inline-end: 24px;
  bottom: 24px;
  max-width: 390px;
  padding: 13px 16px;
  border-radius: 11px;
  color: #fff;
  background: var(--green-dark);
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 800;
}

.report-list { margin-bottom: 14px; }
.sheet { display: none; margin-top: 15px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.sheet.preview { display: block; }
.paper { width: min(100%, 900px); min-height: 1120px; margin: auto; padding: 34px 38px; background: #fff; }
.paper + .paper { border-top: 9px solid var(--background); }
.report-head { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 16px; }
.report-head .logo { width: 88px; height: 78px; }
.report-title { margin: 4px 0; color: #123f40; font-size: 25px; font-weight: 900; }
.report-subtitle { color: #3d746f; font-size: 12px; }
.report-rule { height: 4px; margin: 16px 0 20px; background: var(--green); }
.report-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; }
.report-meta div { padding: 8px 0; display: grid; grid-template-columns: 120px 1fr; border-bottom: 1px dotted #cad7d5; font-size: 10px; }
.report-section { margin: 20px 0 10px; padding-inline-start: 9px; border-inline-start: 5px solid var(--green); font-size: 15px; font-weight: 900; }
.report-note { margin-top: 13px; padding: 11px; border: 1px solid #ddd5f4; border-radius: 9px; color: #655b88; background: #fbfaff; font-size: 9px; line-height: 1.8; }
.report-footer { margin-top: 25px; padding-top: 9px; border-top: 1px solid var(--line); color: #8b9b9a; text-align: center; font-size: 8px; }

@media (max-width: 980px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { min-width: 0; height: auto; position: static; }
  .nav { display: flex; }
  .nav button { white-space: nowrap; }
  .sidebar-note { display: none; }
  .main { padding: 16px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .flow { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  #login { grid-template-columns: 1fr; }
  .login-story { padding: 28px 20px 12px; }
  .login-story .logo { width: 120px; height: 105px; }
  .login-story h1 { font-size: 29px; }
  .login-story > p { font-size: 14px; }
  .login-area { padding: 14px 14px 30px; }
  .scope-strip { grid-template-columns: 1fr; }
  .topbar,
  .page-heading { align-items: flex-start; flex-direction: column; }
  .grid-2,
  .grid-3,
  .role-guide,
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .wide { grid-column: auto; }
  .flow { grid-template-columns: repeat(2, 1fr); }
  .report-meta { grid-template-columns: 1fr; }
  .paper { min-height: 0; padding: 22px; }
}

@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .main { padding: 12px; }
  .panel { padding: 13px; }
  .htvi-box strong { font-size: 38px; }
}

@media print {
  body { background: #fff; }
  #login,
  .sidebar,
  .topbar,
  .page { display: none !important; }
  #app,
  .main { display: block !important; padding: 0 !important; }
  #reports { display: block !important; }
  #reports > :not(.sheet) { display: none !important; }
  .sheet { display: none !important; margin: 0 !important; border: 0 !important; }
  .sheet.print-target { display: block !important; }
  .sheet.print-target .paper { width: 210mm; height: 297mm; min-height: 297mm; max-height: 297mm; margin: 0; padding: 15mm 14mm; overflow: hidden; page-break-after: always; break-after: page; }
  .sheet.print-target .paper:last-child { page-break-after: auto; break-after: auto; }
  @page { size: A4; margin: 0; }
}
