  :root {
    /* Apple-inspired palette */
    --bg: #f5f5f7;
    --bg-grad: radial-gradient(1200px 600px at 20% -10%, #eef2ff 0%, transparent 60%),
               radial-gradient(900px 500px at 100% 0%, #fdf4ff 0%, transparent 55%),
               #f5f5f7;
    --surface: rgba(255,255,255,0.72);
    --surface-solid: #ffffff;
    --ink: #1d1d1f;
    --ink-2: #424245;
    --muted: #6e6e73;
    --muted-2: #86868b;
    --line: rgba(0,0,0,0.08);
    --line-strong: rgba(0,0,0,0.14);

    /* Brand colors */
    --blue: #0071e3;
    --blue-2: #0077ed;
    --blue-tint: #e8f1ff;

    /* AI iridescent */
    --ai-1: #ff6b9d;
    --ai-2: #c084fc;
    --ai-3: #818cf8;
    --ai-4: #38bdf8;
    --ai-tint: linear-gradient(135deg, #fde7f3 0%, #efe4ff 50%, #e0eaff 100%);
    --ai-grad: linear-gradient(135deg, var(--ai-1) 0%, var(--ai-2) 35%, var(--ai-3) 70%, var(--ai-4) 100%);

    /* Status */
    --green: #34c759;
    --green-tint: #e8faec;
    --orange: #ff9f0a;
    --red: #ff3b30;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 16px 50px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.05);

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
  }

  * { box-sizing: border-box; -webkit-font-smoothing: antialiased; }
  html, body { margin: 0; padding: 0; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
                 "IBM Plex Sans Thai", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg-grad);
    background-attachment: fixed;
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    letter-spacing: -0.01em;
  }

  /* ===== Header (Mac toolbar style) ===== */
  header {
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    background: rgba(255,255,255,0.72);
    border-bottom: 1px solid var(--line);
    padding: 14px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    position: sticky; top: 0; z-index: 50;
  }
  .logo { display: flex; align-items: center; gap: 14px; }
  .logo-elsevier {
    height: 50px; width: auto;
    flex-shrink: 0;
  }
  .logo-divider {
    width: 1px; height: 38px;
    background: var(--line-strong);
  }
  .logo-title {
    font-size: 15px; font-weight: 600; color: var(--ink);
    letter-spacing: -0.01em;
    line-height: 1.3;
  }
  .logo-title .sep { color: var(--muted-2); font-weight: 400; margin: 0 6px; }
  .logo-sub {
    font-size: 12px; color: var(--muted); font-weight: 400;
    margin-top: 2px;
  }
  .pool-status {
    display: flex; gap: 18px; font-size: 12.5px; color: var(--muted);
    align-items: center;
  }
  .header-user {
    display: none; align-items: center; gap: 10px;
    padding-left: 14px; margin-left: 4px;
    border-left: 1px solid var(--line);
  }
  .header-user.show { display: inline-flex; }
  .header-user-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--blue); color: white;
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
    overflow: hidden;
    flex-shrink: 0;
  }
  .header-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .header-user-info { font-size: 12px; color: var(--ink-2); line-height: 1.2; max-width: 180px; }
  .header-user-info b { color: var(--ink); display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
  .header-user-info .email { font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; max-width: 180px; }
  .btn-logout {
    background: white;
    color: var(--ink-2);
    border: 1px solid var(--line);
    padding: 6px 11px;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
  }
  .btn-logout:hover { background: #f8f9fa; color: var(--red); border-color: #fecaca; }
  .pool-status b { color: var(--ink); font-weight: 600; }
  .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 7px; vertical-align: middle; }
  .dot.ai { background: var(--ai-grad); }
  .dot.ck { background: var(--blue); }

  main {
    flex: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 40px 28px 80px;
  }

  .view { display: none; }
  .view.active { display: block; animation: fadeUp .35s ease; }
  @keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

  .hero { margin-bottom: 32px; }
  .hero h1 {
    font-size: 32px; margin: 0 0 10px;
    font-weight: 600; letter-spacing: -0.025em;
    color: var(--ink);
    line-height: 1.25;
  }
  .hero-lead {
    color: var(--ink-2); margin: 0 0 20px; font-size: 15px;
    max-width: 760px; line-height: 1.6;
  }
  .hero-lead b { color: var(--ink); font-weight: 600; }

  /* In-app browser warning (LINE, Messenger, etc.) */
  .inapp-warn {
    display: none;
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    color: #7f1d1d;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.55;
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.06);
  }
  .inapp-warn.show { display: block; }
  .inapp-warn b { color: #991b1b; }
  .inapp-warn .icon-row {
    display: flex; align-items: center; gap: 10px;
    font-weight: 600; margin-bottom: 8px;
    font-size: 15px;
  }
  .inapp-warn .copy-url-row {
    display: flex; gap: 8px; margin-top: 12px;
    flex-wrap: wrap;
  }
  .inapp-warn .copy-url-row code {
    background: white;
    padding: 8px 12px; border-radius: 8px;
    font-size: 12px;
    flex: 1; min-width: 0;
    overflow-x: auto; white-space: nowrap;
    border: 1px solid #fca5a5;
  }
  .inapp-warn button {
    background: #dc2626; color: white;
    border: none; padding: 8px 14px;
    border-radius: 8px; font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer;
  }
  .inapp-warn button:hover { background: #b91c1c; }

  /* Info banner (iPad/Tablet tip) */
  .info-banner {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #fffbeb 0%, #fff8dc 100%);
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    color: #5c3a00;
    font-size: 13.5px;
    line-height: 1.55;
    max-width: 760px;
    margin-bottom: 28px;
    box-shadow: 0 1px 2px rgba(217, 119, 6, 0.04);
  }
  .info-banner .info-icon {
    flex-shrink: 0;
    width: 28px; height: 28px;
    border-radius: 8px;
    background: rgba(217, 119, 6, 0.12);
    display: grid; place-items: center;
    font-size: 16px;
  }
  .info-banner b { font-weight: 700; color: #78350f; }

  /* Section divider with title and legend */
  .section-head {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 22px;
  }
  .section-title {
    font-size: 18px; font-weight: 600; color: var(--ink);
    letter-spacing: -0.015em;
    display: inline-flex; align-items: center; gap: 10px;
    margin: 0;
  }
  .section-title::before {
    content: '';
    width: 4px; height: 18px;
    background: linear-gradient(180deg, var(--ai-2), var(--blue));
    border-radius: 999px;
  }

  .legend {
    display: inline-flex; gap: 16px; font-size: 12.5px; color: var(--ink-2);
    align-items: center;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    padding: 7px 14px;
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
  }
  .legend > span { display: inline-flex; align-items: center; }
  .legend .led {
    width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px;
  }
  .legend .led.ok { background: var(--green); box-shadow: 0 0 0 2px rgba(52,199,89,.15); }
  .legend .led.busy { background: var(--muted-2); }
  .legend .led.next-ai { background: var(--ai-grad); }
  .legend .led.next-ck { background: var(--blue); }
  @media (max-width: 600px) {
    .legend { font-size: 11.5px; gap: 10px; padding: 6px 11px; }
  }

  /* ===== Pool sections ===== */
  .pool-section {
    background: var(--surface);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
  }
  .pool-section.ai-section::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,107,157,.05) 0%, rgba(192,132,252,.06) 50%, rgba(56,189,248,.05) 100%);
    pointer-events: none;
  }
  .pool-section.ai-section {
    border-color: rgba(192,132,252,.25);
  }
  .pool-section.ck-section {
    border-color: rgba(0,113,227,.18);
  }
  .pool-section > * { position: relative; }

  .pool-head {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 14px;
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
  }
  .pool-meta { font-size: 13px; color: var(--muted); }
  .pool-meta b { color: var(--ink); font-weight: 600; }

  /* ===== ClinicalKey logo (Elsevier-style) ===== */
  .ck-logo {
    display: inline-flex; align-items: center; gap: 16px;
  }
  .ck-elsevier {
    display: inline-flex; align-items: center; justify-content: center;
    height: 64px; width: auto;
    flex-shrink: 0;
  }
  .ck-elsevier img { height: 100%; width: auto; display: block; }
  .ck-wordmark {
    font-family: -apple-system, "Helvetica Neue", "Segoe UI", Arial, sans-serif;
    font-size: 30px;
    font-weight: 400;
    color: #ee7d11; /* ClinicalKey orange */
    letter-spacing: -0.02em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 10px;
  }
  .ck-wordmark sup {
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
    margin-left: -2px;
    vertical-align: super;
  }
  .ck-ai-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 11px 6px;
    background: #e8f1ff;
    color: #0066cc;
    border-radius: 8px;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.02em;
    line-height: 1;
  }
  .ck-ai-badge .spark {
    font-size: 14px;
    background: linear-gradient(135deg, #0066cc, #818cf8, #c084fc);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  @media (max-width: 600px) {
    .ck-wordmark { font-size: 24px; }
    .ck-ai-badge { font-size: 13px; padding: 4px 9px 5px; }
    .ck-elsevier { width: 30px; height: 36px; }
  }

  /* ===== Pool footer (button moved to bottom) ===== */
  .pool-footer {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: center;
  }
  .btn-wide {
    min-width: 280px;
    padding: 14px 28px;
    font-size: 15px;
    border-radius: 14px;
  }

  /* ===== Buttons ===== */
  .btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-weight: 500; font-size: 14px;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: all .2s cubic-bezier(.4,0,.2,1);
    text-decoration: none;
    line-height: 1;
  }
  .btn:active { transform: scale(.97); }
  .btn.primary {
    background: var(--blue);
    color: white;
    box-shadow: 0 1px 3px rgba(0,113,227,.3), inset 0 1px 0 rgba(255,255,255,.15);
  }
  .btn.primary:hover { background: var(--blue-2); box-shadow: 0 4px 12px rgba(0,113,227,.35); }
  .btn.ai {
    background: var(--ai-grad);
    background-size: 200% 200%;
    color: white;
    box-shadow: 0 1px 3px rgba(192,132,252,.4), inset 0 1px 0 rgba(255,255,255,.2);
    animation: aiShift 6s ease infinite;
  }
  @keyframes aiShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
  }
  .btn.ai:hover { box-shadow: 0 6px 18px rgba(192,132,252,.45); }
  .btn.ghost {
    background: var(--surface-solid); color: var(--ink-2);
    border: 1px solid var(--line);
  }
  .btn.ghost:hover { background: #fafafa; }
  .btn:disabled { opacity: .4; cursor: not-allowed; }
  .btn:disabled:hover { box-shadow: none; }

  /* ===== Account grid (Mac card style) ===== */
  .acc-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
  }
  @media (max-width: 860px) { .acc-grid { grid-template-columns: repeat(2, 1fr); } }

  .acc {
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 14px;
    position: relative;
    transition: all .25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
  }
  .acc::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--muted-2);
    opacity: .25;
    transition: opacity .2s;
  }
  .acc.ai-acc::before { background: var(--ai-grad); opacity: 1; }
  .acc.ck-acc::before { background: var(--blue); opacity: 1; }
  .acc.occupied::before { opacity: .25; filter: grayscale(1); }

  .acc.available { box-shadow: var(--shadow-sm); }
  .acc.available:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
  .acc.occupied {
    background: #fafafa;
    border-color: var(--line);
  }
  .acc.pending {
    background: repeating-linear-gradient(
      45deg,
      #fafafa,
      #fafafa 6px,
      #f3f3f3 6px,
      #f3f3f3 12px
    );
    border: 1px dashed var(--line-strong);
    opacity: 0.85;
  }
  .acc.pending::before { background: repeating-linear-gradient(90deg, #d4d4d4, #d4d4d4 4px, transparent 4px, transparent 8px); opacity: 0.6; filter: none; }
  .acc.pending .acc-id .num {
    background: none;
    -webkit-text-fill-color: var(--muted-2);
    color: var(--muted-2);
  }
  .acc-status.pending {
    color: var(--muted-2);
    background: #f0f0f0;
  }
  .acc-status.pending .led {
    background: var(--orange);
    animation: pulse-pending 2s infinite;
  }
  @keyframes pulse-pending {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
  }
  .acc.suggested {
    box-shadow: 0 0 0 2px rgba(0,113,227,.4), var(--shadow-md);
    transform: translateY(-2px);
  }
  .acc.ai-acc.suggested {
    box-shadow: 0 0 0 2px rgba(192,132,252,.5), 0 8px 24px rgba(192,132,252,.18);
  }

  .acc-id {
    font-family: -apple-system, "SF Pro Display", system-ui, sans-serif;
    font-weight: 600; font-size: 13px; color: var(--ink);
    line-height: 1.3;
    letter-spacing: -0.01em;
    word-break: break-word;
    padding-top: 4px;
  }
  .acc-id .num {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 700;
    font-size: 14px;
  }
  .acc.ai-acc .acc-id .num {
    background: var(--ai-grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .acc.ck-acc .acc-id .num {
    color: var(--blue);
  }
  .acc.occupied .acc-id .num {
    background: none;
    -webkit-text-fill-color: var(--muted);
    color: var(--muted);
  }

  .acc-status {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 10px;
    font-size: 11.5px; font-weight: 500;
    padding: 3px 9px; border-radius: 999px;
  }
  .acc.available .acc-status {
    color: #1a7f37;
    background: var(--green-tint);
  }
  .acc.occupied .acc-status {
    color: var(--muted);
    background: #f0f0f0;
  }
  .acc-status .led {
    width: 6px; height: 6px; border-radius: 50%;
  }
  .acc.available .led { background: var(--green); animation: pulse 2.5s infinite; }
  .acc.occupied .led { background: var(--muted-2); }
  @keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(52,199,89,.5); }
    50% { box-shadow: 0 0 0 5px rgba(52,199,89,0); }
  }

  .acc-meta {
    margin-top: 12px;
    font-size: 11.5px; color: var(--muted);
    line-height: 1.5;
  }
  .acc-meta .row { display: flex; justify-content: space-between; gap: 6px; }
  .acc-meta .row + .row { margin-top: 2px; }
  .acc-meta b { color: var(--ink-2); font-weight: 600; }
  .acc-time {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600;
    color: var(--ink);
  }
  .badge-next {
    position: absolute;
    top: 10px; right: 10px;
    color: white;
    font-size: 9.5px; font-weight: 700;
    padding: 3px 8px; border-radius: 999px;
    letter-spacing: 0.06em;
  }
  .acc.ai-acc .badge-next { background: var(--ai-grad); box-shadow: 0 1px 3px rgba(192,132,252,.4); }
  .acc.ck-acc .badge-next { background: var(--blue); box-shadow: 0 1px 3px rgba(0,113,227,.3); }

  /* ===== Stepper ===== */
  .stepper {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 24px;
    color: var(--muted); font-size: 13px;
    flex-wrap: wrap;
  }
  .step { display: flex; align-items: center; gap: 7px; }
  .step .num {
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(0,0,0,.06); color: var(--muted);
    display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
  }
  .step.active .num { background: var(--blue); color: white; box-shadow: 0 1px 3px rgba(0,113,227,.3); }
  .step.active.ai-flow .num { background: var(--ai-grad); box-shadow: 0 1px 3px rgba(192,132,252,.4); }
  .step.done .num { background: var(--green); color: white; }
  .step .sep { width: 22px; height: 1px; background: var(--line-strong); }

  /* ===== Panel ===== */
  .panel {
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    max-width: 640px;
    margin: 0 auto;
  }
  .panel h2 {
    margin: 0 0 8px; font-size: 22px;
    font-weight: 600; letter-spacing: -0.02em;
  }
  .panel .sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }

  .question {
    background: #fafafa;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 14px;
  }
  .q-text {
    font-weight: 600; margin: 0 0 4px; font-size: 15px;
    color: var(--ink);
  }
  .q-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }
  .staff-input {
    width: 100%;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 18px; font-weight: 600;
    padding: 14px 16px;
    border: 1.5px solid var(--line-strong);
    border-radius: 12px;
    background: white;
    color: var(--ink);
    letter-spacing: 0.05em;
    transition: all .15s;
    box-sizing: border-box;
  }
  .staff-input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(0,113,227,.12);
  }
  .staff-input.ai-focus:focus {
    border-color: var(--ai-2);
    box-shadow: 0 0 0 4px rgba(192,132,252,.18);
  }
  .staff-welcome {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--blue-tint);
    border: 1px solid rgba(0,113,227,.15);
    border-radius: 10px;
    font-size: 13px;
    color: var(--ink-2);
    display: none;
  }
  .staff-welcome.show { display: block; }
  .staff-welcome b { color: var(--ink); }

  /* ===== Google Sign-In flow ===== */
  .signin-container {
    display: flex; flex-direction: column; align-items: center;
    gap: 16px; padding: 12px 0;
  }
  .signin-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4285f4, #34a853, #fbbc05, #ea4335);
    padding: 2px;
  }
  .signin-icon-inner {
    width: 100%; height: 100%; border-radius: 50%;
    background: white;
    display: grid; place-items: center;
    font-size: 24px;
  }
  .signin-text { text-align: center; color: var(--ink-2); font-size: 14px; }
  .signin-text b { color: var(--ink); }
  #googleBtnHost { min-height: 44px; display: flex; justify-content: center; }

  /* Google Sign-In button (Google brand-compliant) */
  .google-btn {
    display: inline-flex; align-items: center; gap: 12px;
    padding: 11px 22px;
    background: white;
    color: #1f1f1f;
    border: 1px solid #dadce0;
    border-radius: 4px;
    font-family: 'Roboto', -apple-system, sans-serif;
    font-size: 14px; font-weight: 500;
    letter-spacing: 0.25px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: background .15s, box-shadow .15s;
    min-width: 240px;
    justify-content: center;
  }
  .google-btn:hover {
    background: #f8f9fa;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  }
  .google-btn:active { background: #f1f3f4; }
  .signin-warn {
    background: #fffbeb; border: 1px solid #fde68a; color: #5c3a00;
    border-radius: 10px; padding: 12px 14px; font-size: 12.5px;
    text-align: left; line-height: 1.5;
  }
  .signin-warn code {
    background: rgba(0,0,0,.06); padding: 1px 5px;
    border-radius: 4px; font-size: 11.5px;
  }

  .user-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px;
    background: var(--blue-tint);
    border: 1px solid rgba(0,113,227,.15);
    border-radius: 12px;
  }
  .user-card.ai-tint {
    background: linear-gradient(135deg, #fde7f3, #efe4ff, #e0eaff);
    border-color: rgba(192,132,252,.25);
  }
  .user-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    display: grid; place-items: center;
    font-size: 18px; font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
  }
  .user-avatar img { width: 100%; height: 100%; object-fit: cover; }
  .user-info { flex: 1; min-width: 0; }
  .user-name { font-weight: 600; font-size: 14.5px; color: var(--ink); }
  .user-email { font-size: 12.5px; color: var(--muted); font-family: 'JetBrains Mono', ui-monospace, monospace; word-break: break-all; }
  .user-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
  .user-actions { display: flex; gap: 6px; flex-shrink: 0; }
  .switch-link {
    color: var(--blue); font-size: 12.5px;
    text-decoration: none; cursor: pointer;
    background: none; border: none; padding: 0; font-family: inherit;
  }
  .switch-link:hover { text-decoration: underline; }

  /* ===== Stats view ===== */
  .stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
  }
  @media (max-width: 600px) { .stats-summary { grid-template-columns: 1fr; } }
  .stat-tile {
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px 18px;
  }
  .stat-tile .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
  .stat-tile .value {
    font-size: 28px; font-weight: 700; color: var(--ink);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    letter-spacing: -0.02em; margin-top: 4px;
  }
  .stats-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-solid);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--line);
    font-size: 13px;
  }
  .stats-table th, .stats-table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
  }
  .stats-table th {
    background: #fafafa;
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .stats-table tr:last-child td { border-bottom: none; }
  .stats-table td.mono {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600;
  }
  .stats-table .pkg-tag {
    display: inline-block;
    font-size: 10.5px; padding: 2px 8px; border-radius: 999px; font-weight: 600;
  }
  .stats-table .pkg-tag.ai { background: linear-gradient(135deg, #f3e8ff, #e0eaff); color: var(--ai-2); }
  .stats-table .pkg-tag.ck { background: var(--blue-tint); color: var(--blue); }
  .stats-empty {
    padding: 32px; text-align: center; color: var(--muted);
    background: #fafafa; border-radius: var(--radius-md);
  }
  .stats-controls {
    display: flex; gap: 10px; align-items: center; margin-bottom: 16px;
    flex-wrap: wrap;
  }
  .stats-search {
    flex: 1; min-width: 200px;
    padding: 9px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    font-family: inherit; font-size: 13px;
    background: white;
  }
  .stats-search:focus { outline: none; border-color: var(--blue); }
  .stats-link {
    color: var(--blue); text-decoration: none;
    font-size: 12px; cursor: pointer;
  }
  .stats-link:hover { text-decoration: underline; }

  .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
  .alert { padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; font-weight: 500; }
  .alert.err { background: #ffebee; color: #b71c1c; border: 1px solid #ffcdd2; }
  .alert.ok  { background: var(--green-tint); color: #0a5d27; border: 1px solid #b8e6c1; }

  /* ===== Credential card ===== */
  .cred-card {
    background: linear-gradient(160deg, #1d1d1f 0%, #000000 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 18px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
  }
  .cred-card.ai-cred::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: var(--ai-grad);
  }
  .cred-card.ck-cred::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: var(--blue);
  }
  .cred-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,.08);
    gap: 12px;
  }
  .cred-row:last-child { border-bottom: none; }
  .cred-label { font-size: 11px; color: #86868b; letter-spacing: 0.02em; text-transform: uppercase; }
  .cred-value {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 14px; letter-spacing: 0;
    margin-top: 3px;
    word-break: break-all;
  }
  .copy-btn {
    background: rgba(255,255,255,.08);
    color: white;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    padding: 5px 12px; font-size: 11.5px;
    cursor: pointer; font-family: inherit;
    transition: background .15s;
  }
  .copy-btn:hover { background: rgba(255,255,255,.16); }

  /* ===== Timer ===== */
  .timer {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-top: 18px;
  }
  .timer-num {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 30px; font-weight: 700; color: var(--ink);
    letter-spacing: -0.01em;
  }
  .timer-num.warn { color: var(--orange); }
  .timer-num.crit { color: var(--red); }
  .timer-label { color: var(--muted); font-size: 12px; margin-bottom: 2px; }

  .progress {
    height: 6px; background: rgba(0,0,0,.05);
    border-radius: 999px; margin-top: 14px; overflow: hidden;
  }
  .progress > span { display: block; height: 100%; background: var(--green); transition: width 1s linear, background .3s; border-radius: 999px; }

  .reminders {
    background: #fff8e6; border: 1px solid #ffe49a; color: #5c3a00;
    border-radius: var(--radius-md); padding: 14px 16px; font-size: 13px; margin-top: 18px;
    line-height: 1.5;
  }
  .reminders ul { margin: 6px 0 0; padding-left: 20px; }
  .reminders li + li { margin-top: 4px; }

  .queue-card { text-align: center; padding: 44px 28px; }
  .queue-num {
    font-size: 56px; font-weight: 700; color: var(--blue);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    letter-spacing: -0.03em;
    margin: 8px 0;
  }

  /* ===== Config (admin) view ===== */
  .config-section { margin-bottom: 22px; }
  .config-section h3 {
    margin: 0 0 12px; font-size: 16px; font-weight: 600;
    color: var(--ink);
    display: inline-flex; align-items: center; gap: 8px;
  }
  .config-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: 13px;
  }
  .config-table th {
    background: #fafafa;
    font-weight: 600; font-size: 11.5px;
    color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.04em;
    text-align: left;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
  }
  .config-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
  }
  .config-table tr:last-child td { border-bottom: none; }
  .config-table .acc-id-cell {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-weight: 600;
    white-space: nowrap;
  }
  .config-table .acc-id-cell.ai { color: var(--ai-2); }
  .config-table .acc-id-cell.ck { color: var(--blue); }
  .config-table input[type="text"], .config-table input[type="password"] {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-family: inherit; font-size: 13px;
    background: white;
    box-sizing: border-box;
  }
  .config-table input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0,113,227,.12);
  }
  .config-table input.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }
  .pwd-cell { display: flex; align-items: center; gap: 6px; }
  .pwd-cell input { flex: 1; }
  .pwd-toggle {
    background: white; border: 1px solid var(--line); border-radius: 6px;
    padding: 6px 10px; font-size: 11px; cursor: pointer; color: var(--ink-2);
    flex-shrink: 0;
  }
  .pwd-toggle:hover { background: #f8f9fa; }
  .status-pill {
    display: inline-block;
    padding: 2px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
  }
  .status-pill.available { background: var(--green-tint); color: #1a7f37; }
  .status-pill.pending { background: #fef3c7; color: #92400e; }
  .status-pill.occupied { background: #f0f0f0; color: var(--muted); }
  .config-actions {
    margin-top: 18px;
    display: flex; gap: 10px; justify-content: space-between;
    flex-wrap: wrap;
  }
  .config-warn {
    background: #fffbeb; border: 1px solid #fde68a; color: #5c3a00;
    border-radius: var(--radius-md); padding: 12px 14px; font-size: 13px;
    margin-bottom: 18px;
    line-height: 1.55;
  }
  .config-warn b { color: #78350f; }

  footer {
    text-align: center; color: var(--muted-2); font-size: 11.5px;
    padding: 32px 24px;
  }
  .footer-elsevier {
    display: flex; align-items: center; justify-content: center;
    gap: 16px;
    padding: 24px 0 12px;
  }
  .footer-elsevier img { height: 70px; width: auto; opacity: 0.85; }
  .footer-line {
    width: 1px; height: 50px;
    background: var(--line-strong);
  }
  .footer-text {
    text-align: left;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
  }
  .footer-text b { color: var(--ink-2); font-weight: 600; }
  .footer-meta {
    margin-top: 12px;
    color: var(--muted-2); font-size: 11.5px;
  }

  /* ===== Send progress (สถานะการจัดส่งอีเมล) ===== */
  .send-progress {
    margin-top: 18px;
    padding: 16px 18px;
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    animation: fadeUp .3s cubic-bezier(.4,0,.2,1);
  }
  .send-progress[hidden] { display: none; }
  .send-progress .sp-head { display: flex; gap: 12px; align-items: flex-start; }
  .send-progress .sp-text { flex: 1; min-width: 0; }
  .send-progress .sp-title {
    font-size: 15px; font-weight: 600; color: var(--ink);
    letter-spacing: -0.01em;
  }
  .send-progress .sp-step {
    margin-top: 3px; font-size: 13px; color: var(--muted); line-height: 1.55;
  }
  .send-progress .progress { margin-top: 14px; }

  .send-progress .sp-icon {
    flex-shrink: 0;
    width: 20px; height: 20px; margin-top: 2px;
    border-radius: 999px;
    border: 2px solid var(--blue-tint);
    border-top-color: var(--blue);
    animation: spSpin .8s linear infinite;
  }
  @keyframes spSpin { to { transform: rotate(360deg); } }

  .send-progress.is-done .sp-icon {
    border: none; animation: none;
    background: var(--green);
    box-shadow: 0 0 0 4px var(--green-tint);
    position: relative;
  }
  .send-progress.is-done .sp-icon::after {
    content: '✓';
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 12px; font-weight: 700;
  }
  .send-progress.is-done .progress span { background: var(--green); }

  .send-progress.is-error .sp-icon {
    border: none; animation: none;
    background: var(--red);
    box-shadow: 0 0 0 4px rgba(255,59,48,.12);
    position: relative;
  }
  .send-progress.is-error .sp-icon::after {
    content: '!';
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 12px; font-weight: 700;
  }
  .send-progress.is-error .progress span { background: var(--red); }
  .send-progress.is-error .sp-step { color: var(--red); }

  .sp-hints {
    margin: 12px 0 0; padding-left: 18px;
    font-size: 12.5px; color: var(--muted); line-height: 1.75;
  }
  .sp-hints[hidden] { display: none; }
  .sp-hints b { color: var(--ink-2); font-weight: 600; }

  @media (prefers-reduced-motion: reduce) {
    .send-progress .sp-icon { animation: none; }
    .send-progress { animation: none; }
  }
