/* Adapted from Zayid v7.2.0→v7.3.0 QC guide layout */

    :root {
      --bg: #f4f6f9;
      --surface: #ffffff;
      --border: #e2e8f0;
      --border-strong: #cbd5e1;
      --text: #0f172a;
      --text-muted: #475569;
      --text-light: #64748b;
      --accent: #0e5c6e;
      --accent-light: #e6f3f6;
      --agent: #1d4ed8;
      --agent-bg: #eff6ff;
      --ops: #6d28d9;
      --ops-bg: #f5f3ff;
      --web: #047857;
      --web-bg: #ecfdf5;
      --mobile: #b45309;
      --mobile-bg: #fffbeb;
      --cross: #334155;
      --cross-bg: #f1f5f9;
      --p0: #b91c1c;
      --p0-bg: #fef2f2;
      --p1: #b45309;
      --p1-bg: #fffbeb;
      --p2: #475569;
      --p2-bg: #f1f5f9;
      --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
      --radius: 10px;
      --nav-width: 260px;
      --content-max: 1480px;
    }
    *, *::before, *::after { box-sizing: border-box; }
    html { scroll-behavior: smooth; }
    body {
      margin: 0;
      font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
      font-size: 15px;
      line-height: 1.55;
      color: var(--text);
      background: var(--bg);
    }
    .layout {
      display: grid;
      grid-template-columns: var(--nav-width) 1fr;
      min-height: 100vh;
    }
    .sidebar {
      position: sticky;
      top: 0;
      height: 100vh;
      overflow-y: auto;
      background: var(--surface);
      border-right: 1px solid var(--border);
      padding: 1.25rem 0;
    }
    .sidebar-brand {
      padding: 0 1.25rem 1rem;
      border-bottom: 1px solid var(--border);
      margin-bottom: 0.75rem;
    }
    .sidebar-brand .logo {
      font-weight: 700;
      font-size: 1.05rem;
      color: var(--accent);
      letter-spacing: -0.02em;
    }
    .sidebar-brand .ver {
      font-size: 0.8rem;
      color: var(--text-light);
      margin-top: 0.2rem;
    }
    .nav-group { margin-bottom: 0.5rem; }
    .nav-group-title {
      font-size: 0.68rem;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--text-light);
      padding: 0.5rem 1.25rem 0.25rem;
    }
    .nav-link {
      display: block;
      padding: 0.4rem 1.25rem;
      font-size: 0.875rem;
      color: var(--text-muted);
      text-decoration: none;
      border-left: 3px solid transparent;
      transition: background 0.15s, color 0.15s;
    }
    .nav-link:hover { background: var(--bg); color: var(--text); }
    .nav-link.active {
      color: var(--accent);
      background: var(--accent-light);
      border-left-color: var(--accent);
      font-weight: 500;
    }
    .nav-link.agent:hover, .nav-link.agent.active { border-left-color: var(--agent); color: var(--agent); background: var(--agent-bg); }
    .nav-link.ops:hover, .nav-link.ops.active { border-left-color: var(--ops); color: var(--ops); background: var(--ops-bg); }
    .nav-link.web:hover, .nav-link.web.active { border-left-color: var(--web); color: var(--web); background: var(--web-bg); }
    .nav-link.mobile:hover, .nav-link.mobile.active { border-left-color: var(--mobile); color: var(--mobile); background: var(--mobile-bg); }
    .main { min-width: 0; }
    .hero {
      background: linear-gradient(135deg, #0e5c6e 0%, #134e5e 100%);
      color: #fff;
      padding: 2.5rem 2.5rem 2rem;
    }
    .hero-inner { max-width: var(--content-max); margin: 0 auto; }
    .hero h1 {
      margin: 0 0 0.5rem;
      font-size: 1.85rem;
      font-weight: 700;
      letter-spacing: -0.03em;
    }
    .hero .subtitle { opacity: 0.9; font-size: 1.05rem; max-width: 720px; }
    .hero-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 0.75rem;
      margin-top: 1.25rem;
    }
    .badge {
      display: inline-flex;
      align-items: center;
      gap: 0.35rem;
      padding: 0.35rem 0.75rem;
      border-radius: 999px;
      font-size: 0.8rem;
      font-weight: 500;
      background: rgba(255,255,255,0.15);
      border: 1px solid rgba(255,255,255,0.25);
    }
    .content {
      max-width: var(--content-max);
      margin: 0 auto;
      padding: 2rem 2.5rem 5rem;
    }
    section { margin-bottom: 2.75rem; scroll-margin-top: 1rem; }
    h2 {
      font-size: 1.35rem;
      font-weight: 700;
      margin: 0 0 1rem;
      letter-spacing: -0.02em;
      display: flex;
      align-items: center;
      gap: 0.6rem;
    }
    h2 .portal-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      flex-shrink: 0;
    }
    h3 {
      font-size: 1rem;
      font-weight: 600;
      color: var(--text-muted);
      margin: 1.5rem 0 0.75rem;
      padding-bottom: 0.4rem;
      border-bottom: 1px solid var(--border);
    }
    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow: hidden;
    }
    .card-pad { padding: 1.25rem 1.5rem; }
    .info-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 1rem;
    }
    .info-item {
      padding: 1rem 1.15rem;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
    }
    .info-item strong { display: block; font-size: 0.85rem; color: var(--text); margin-bottom: 0.35rem; }
    .info-item span { font-size: 0.9rem; color: var(--text-muted); }
    .legend { display: flex; flex-wrap: wrap; gap: 0.75rem; }
    .legend-item {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.5rem 0.85rem;
      border-radius: 8px;
      font-size: 0.85rem;
      font-weight: 500;
      border: 1px solid var(--border);
      background: var(--surface);
    }
    .pri {
      display: inline-block;
      padding: 0.15rem 0.5rem;
      border-radius: 4px;
      font-size: 0.72rem;
      font-weight: 700;
      letter-spacing: 0.03em;
      min-width: 2rem;
      text-align: center;
    }
    .pri-p0 { background: var(--p0-bg); color: var(--p0); border: 1px solid #fecaca; }
    .pri-p1 { background: var(--p1-bg); color: var(--p1); border: 1px solid #fde68a; }
    .pri-p2 { background: var(--p2-bg); color: var(--p2); border: 1px solid #cbd5e1; }
    .table-wrap { overflow-x: auto; }
    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.875rem;
    }
    thead th {
      text-align: left;
      padding: 0.7rem 1rem;
      background: #f8fafc;
      border-bottom: 2px solid var(--border-strong);
      font-weight: 600;
      font-size: 0.78rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--text-light);
      white-space: nowrap;
    }
    tbody td {
      padding: 0.75rem 1rem;
      border-bottom: 1px solid var(--border);
      vertical-align: top;
    }
    tbody tr:hover { background: #fafbfc; }
    tbody tr.done { opacity: 0.55; }
    tbody tr.done .id-code-primary { text-decoration: line-through; color: var(--text-light); }
    .test-id {
      font-family: ui-monospace, 'Cascadia Code', monospace;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--accent);
      white-space: normal;
      width: 1%;
      vertical-align: top;
    }
    .test-id .id-code {
      display: block;
      white-space: nowrap;
      line-height: 1.35;
    }
    .test-id .id-code-primary {
      font-weight: 700;
    }
    .test-id .id-code:not(.id-code-primary) {
      font-size: 0.72rem;
      font-weight: 500;
      color: var(--text-light);
      margin-top: 0.15rem;
    }
    .chk { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); }
    .note {
      padding: 1rem 1.15rem;
      border-radius: var(--radius);
      border-left: 4px solid var(--accent);
      background: var(--accent-light);
      font-size: 0.9rem;
      color: var(--text-muted);
      margin: 1rem 0;
    }
    .note.warn { border-left-color: var(--mobile); background: var(--mobile-bg); }
    .portal-section { border-left: 4px solid var(--border-strong); padding-left: 1.25rem; }
    .portal-section.agent { border-left-color: var(--agent); }
    .portal-section.ops { border-left-color: var(--ops); }
    .portal-section.web { border-left-color: var(--web); }
    .portal-section.mobile { border-left-color: var(--mobile); }
    .portal-section.cross { border-left-color: var(--cross); }
    .smoke-list { list-style: none; padding: 0; margin: 0; counter-reset: smoke; }
    .smoke-list li {
      counter-increment: smoke;
      display: flex;
      gap: 1rem;
      padding: 0.85rem 1rem;
      border-bottom: 1px solid var(--border);
      align-items: flex-start;
    }
    .smoke-list li::before {
      content: counter(smoke);
      flex-shrink: 0;
      width: 28px;
      height: 28px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: var(--accent);
      color: #fff;
      border-radius: 50%;
      font-size: 0.8rem;
      font-weight: 700;
    }
    .smoke-surface {
      font-weight: 600;
      font-size: 0.8rem;
      color: var(--text-light);
      min-width: 120px;
    }
    .quirks dt { font-weight: 600; color: var(--text); margin-top: 0.75rem; }
    .quirks dd { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.9rem; }
    .defect-list { margin: 0; padding-left: 1.25rem; }
    .defect-list li { margin-bottom: 0.5rem; color: var(--text-muted); }
    .progress-bar {
      position: fixed;
      bottom: 0;
      left: var(--nav-width);
      right: 0;
      background: var(--surface);
      border-top: 1px solid var(--border);
      padding: 0.6rem 2rem;
      display: flex;
      align-items: center;
      gap: 1rem;
      font-size: 0.85rem;
      z-index: 100;
    }
    .progress-track {
      flex: 1;
      height: 6px;
      background: var(--border);
      border-radius: 3px;
      overflow: hidden;
    }
    .progress-fill {
      height: 100%;
      background: var(--accent);
      border-radius: 3px;
      transition: width 0.3s;
      width: 0%;
    }
    .footer-note {
      text-align: center;
      font-size: 0.8rem;
      color: var(--text-light);
      padding: 1rem;
      border-top: 1px solid var(--border);
      margin-top: 2rem;
    }
    /* Detail popup */
    .th-detail, .info-cell { width: 44px; text-align: center; vertical-align: middle; }
    .btn-detail {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 32px;
      height: 32px;
      padding: 0;
      border: 1px solid var(--border);
      border-radius: 8px;
      background: var(--surface);
      color: var(--accent);
      cursor: pointer;
      transition: background 0.15s, border-color 0.15s, transform 0.1s;
    }
    .btn-detail:hover { background: var(--accent-light); border-color: var(--accent); }
    .btn-detail:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    .btn-detail svg { width: 18px; height: 18px; }
    .modal-overlay {
      position: fixed;
      inset: 0;
      z-index: 1000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 1.25rem;
      background: rgba(15, 23, 42, 0.45);
      backdrop-filter: blur(4px);
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.2s, visibility 0.2s;
    }
    .modal-overlay.open { opacity: 1; visibility: visible; }
    .modal-dialog {
      width: min(560px, 100%);
      max-height: min(85vh, 720px);
      overflow: hidden;
      display: flex;
      flex-direction: column;
      background: var(--surface);
      border-radius: 14px;
      border: 1px solid var(--border);
      box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
      transform: translateY(12px) scale(0.98);
      transition: transform 0.2s;
    }
    .modal-overlay.open .modal-dialog { transform: translateY(0) scale(1); }
    .modal-header {
      display: flex;
      align-items: center;
      gap: 0.6rem;
      padding: 1.1rem 1.25rem 0.5rem;
      flex-shrink: 0;
    }
    .modal-id {
      font-family: ui-monospace, monospace;
      font-size: 0.8rem;
      font-weight: 700;
      color: var(--accent);
      background: var(--accent-light);
      padding: 0.2rem 0.55rem;
      border-radius: 6px;
    }
    .modal-surface {
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--text-light);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .modal-close {
      margin-left: auto;
      width: 36px;
      height: 36px;
      border: none;
      border-radius: 8px;
      background: var(--bg);
      color: var(--text-muted);
      font-size: 1.4rem;
      line-height: 1;
      cursor: pointer;
    }
    .modal-close:hover { background: var(--border); color: var(--text); }
    .modal-title {
      margin: 0;
      padding: 0 1.25rem 0.75rem;
      font-size: 1.15rem;
      font-weight: 700;
      letter-spacing: -0.02em;
      border-bottom: 1px solid var(--border);
      flex-shrink: 0;
    }
    .modal-body {
      padding: 1rem 1.25rem 1.25rem;
      overflow-y: auto;
      font-size: 0.92rem;
      color: var(--text-muted);
    }
    .modal-body .detail-block { margin-bottom: 1rem; }
    .modal-body .detail-block:last-child { margin-bottom: 0; }
    .modal-body .detail-label {
      display: block;
      font-size: 0.72rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text);
      margin-bottom: 0.35rem;
    }
    .modal-body p { margin: 0 0 0.5rem; }
    .modal-body ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }
    .modal-body li { margin-bottom: 0.35rem; }
    .modal-body .detail-pass {
      background: var(--web-bg);
      border: 1px solid #a7f3d0;
      border-radius: 8px;
      padding: 0.75rem 0.9rem;
      color: #065f46;
    }
    .modal-body .detail-tip {
      background: var(--mobile-bg);
      border-left: 3px solid var(--mobile);
      padding: 0.65rem 0.85rem;
      border-radius: 0 8px 8px 0;
      font-size: 0.88rem;
    }
    .modal-body .detail-fail {
      background: var(--p0-bg);
      border-left: 3px solid var(--p0);
      padding: 0.65rem 0.85rem;
      border-radius: 0 8px 8px 0;
      font-size: 0.88rem;
    }
    @media (max-width: 960px) {
      .layout { grid-template-columns: 1fr; }
      .sidebar { position: relative; height: auto; max-height: none; }
      .progress-bar { left: 0; }
      .hero, .content { padding-left: 1.25rem; padding-right: 1.25rem; }
    }
    @media print {
      .sidebar, .progress-bar, .modal-overlay, .btn-detail { display: none; }
      .layout { display: block; }
      .hero { background: #0e5c6e; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    }

    /* Language switcher */
    .lang-switch {
      display: flex;
      gap: 0.35rem;
      padding: 0.75rem 1.25rem 0.25rem;
    }
    .lang-btn {
      flex: 1;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text-muted);
      border-radius: 8px;
      padding: 0.45rem 0.5rem;
      font-size: 0.8rem;
      font-weight: 600;
      cursor: pointer;
    }
    .lang-btn.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    /* RTL layout — dir=rtl places the first grid column (sidebar) on the right */
    html[dir="rtl"] body { font-family: 'IBM Plex Sans', 'Segoe UI', Tahoma, Arial, sans-serif; }
    html[dir="rtl"] .sidebar {
      border-right: none;
      border-left: 1px solid var(--border);
    }
    html[dir="rtl"] .nav-link {
      border-left: none;
      border-right: 3px solid transparent;
    }
    html[dir="rtl"] .nav-link.active { border-right-color: var(--accent); border-left-color: transparent; }
    html[dir="rtl"] .nav-link.agent:hover, html[dir="rtl"] .nav-link.agent.active { border-right-color: var(--agent); }
    html[dir="rtl"] .nav-link.ops:hover, html[dir="rtl"] .nav-link.ops.active { border-right-color: var(--ops); }
    html[dir="rtl"] .nav-link.web:hover, html[dir="rtl"] .nav-link.web.active { border-right-color: var(--web); }
    html[dir="rtl"] .nav-link.mobile:hover, html[dir="rtl"] .nav-link.mobile.active { border-right-color: var(--mobile); }
    html[dir="rtl"] .portal-section { border-left: none; border-right: 4px solid var(--border-strong); padding-left: 0; padding-right: 1.25rem; }
    html[dir="rtl"] .portal-section.agent { border-right-color: var(--agent); }
    html[dir="rtl"] .portal-section.ops { border-right-color: var(--ops); }
    html[dir="rtl"] .portal-section.web { border-right-color: var(--web); }
    html[dir="rtl"] .portal-section.mobile { border-right-color: var(--mobile); }
    html[dir="rtl"] .portal-section.cross { border-right-color: var(--cross); }
    html[dir="rtl"] .note { border-left: none; border-right: 4px solid var(--accent); }
    html[dir="rtl"] .note.warn { border-right-color: var(--mobile); }
    html[dir="rtl"] thead th, html[dir="rtl"] tbody td { text-align: right; }
    html[dir="rtl"] .progress-bar { left: 0; right: var(--nav-width); }
    html[dir="rtl"] .modal-close { margin-left: 0; margin-right: auto; }
    html[dir="rtl"] .modal-body .detail-tip,
    html[dir="rtl"] .modal-body .detail-fail {
      border-left: none;
      border-right: 3px solid var(--mobile);
      border-radius: 8px 0 0 8px;
    }
    html[dir="rtl"] .modal-body .detail-fail { border-right-color: var(--p0); }
    html[dir="rtl"] .modal-body ul { padding-left: 0; padding-right: 1.2rem; }
    html[dir="rtl"] .defect-list { padding-left: 0; padding-right: 1.25rem; }
    @media (max-width: 960px) {
      html[dir="rtl"] .sidebar { border-left: none; border-bottom: 1px solid var(--border); }
      html[dir="rtl"] .progress-bar { right: 0; }
    }
  
    .pri-p3 { background: var(--p3-bg, #f8fafc); color: var(--p3, #64748b); border: 1px solid #e2e8f0; }
    :root { --p3: #64748b; --p3-bg: #f8fafc; }
    .nav-link.cross:hover, .nav-link.cross.active { border-left-color: var(--cross); color: var(--cross); background: var(--cross-bg); }
    [dir="rtl"] { font-family: 'IBM Plex Sans Arabic', 'IBM Plex Sans', system-ui, sans-serif; }
    .modal-dialog { width: min(640px, 100%); max-height: min(85vh, 780px); }
    .modal-body code { font-size: 0.8em; background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 3px; }
    .scenario-cell { min-width: 320px; max-width: 640px; }
    .scenario-title { font-weight: 650; color: var(--text); font-size: 0.95rem; line-height: 1.35; }
    .scenario-meaning {
      margin-top: 0.4rem;
      font-size: 0.84rem;
      color: var(--text-muted);
      line-height: 1.45;
    }
    .scenario-wrong {
      margin-top: 0.45rem;
      padding: 0.45rem 0.6rem;
      border-radius: 6px;
      background: var(--p0-bg);
      border: 1px solid #fecaca;
      color: #7f1d1d;
      font-size: 0.84rem;
      line-height: 1.45;
    }
    .scenario-wrong strong { font-weight: 700; }
    .expected-cell {
      min-width: 200px;
      max-width: 320px;
      font-size: 0.84rem;
      color: #065f46;
      line-height: 1.45;
    }

    /* Tags */
    .tags-cell {
      white-space: normal;
      min-width: 7.5rem;
      max-width: 11rem;
    }
    .tag {
      display: inline-block;
      margin: 0.1rem 0.15rem 0.1rem 0;
      padding: 0.12rem 0.4rem;
      border-radius: 4px;
      font-size: 0.68rem;
      font-weight: 650;
      letter-spacing: 0.01em;
      border: 1px solid var(--border);
      background: #f8fafc;
      color: var(--text-muted);
      white-space: nowrap;
    }
    .tag-empty { color: var(--text-light); font-size: 0.8rem; }
    .tag-no-website { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
    .tag-text { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }
    .tag-calculations { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
    .tag-timer { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
    .tag-signalr { background: #f0f9ff; color: #0369a1; border-color: #bae6fd; }
    .tag-bidding { background: #fdf2f8; color: #9d174d; border-color: #fbcfe8; }
    .tag-wallet { background: #ecfdf5; color: #065f46; border-color: #6ee7b7; }
    .tag-auth { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
    .tag-dto { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
    .tag-onsite { background: #fffbeb; color: #b45309; border-color: #fde68a; }
    .tag-privacy { background: #fdf4ff; color: #86198f; border-color: #f5d0fe; }
    .tag-notifications { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
    .tag-hybrid-plus { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

    /* Interactive legend filters (Priority & tags section) */
    .filter-section .filter-meta {
      font-size: 0.85rem;
      font-weight: 500;
      color: var(--text-light);
      margin-left: 0.5rem;
    }
    button.legend-item.legend-filter {
      cursor: pointer;
      font: inherit;
      text-align: left;
      width: 100%;
      max-width: 420px;
      transition: box-shadow 0.15s, border-color 0.15s, background 0.15s;
    }
    button.legend-item.legend-filter:hover {
      border-color: var(--accent);
    }
    button.legend-item.legend-filter[aria-pressed="true"] {
      border-color: var(--accent);
      background: var(--accent-light);
      box-shadow: 0 0 0 2px rgba(14, 92, 110, 0.2);
    }
    button.legend-item.legend-filter[data-filter-mode="include"] {
      border-color: #047857;
      background: #ecfdf5;
      box-shadow: 0 0 0 2px rgba(4, 120, 87, 0.18);
    }
    button.legend-item.legend-filter[data-filter-mode="exclude"] {
      border-color: #b91c1c;
      background: #fef2f2;
      box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.15);
    }
    .filter-mode-badge {
      font-size: 0.65rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.03em;
      padding: 0.1rem 0.35rem;
      border-radius: 4px;
      white-space: nowrap;
    }
    .filter-mode-badge.mode-include {
      background: #047857;
      color: #fff;
    }
    .filter-mode-badge.mode-exclude {
      background: #b91c1c;
      color: #fff;
    }
    button.legend-item.legend-filter .filter-count {
      margin-left: auto;
      font-size: 0.75rem;
      font-weight: 600;
      color: var(--text-light);
      font-variant-numeric: tabular-nums;
    }
    .filter-clear {
      padding: 0.35rem 0.75rem;
      border-radius: 6px;
      border: 1px solid var(--border-strong);
      background: var(--surface);
      color: var(--text-muted);
      font-size: 0.8rem;
      cursor: pointer;
    }
    .filter-clear:hover { color: var(--text); border-color: var(--accent); }
    tr.filter-hidden { display: none; }
    section.section-filtered-out { display: none; }
