*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      font-family: 'Noto Sans', sans-serif;
      background: #f0f4f8;
      overflow: hidden;
      height: 100vh;
      display: flex;
      flex-direction: column;
    }
    body.auth-locked #app-shell {
      pointer-events: none;
      user-select: none;
      filter: blur(2px);
    }

    .hidden { display: none !important; }

    /* ── Auth gate ── */
    #auth-overlay {
      position: fixed;
      inset: 0;
      z-index: 200;
      display: flex;
      align-items: center;
      justify-content: center;
      background:
        radial-gradient(circle at 20% 20%, rgba(26, 58, 92, 0.2), transparent 38%),
        radial-gradient(circle at 80% 15%, rgba(139, 26, 45, 0.18), transparent 36%),
        rgba(7, 14, 28, 0.76);
      padding: 16px;
    }
    #auth-overlay.hidden { display: none; }

    .auth-card {
      width: min(440px, 100%);
      background: #fff;
      border-radius: 14px;
      box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
      padding: 24px 22px 20px;
      border: 1px solid #d6dde8;
    }
    .auth-card h2 {
      font-size: 24px;
      line-height: 1.2;
      color: #10243f;
      margin-bottom: 8px;
    }
    .auth-subtitle {
      font-size: 14px;
      color: #4d6178;
      line-height: 1.5;
      margin-bottom: 18px;
    }
    #auth-form {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .otp-group {
      display: flex;
      justify-content: center;
      gap: 10px;
    }
    .otp-digit {
      width: 56px;
      height: 56px;
      border: 1px solid #b8c5d7;
      border-radius: 12px;
      text-align: center;
      font-size: 30px;
      font-weight: 700;
      color: #12253f;
      background: #f8fbff;
      outline: none;
      transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
      caret-color: transparent;
    }
    .otp-digit:focus {
      border-color: #1d4d80;
      background: #ffffff;
      box-shadow: 0 0 0 4px rgba(41, 98, 255, 0.13);
    }
    .otp-digit.error {
      border-color: #b42318;
      box-shadow: 0 0 0 3px rgba(208, 43, 34, 0.12);
      background: #fff7f7;
    }
    .auth-error {
      min-height: 19px;
      text-align: center;
      color: #b42318;
      font-size: 13px;
      line-height: 1.4;
    }
    #auth-submit {
      height: 42px;
      border: none;
      border-radius: 10px;
      background: linear-gradient(90deg, #1f4d81 0%, #163a62 100%);
      color: #fff;
      font-size: 14px;
      font-weight: 700;
      cursor: pointer;
      transition: opacity 0.2s, transform 0.1s;
    }
    #auth-submit:hover { opacity: 0.94; }
    #auth-submit:active { transform: translateY(1px); }
    #auth-submit:disabled { opacity: 0.62; cursor: not-allowed; }

    @media (max-width: 520px) {
      .auth-card {
        padding: 20px 14px 16px;
      }
      .auth-card h2 {
        font-size: 21px;
      }
      .otp-group {
        gap: 8px;
      }
      .otp-digit {
        width: 48px;
        height: 52px;
        font-size: 27px;
      }
    }

    /* ── Top bar ── */
    #topbar {
      height: 60px;
      background: #1a3a5c;
      color: #fff;
      display: flex;
      align-items: center;
      padding: 0 24px;
      gap: 16px;
      flex-shrink: 0;
      box-shadow: 0 2px 8px rgba(0,0,0,0.25);
      z-index: 10;
    }
    #topbar h1 {
      font-size: 18px;
      font-weight: 700;
      letter-spacing: 0.3px;
      margin-right: auto;
    }
    #topbar select, #topbar button {
      font-family: inherit;
      font-size: 14px;
      padding: 6px 12px;
      border-radius: 4px;
      border: none;
      cursor: pointer;
    }
    #topbar select {
      background: rgba(255,255,255,0.15);
      color: #fff;
      min-width: 140px;
    }
    #topbar select option { background: #1a3a5c; color: #fff; }
    #btn-export {
      background: #8b1a2d;
      color: #fff;
      font-weight: 600;
      transition: background 0.2s;
    }
    #btn-export:hover { background: #a82038; }
    #btn-export:disabled { opacity: 0.6; cursor: not-allowed; }
    #btn-reset-view {
      background: rgba(255,255,255,0.16);
      color: #fff;
      font-weight: 600;
      transition: background 0.2s;
    }
    #btn-reset-view:hover { background: rgba(255,255,255,0.24); }

    /* ── Canvas ── */
    #canvas {
      flex: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: hidden;
      position: relative;
      padding: 12px;
    }
    #paper-frame {
      position: relative;
      width: min(96vw, calc((100vh - 96px) * 420 / 297));
      max-height: 96%;
      aspect-ratio: 420 / 297;
      background: #fff;
      border: 1px solid #666;
      box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
      overflow: hidden;
    }
    #chart-svg {
      width: 100%;
      height: 100%;
      display: block;
      background: #fff;
    }

    /* ── Loading ── */
    #loading {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(240,244,248,0.85);
      font-size: 16px;
      color: #555;
      z-index: 5;
    }
    #loading.hidden { display: none; }

    /* ── Error ── */
    #error-msg {
      position: absolute;
      inset: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 40px;
      color: #c0392b;
      font-size: 15px;
      text-align: center;
      z-index: 5;
    }
    #error-msg.hidden { display: none; }

    /* ── Node ── */
    .node-card .card-bg {
      fill: #fff;
      stroke-width: 2;
      rx: 8;
      filter: drop-shadow(0 1px 3px rgba(0,0,0,0.12));
      transition: filter 0.15s;
    }
    .node-card:hover .card-bg {
      filter: drop-shadow(0 3px 8px rgba(0,0,0,0.22));
    }
    .node-card .card-bg.tinh-uy { stroke: #1a3a5c; }
    .node-card .card-bg.ubnd    { stroke: #8b1a2d; }
    .node-card .card-bg.fake-root { stroke: #aaa; fill: #f5f5f5; }

    .node-card .avatar-init {
      font-size: 13px;
      font-weight: 700;
      fill: #fff;
      text-anchor: middle;
      dominant-baseline: central;
    }
    .node-card .avatar-bg-tinh { fill: #1a3a5c; }
    .node-card .avatar-bg-ubnd { fill: #8b1a2d; }

    .node-card .name-text { font-size: 12px; font-weight: 700; fill: #222; }
    .node-card .person-name { text-transform: uppercase; }
    .node-card .role-text { font-size: 10px; fill: #666; }
    .node-card .group-text { font-size: 9px; fill: #999; }
    .node-card .wiki-link { cursor: pointer; }
    .node-card .wiki-icon-bg {
      fill: rgba(255, 255, 255, 0.94);
      stroke: #cbd5e1;
      stroke-width: 1;
      transition: fill 0.15s, stroke 0.15s;
    }
    .node-card .wiki-icon-stroke {
      fill: none;
      stroke: #475569;
      stroke-width: 1.7;
      stroke-linecap: round;
      stroke-linejoin: round;
      transition: stroke 0.15s;
    }
    .node-card .wiki-link:hover .wiki-icon-bg {
      fill: #ffffff;
      stroke: #64748b;
    }
    .node-card .wiki-link:hover .wiki-icon-stroke {
      stroke: #0f172a;
    }
    .node-card .wiki-link:focus-visible .wiki-icon-bg {
      fill: #ffffff;
      stroke: #1d4ed8;
      stroke-width: 1.2;
    }
    .node-card .wiki-link:focus-visible .wiki-icon-stroke {
      stroke: #1d4ed8;
    }
    .node-card .card-bg.virtual-vp {
      fill: #f8fafc;
      stroke: #8b1a2d;
      stroke-dasharray: 6 3;
    }

    /* ── Link ── */
    .link { fill: none; stroke: #bbb; stroke-width: 3; }

    /* ── Print ── */
    @media print {
      @page { size: A3 landscape; margin: 10mm; }
      body { background: #fff; overflow: visible; height: auto; }
      #topbar, #loading, #error-msg { display: none !important; }
      #canvas { overflow: visible; height: auto; }
    }
