@font-face {
  font-family: "Vazirmatn";
  src: url("fonts/vazirmatn-arabic-wght-normal.woff2") format("woff2-variations");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

body {
  font-family: "Vazirmatn", Tahoma, "Segoe UI", Arial, sans-serif;
  line-height: 1.8;
  font-feature-settings: "kern" 1;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfdfd;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 11px;
  outline: 0;
  transition: .2s;
  font: inherit;
}

select:focus { border-color: #7dc3ba; box-shadow: 0 0 0 3px rgba(14,137,126,.09); background: #fff; }

.settings-grid .full-width { grid-column: 1 / -1; }
.api-guide { padding: 26px 28px; }
.guide-head { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.guide-head h2 { margin: 3px 0 4px; font-size: 20px; }
.guide-head p { margin: 0; color: var(--muted); font-size: 12px; }
.guide-steps { counter-reset: api-step; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.guide-step { counter-increment: api-step; border: 1px solid var(--line); border-radius: 14px; padding: 15px; background: #fbfdfd; }
.guide-step::before { content: counter(api-step); width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px; background: var(--teal-soft); color: var(--teal-dark); font-weight: 800; font-size: 11px; margin-bottom: 9px; }
.guide-step strong { display: block; font-size: 12px; margin-bottom: 3px; }
.guide-step p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.9; }
.guide-table { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.guide-table table { width: 100%; border-collapse: collapse; min-width: 720px; }
.guide-table th, .guide-table td { padding: 11px 13px; border-bottom: 1px solid #edf2f1; text-align: right; font-size: 11px; vertical-align: top; }
.guide-table th { background: #f5f9f8; color: var(--muted); font-size: 10px; }
.guide-table tr:last-child td { border-bottom: 0; }
.source-badge { display: inline-flex; border-radius: 999px; padding: 2px 7px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.source-badge.auto { background: #e5f7ee; color: #20835c; }
.source-badge.manual { background: var(--gold-soft); color: #9a6c20; }
.guide-note { margin: 14px 0 0; padding: 11px 13px; border-radius: 11px; background: #fff8eb; color: #77551e; font-size: 11px; }
.guide-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.video-uploader { margin: 10px 0 12px; padding: 12px; border: 1px solid #cfe4e1; border-radius: 14px; background: #f7fbfa; }
.uploader-head { display: grid; margin-bottom: 9px; }
.uploader-head strong { font-size: 12px; }
.uploader-head small { color: var(--muted); font-size: 9px; }
.upload-dropzone { min-height: 88px; border: 1.5px dashed #8ec8c0; border-radius: 12px; display: grid; place-items: center; align-content: center; text-align: center; padding: 12px; background: #fff; cursor: pointer; transition: .2s; }
.upload-dropzone:hover, .upload-dropzone.dragging { border-color: var(--teal); background: var(--teal-soft); }
.upload-dropzone input { display: none; }
.upload-dropzone span { color: var(--teal-dark); font-size: 12px; font-weight: 800; }
.upload-dropzone small { color: var(--muted); font-size: 9px; font-weight: 400; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress { height: 7px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #dceae8; direction: ltr; }
.upload-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #38b8a9); transition: width .2s; }
.upload-message { margin: 8px 1px 0; color: var(--muted); font-size: 9px; line-height: 1.7; }
.upload-message.error-text { color: var(--danger); }
.upload-message.success-text { color: #20835c; }
.process-note { display: block; margin: 6px 4px 0; color: var(--muted); font-size: 9px; text-align: center; }
.inline-action { margin-top: 8px; }
.record-toolbar-actions { align-items: center; flex-wrap: wrap; }
.record-toolbar-actions form { margin: 0; }
.button.danger { border-color: #efc4c4; background: #fff2f2; color: #a93434; }
.button.danger:hover { border-color: #dc9292; background: #ffe8e8; }
.stalled-run-note { margin-top: 9px; padding: 10px 11px; border: 1px solid #efd3a3; border-radius: 11px; background: #fff8eb; color: #77551e; font-size: 9px; line-height: 1.8; }
.stalled-run-note strong { display: block; font-size: 10px; }
.stalled-run-note p { margin: 2px 0 0; }
.metric-group + .metric-group { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 20px; }
.metric-group h3 { margin: 0; font-size: 13px; }
.metric-group > p { margin: 2px 0 12px; color: var(--muted); font-size: 10px; }
.metric-group label small { min-height: 32px; line-height: 1.7; }
.percent-input { position: relative; direction: ltr; }
.percent-input input { padding-right: 32px; }
.percent-input span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 11px; }
.source-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
.watch-time-entry { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; margin-bottom: 12px; }
.watch-time-entry label { font-size: 10px; }
.watch-time-entry input { margin-top: 5px; }
.watch-time-summary { display: block; direction: ltr; margin: -2px 0 13px; padding: 8px 11px; border-radius: 9px; background: #f0faf8; color: var(--teal-dark); font-size: 11px; font-weight: 800; text-align: left; }
.retention-grid { margin-top: 4px; }
.breakdown-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.source-breakdown-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 0; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: #fbfdfd; }
.metric-pair legend { padding: 0 6px; color: var(--ink); font-size: 11px; font-weight: 800; }
.metric-pair label { font-size: 10px; }
.metric-pair label small { display: block; min-height: 0; margin-top: 5px; color: var(--muted); font-size: 8px; }
.metric-pair input[data-calculated="1"] { background: #f0faf8; border-color: #a9d9d2; }
input[readonly] { background: #f3f6f5; color: var(--teal-dark); font-weight: 700; }

@media (max-width: 1100px) {
  .settings-grid .full-width { grid-column: auto; }
  .guide-steps { grid-template-columns: repeat(2, 1fr); }
  .source-grid { grid-template-columns: repeat(3, 1fr); }
  .watch-time-entry { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .guide-head { display: block; }
  .guide-head .button { margin-top: 10px; }
  .guide-steps { grid-template-columns: 1fr; }
  .api-guide { padding: 20px; }
  .source-grid { grid-template-columns: 1fr; }
  .watch-time-entry, .breakdown-grid, .source-breakdown-grid { grid-template-columns: 1fr; }
}
