/* =========================================================================
   إرادة — أنماط تطبيق لوحة الأداء (تكميلية لـ identity.css)
   شاشة عرض متجاوبة + صفحة إدخال، مبنية على نفس الرموز اللونية للهوية.
   ========================================================================= */

@import url("https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap");

html,
body {
  direction: rtl;
}
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
}

/* ---- app shell (responsive, not fixed slide) -------------------------- */
.wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-4) var(--space-6);
}

/* ---- top brand bar ---------------------------------------------------- */
.appbar {
  background: linear-gradient(135deg, var(--teal-600) 0%, var(--teal-800) 75%, var(--teal-900) 100%);
  color: #fff;
  border-bottom: 4px solid var(--gold-500);
  position: relative;
  overflow: hidden;
}
.appbar::before {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  top: -190px;
  left: -120px;
}
.appbar__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  position: relative;
}
.appbar__logo {
  height: 56px;
  flex: 0 0 auto;
  background: #fff;
  padding: 6px 10px;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(3, 59, 66, 0.18);
}
.appbar__titles {
  flex: 1 1 auto;
}
.appbar__org {
  font-size: 15px;
  color: var(--teal-100);
  font-weight: 500;
  margin-bottom: 4px;
}
.appbar__title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 30px;
  line-height: 1.2;
}
.appbar__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  flex: 0 0 auto;
  text-align: start;
}
.appbar__chip {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.appbar__chip b {
  color: var(--gold-300);
}
.appbar__select {
  background: transparent;
  color: #fff;
  border: none;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.appbar__select option {
  color: var(--ink);
  background: #fff;
}

/* ---- action buttons --------------------------------------------------- */
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.06s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn--gold {
  background: var(--gold-500);
  color: #3a2a08;
}
.btn--gold:hover {
  background: var(--gold-300);
}
.btn--teal {
  background: var(--teal-600);
  color: #fff;
}
.btn--teal:hover {
  background: var(--teal-500);
}
.btn--ghost {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.24);
}
.btn--outline {
  background: #fff;
  color: var(--teal-700);
  border: 1.5px solid var(--teal-600);
}
.btn--outline:hover {
  background: var(--teal-50);
}

/* ---- tabs ------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  flex-wrap: wrap;
}
.tab {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal-700);
  border-radius: var(--radius-pill);
  padding: 11px 26px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.15s ease;
}
.tab:hover {
  border-color: var(--teal-300);
}
.tab.is-active {
  background: var(--teal-600);
  color: #fff;
  border-color: var(--teal-600);
}
.tab .tab__k {
  color: var(--gold-500);
  font-weight: 800;
  margin-inline-end: 6px;
}
.tab.is-active .tab__k {
  color: var(--gold-300);
}
.panel {
  display: none;
  animation: fade 0.25s ease;
}
.panel.is-active {
  display: block;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---- section titles inside app ---------------------------------------- */
.sec-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 22px;
  color: var(--teal-700);
  margin: var(--space-5) 0 var(--space-3);
  position: relative;
  padding-bottom: 10px;
}
.sec-title::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 64px;
  height: 4px;
  border-radius: 3px;
  background: var(--gold-500);
}

/* ---- KPI cards (dashboard hero row) ----------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}
.kpi-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
  padding: var(--space-4) var(--space-3) var(--space-3);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 5px;
  background: var(--teal-500);
}
.kpi-card.is-green::before {
  background: #2f9e6b;
}
.kpi-card.is-yellow::before {
  background: var(--gold-500);
}
.kpi-card.is-red::before {
  background: #c0433f;
}
.kpi-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.kpi-card__label {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.5;
  max-width: 72%;
}
.kpi-card__num {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 40px;
  color: var(--teal-600);
  line-height: 1;
}
.kpi-card__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}
.kpi-card__target {
  color: var(--muted);
}
.kpi-card__target b {
  color: var(--teal-700);
}

/* ---- status + trend badges -------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.badge.green {
  background: #e4f4ec;
  color: #1f7a51;
}
.badge.green .dot {
  background: #2f9e6b;
}
.badge.yellow {
  background: var(--gold-100);
  color: var(--gold-600);
}
.badge.yellow .dot {
  background: var(--gold-500);
}
.badge.red {
  background: #fbe6e5;
  color: #a5322e;
}
.badge.red .dot {
  background: #c0433f;
}
.badge.none {
  background: var(--line);
  color: var(--muted);
}
.badge.none .dot {
  background: var(--muted);
}

.trend {
  font-weight: 800;
  font-size: 17px;
  display: inline-block;
  width: 24px;
  text-align: center;
}
.trend.up {
  color: #2f9e6b;
}
.trend.flat {
  color: var(--muted);
}
.trend.down {
  color: #c0433f;
}

/* ---- big table (method 1) --------------------------------------------- */
.tbl td .comment {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}
.tbl .axis-cell {
  font-weight: 700;
  color: var(--teal-700);
}
.tbl .val-strong {
  font-family: var(--font-head);
  font-weight: 800;
  color: var(--teal-700);
  font-size: 17px;
}
.tbl .tgt {
  color: var(--muted);
  font-size: 14px;
}
.tbl-wrap {
  overflow-x: auto;
}

/* ---- summary distribution bar ----------------------------------------- */
.dist {
  display: flex;
  height: 34px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  background: var(--line);
}
.dist span {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  min-width: 0;
}
.dist .g {
  background: #2f9e6b;
}
.dist .y {
  background: var(--gold-500);
}
.dist .r {
  background: #c0433f;
}

/* ---- narrative (method 2) --------------------------------------------- */
.narr {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
  padding: var(--space-5);
}
.narr h3 {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 21px;
  color: var(--teal-700);
  margin: var(--space-4) 0 var(--space-2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.narr h3:first-child {
  margin-top: 0;
}
.narr h3 .roman {
  background: var(--teal-600);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-pill);
  padding: 4px 14px;
}
.narr p {
  font-size: 16.5px;
  line-height: 1.95;
  color: var(--ink);
  margin-bottom: var(--space-2);
  text-align: justify;
}
.narr .hr {
  height: 2px;
  background: var(--gold-500);
  opacity: 0.5;
  border-radius: 2px;
  margin: var(--space-3) 0;
}

/* ---- executive summary block ------------------------------------------ */
.exec {
  background: linear-gradient(160deg, var(--teal-600), var(--teal-800));
  color: #fff;
  border-radius: var(--radius-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-lift);
  margin-top: var(--space-4);
}
.exec h3 {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 22px;
  margin-bottom: var(--space-3);
  color: #fff;
}
.exec h3::after {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  background: var(--gold-500);
  border-radius: 3px;
  margin-top: 10px;
}
.exec p {
  font-size: 16.5px;
  line-height: 1.9;
  color: var(--teal-100);
}
.exec .cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.exec .col {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-card);
  padding: var(--space-3) var(--space-4);
}
.exec .col h4 {
  font-size: 15px;
  color: var(--gold-300);
  margin-bottom: 8px;
  font-weight: 700;
}
.exec .col p {
  color: #fff;
  font-size: 15.5px;
}

/* ---- footer ----------------------------------------------------------- */
.appfoot {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-3);
  font-size: 13px;
  color: var(--muted);
}
.appfoot .line {
  flex: 1 1 auto;
  height: 2px;
  background: var(--gold-500);
  opacity: 0.55;
  border-radius: 2px;
}

/* ---- entry form ------------------------------------------------------- */
.form-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.form-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}
.form-card__title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 18px;
  color: var(--teal-700);
}
.form-card__axis {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.form-card__target {
  background: var(--teal-50);
  color: var(--teal-800);
  border-radius: var(--radius-pill);
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.fieldrow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(26, 130, 144, 0.12);
}
.field textarea {
  resize: vertical;
  min-height: 46px;
}
.field .hint {
  font-size: 12px;
  color: var(--muted);
}
.field--full {
  grid-column: 1 / -1;
}

/* auto-computed achieved input */
.field input.is-auto {
  background: var(--teal-50);
  border-color: var(--teal-300);
  color: var(--teal-800);
  font-family: var(--font-head);
  font-weight: 800;
  cursor: not-allowed;
}
/* auto trend display (read-only) */
.trend-view {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  background: var(--paper);
  min-height: 44px;
  font-weight: 700;
  font-size: 14px;
}
.trend-view .lbl {
  color: var(--ink);
}
.trend-view .lbl.muted {
  color: var(--muted);
  font-weight: 500;
}

/* status quick-picker */
.statuspick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.statuspick label {
  cursor: pointer;
}
.statuspick input {
  display: none;
}
.statuspick .opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 8px 15px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  transition: all 0.12s ease;
}
.statuspick .opt .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}
.statuspick .g .dot {
  background: #2f9e6b;
}
.statuspick .y .dot {
  background: var(--gold-500);
}
.statuspick .r .dot {
  background: #c0433f;
}
.statuspick input:checked + .opt.g {
  border-color: #2f9e6b;
  background: #e4f4ec;
  color: #1f7a51;
}
.statuspick input:checked + .opt.y {
  border-color: var(--gold-500);
  background: var(--gold-100);
  color: var(--gold-600);
}
.statuspick input:checked + .opt.r {
  border-color: #c0433f;
  background: #fbe6e5;
  color: #a5322e;
}

/* sticky save bar */
.savebar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(3, 59, 66, 0.08);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: 0 calc(-1 * var(--space-4));
}
.savebar__status {
  font-size: 14px;
  color: var(--muted);
}
.savebar__status.ok {
  color: #1f7a51;
  font-weight: 700;
}
.savebar__status.err {
  color: #a5322e;
  font-weight: 700;
}

/* toast */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--teal-800);
  color: #fff;
  padding: 12px 26px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 50;
  border: 1px solid var(--gold-500);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* empty-state note */
.note {
  background: var(--gold-100);
  border-right: 5px solid var(--gold-500);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
  margin: var(--space-3) 0;
}
.note strong {
  color: var(--gold-600);
}

/* ---- responsive ------------------------------------------------------- */
@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 820px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .appbar__inner {
    flex-wrap: wrap;
  }
  .exec .cols {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 520px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .appbar__title {
    font-size: 22px;
  }
}

/* ---- print (board handout / PDF) -------------------------------------- */
@media print {
  @page {
    size: A4 landscape;
    margin: 12mm;
  }
  body {
    background: #fff;
  }
  .no-print {
    display: none !important;
  }
  .panel {
    display: block !important;
  }
  .tabs {
    display: none;
  }
  .appbar {
    border-bottom-color: var(--gold-500);
  }
  .kpi-card,
  .narr,
  .exec,
  .tbl {
    box-shadow: none;
    break-inside: avoid;
  }
  .exec {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .sec-title {
    break-after: avoid;
  }
}
