/* IT Service Desk v2 — shared theme/components, extracted from Password_Vault_Template.html */
/* ดูรายละเอียดการใช้งานใน docs/DESIGN_SYSTEM.md */

    /* -------------------------------------------------------------
       THEME SYSTEM: LIGHT MODE (Default - IG Inspired) & DARK MODE
       ------------------------------------------------------------- */
    :root, [data-theme="light"] {
      --bg-primary: #f8fafc;
      --bg-surface: #ffffff;
      --bg-card: #ffffff;
      --bg-card-hover: #fbfcfe;
      --bg-subtle: #f1f5f9;
      --border: #e2e8f0;
      --border-subtle: #edf2f7;
      --border-focus: #cbd5e1;
      
      --text-main: #0f172a;
      --text-body: #334155;
      --text-muted: #64748b;
      --text-dim: #94a3b8;

      --brand-gradient: linear-gradient(135deg, #10b981 0%, #059669 40%, #0284c7 75%, #4f46e5 100%);
      --brand-gradient-soft: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(79, 70, 229, 0.08) 100%);

      /* Stat Card Semantic Variants */
      --c-emerald: #059669;
      --c-emerald-bg: #ecfdf5;
      --c-emerald-border: #a7f3d0;

      --c-blue: #2563eb;
      --c-blue-bg: #eff6ff;
      --c-blue-border: #bfdbfe;

      --c-purple: #7c3aed;
      --c-purple-bg: #f5f3ff;
      --c-purple-border: #ddd6fe;

      --c-amber: #d97706;
      --c-amber-bg: #fffbeb;
      --c-amber-border: #fde68a;

      --c-rose: #e11d48;
      --c-rose-bg: #fff1f2;
      --c-rose-border: #fecdd3;

      --c-teal: #0891b2;
      --c-teal-bg: #ecfeff;
      --c-teal-border: #a5f3fc;

      --c-indigo: #4f46e5;
      --c-indigo-bg: #eef2ff;
      --c-indigo-border: #c7d2fe;

      --c-yellow: #ca8a04;
      --c-yellow-bg: #fefce8;
      --c-yellow-border: #fde047;

      /* Radii & Shadows */
      --radius-sm: 8px;
      --radius-md: 14px;
      --radius-lg: 20px;
      --radius-pill: 9999px;

      --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
      --shadow-card: 0 2px 6px -1px rgba(15, 23, 42, 0.04), 0 6px 16px -2px rgba(15, 23, 42, 0.03);
      --shadow-hover: 0 10px 24px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -2px rgba(15, 23, 42, 0.04);
      --shadow-floating: 0 20px 45px -8px rgba(15, 23, 42, 0.16), 0 4px 12px rgba(15, 23, 42, 0.06);

      --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    [data-theme="dark"] {
      --bg-primary: #0b0f17;
      --bg-surface: #111827;
      --bg-card: #141b2a;
      --bg-card-hover: #192235;
      --bg-subtle: #1a2234;
      --border: #1e293b;
      --border-subtle: #172033;
      --border-focus: #334155;
      
      --text-main: #f8fafc;
      --text-body: #cbd5e1;
      --text-muted: #94a3b8;
      --text-dim: #64748b;

      --brand-gradient: linear-gradient(135deg, #10b981 0%, #059669 40%, #0ea5e9 75%, #6366f1 100%);
      --brand-gradient-soft: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(99, 102, 241, 0.15) 100%);

      --c-emerald: #10b981;
      --c-emerald-bg: rgba(16, 185, 129, 0.12);
      --c-emerald-border: rgba(16, 185, 129, 0.28);

      --c-blue: #38bdf8;
      --c-blue-bg: rgba(56, 189, 248, 0.12);
      --c-blue-border: rgba(56, 189, 248, 0.28);

      --c-purple: #a855f7;
      --c-purple-bg: rgba(168, 85, 247, 0.12);
      --c-purple-border: rgba(168, 85, 247, 0.28);

      --c-amber: #fbbf24;
      --c-amber-bg: rgba(251, 191, 36, 0.12);
      --c-amber-border: rgba(251, 191, 36, 0.28);

      --c-rose: #fb7185;
      --c-rose-bg: rgba(251, 113, 133, 0.12);
      --c-rose-border: rgba(251, 113, 133, 0.28);

      --c-teal: #2dd4bf;
      --c-teal-bg: rgba(45, 212, 191, 0.12);
      --c-teal-border: rgba(45, 212, 191, 0.28);

      --c-indigo: #818cf8;
      --c-indigo-bg: rgba(129, 140, 248, 0.12);
      --c-indigo-border: rgba(129, 140, 248, 0.28);

      --c-yellow: #facc15;
      --c-yellow-bg: rgba(250, 204, 21, 0.10);
      --c-yellow-border: rgba(250, 204, 21, 0.30);

      --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
      --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.4);
      --shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.5);
      --shadow-floating: 0 20px 45px rgba(0, 0, 0, 0.6);
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
      -webkit-font-smoothing: antialiased;
    }

    body {
      font-family: "Prompt", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background-color: var(--bg-primary);
      background-image: 
        radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.04) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.04) 0px, transparent 50%);
      color: var(--text-body);
      line-height: 1.6;
      min-height: 100vh;
      padding-bottom: 100px;
      overflow-x: hidden;
      transition: background-color 0.25s ease, color 0.25s ease;
    }

    ::-webkit-scrollbar {
      display: none;
      width: 0;
      height: 0;
    }
    * {
      scrollbar-width: none;
      -ms-overflow-style: none;
    }

    .container {
      max-width: 1240px;
      margin: 0 auto;
      padding: 0 24px;
    }

    /* -------------------------------------------------------------
       HEADER
       ------------------------------------------------------------- */
    header {
      text-align: center;
      position: relative;
    }

    .header-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: var(--brand-gradient-soft);
      border: 1px solid rgba(16, 185, 129, 0.25);
      padding: 6px 16px;
      border-radius: var(--radius-pill);
      font-size: 0.84rem;
      color: #059669;
      font-weight: 500;
      margin-bottom: 14px;
    }
    [data-theme="dark"] .header-badge {
      color: #10b981;
    }

    .brand-title {
      font-size: 2.3rem;
      font-weight: 700;
      letter-spacing: -0.6px;
      color: var(--text-main);
      margin-bottom: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 12px;
      flex-wrap: wrap;
    }

    .brand-gradient-text {
      background: var(--brand-gradient);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
    }

    .brand-subtitle {
      color: var(--text-muted);
      font-size: 1.02rem;
      max-width: 680px;
      margin: 0 auto 18px;
      font-weight: 400;
    }

    .header-tags {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 10px;
      flex-wrap: wrap;
      margin-top: 6px;
    }

    /* Modern Gradient Action Pills */
    .header-action-pill {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 9px 18px;
      border-radius: var(--radius-pill);
      font-size: 0.88rem;
      font-weight: 600;
      color: #ffffff;
      border: none;
      cursor: pointer;
      text-decoration: none;
      user-select: none;
      line-height: 1.2;
      transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .header-action-pill:hover {
      transform: translateY(-2px);
      filter: brightness(1.05);
    }
    .header-action-pill:active {
      transform: translateY(0);
      filter: brightness(0.98);
    }

    /* 1. เพิ่มรายการ (Emerald Gradient) */
    .btn-pill-emerald {
      background: linear-gradient(135deg, #10b981 0%, #059669 100%);
      box-shadow: 0 4px 14px rgba(16, 185, 129, 0.32);
    }
    .btn-pill-emerald:hover {
      box-shadow: 0 6px 20px rgba(16, 185, 129, 0.46);
    }

    /* 2. สุ่มรหัสผ่าน (Amber / Gold Gradient) */
    .btn-pill-amber {
      background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
      box-shadow: 0 4px 14px rgba(245, 158, 11, 0.32);
    }
    .btn-pill-amber:hover {
      box-shadow: 0 6px 20px rgba(245, 158, 11, 0.46);
    }

    /* 3. Export Excel (Blue Gradient) */
    .btn-pill-blue {
      background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
      box-shadow: 0 4px 14px rgba(59, 130, 246, 0.32);
    }
    .btn-pill-blue:hover {
      box-shadow: 0 6px 20px rgba(59, 130, 246, 0.46);
    }

    /* Template เปล่า (Teal Gradient) */
    .btn-pill-teal {
      background: linear-gradient(135deg, #14b8a6 0%, #0d9488 100%);
      box-shadow: 0 4px 14px rgba(20, 184, 166, 0.32);
    }
    .btn-pill-teal:hover {
      box-shadow: 0 6px 20px rgba(20, 184, 166, 0.46);
    }

    /* ซิงค์ (Indigo Gradient) */
    .btn-pill-indigo {
      background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
      box-shadow: 0 4px 14px rgba(99, 102, 241, 0.32);
    }
    .btn-pill-indigo:hover {
      box-shadow: 0 6px 20px rgba(99, 102, 241, 0.46);
    }

    /* SYNC MODAL */
    .sync-step-card {
      background: var(--bg-primary);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 14px 16px;
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
    .sync-step-title {
      font-weight: 700;
      font-size: 0.92rem;
      color: var(--text-main);
    }
    .sync-step-desc {
      font-size: 0.8rem;
      color: var(--text-muted);
      line-height: 1.55;
    }
    .sync-summary {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 8px;
    }
    .sync-chip {
      border-radius: var(--radius-md);
      border: 1px solid var(--border);
      background: var(--bg-subtle);
      padding: 10px 8px;
      text-align: center;
      font-size: 0.74rem;
      color: var(--text-muted);
      font-weight: 600;
    }
    .sync-chip strong { display: block; font-size: 1.35rem; line-height: 1.2; color: var(--text-main); }
    .sync-chip.added { background: var(--c-emerald-bg); border-color: var(--c-emerald-border); }
    .sync-chip.added strong { color: var(--c-emerald); }
    .sync-chip.changed { background: var(--c-blue-bg); border-color: var(--c-blue-border); }
    .sync-chip.changed strong { color: var(--c-blue); }
    .sync-chip.missing { background: var(--c-rose-bg); border-color: var(--c-rose-border); }
    .sync-chip.missing strong { color: var(--c-rose); }
    .sync-section-head {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      gap: 8px;
      margin: 16px 0 6px;
      font-weight: 700;
      font-size: 0.86rem;
      color: var(--text-main);
    }
    .sync-section-head button {
      background: none;
      border: none;
      color: var(--c-blue);
      font-size: 0.76rem;
      cursor: pointer;
      text-decoration: underline;
      font-family: inherit;
    }
    .sync-section-note {
      font-size: 0.76rem;
      color: var(--text-muted);
      margin-bottom: 6px;
    }
    .sync-list {
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      max-height: 230px;
      overflow-y: auto;
      background: var(--bg-surface);
    }
    .sync-row {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 12px;
      border-bottom: 1px solid var(--border-subtle);
      font-size: 0.84rem;
    }
    .sync-row:last-child { border-bottom: none; }
    .sync-row-main { flex: 1; min-width: 0; }
    .sync-row-title {
      font-weight: 600;
      color: var(--text-main);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .sync-row-sub {
      font-size: 0.74rem;
      color: var(--text-muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .sync-row select {
      font-family: inherit;
      font-size: 0.78rem;
      padding: 5px 8px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--bg-surface);
      color: var(--text-main);
      flex-shrink: 0;
      max-width: 48%;
    }
    @media (max-width: 768px) {
      .sync-summary { grid-template-columns: repeat(2, 1fr); }
    }

    /* 4. LOG (Purple Gradient) */
    .btn-pill-purple {
      background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
      box-shadow: 0 4px 14px rgba(139, 92, 246, 0.32);
    }
    .btn-pill-purple:hover {
      box-shadow: 0 6px 20px rgba(139, 92, 246, 0.46);
    }

    /* 5. โหมดมืด / สว่าง (Slate / Midnight in Light, Amber Sun in Dark) */
    .btn-pill-theme {
      background: linear-gradient(135deg, #475569 0%, #334155 100%);
      box-shadow: 0 4px 14px rgba(51, 65, 85, 0.28);
    }
    .btn-pill-theme:hover {
      box-shadow: 0 6px 20px rgba(51, 65, 85, 0.42);
    }
    [data-theme="dark"] .btn-pill-theme {
      background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
      box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
    }
    [data-theme="dark"] .btn-pill-theme:hover {
      box-shadow: 0 6px 20px rgba(245, 158, 11, 0.48);
    }

    /* 6. ล็อกคลัง (Rose / Ruby Red Gradient) */
    .btn-pill-rose {
      background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
      box-shadow: 0 4px 14px rgba(225, 29, 72, 0.32);
    }
    .btn-pill-rose:hover {
      box-shadow: 0 6px 20px rgba(225, 29, 72, 0.46);
    }

    .app-header-box {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: 28px;
      padding: 34px 28px 28px;
      margin: 28px auto 24px;
      box-shadow: var(--shadow-card);
      text-align: center;
      position: relative;
      transition: var(--transition);
    }
    [data-theme="dark"] .app-header-box {
      box-shadow: 0 10px 36px -8px rgba(0, 0, 0, 0.5);
      border-color: rgba(255, 255, 255, 0.08);
    }

    /* -------------------------------------------------------------
       METRIC COLOR BOXES (Stat Cards Grid - Enlarged & Punchy)
       ------------------------------------------------------------- */
    .stats-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
      gap: 16px;
      margin-bottom: 24px;
    }

    .stat-card {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 22px 22px;
      min-height: 114px;
      position: relative;
      transition: var(--transition);
      cursor: pointer;
      box-shadow: var(--shadow-card);
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }

    .stat-card:hover {
      border-color: var(--border-focus);
      transform: translateY(-2px);
      box-shadow: var(--shadow-hover);
    }

    .stat-card.active-stat {
      border-color: #10b981;
      background: var(--c-emerald-bg);
      box-shadow: 0 0 0 2px #10b981, var(--shadow-card);
    }

    .stat-top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;
      gap: 8px;
      min-height: 38px;
    }

    .stat-label {
      font-size: 0.86rem;
      font-weight: 600;
      color: var(--text-muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      flex: 1;
      min-width: 0;
    }

    .stat-badge-icon {
      width: 36px;
      height: 36px;
      border-radius: var(--radius-md);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.15rem;
      flex-shrink: 0;
    }

    .stat-value {
      font-size: 2.3rem;
      font-weight: 700;
      line-height: 1.1;
      letter-spacing: -0.5px;
      color: var(--text-main);
    }

    .stat-card.emerald .stat-value { color: var(--c-emerald); }
    .stat-card.emerald .stat-badge-icon { background: var(--c-emerald-bg); color: var(--c-emerald); }

    .stat-card.blue .stat-value { color: var(--c-blue); }
    .stat-card.blue .stat-badge-icon { background: var(--c-blue-bg); color: var(--c-blue); }

    .stat-card.purple .stat-value { color: var(--c-purple); }
    .stat-card.purple .stat-badge-icon { background: var(--c-purple-bg); color: var(--c-purple); }

    .stat-card.amber .stat-value { color: var(--c-amber); }
    .stat-card.amber .stat-badge-icon { background: var(--c-amber-bg); color: var(--c-amber); }

    .stat-card.rose .stat-value { color: var(--c-rose); }
    .stat-card.rose .stat-badge-icon { background: var(--c-rose-bg); color: var(--c-rose); }

    .stat-card.teal .stat-value { color: var(--c-teal); }
    .stat-card.teal .stat-badge-icon { background: var(--c-teal-bg); color: var(--c-teal); }

    .stat-card.indigo .stat-value { color: var(--c-indigo); }
    .stat-card.indigo .stat-badge-icon { background: var(--c-indigo-bg); color: var(--c-indigo); }
    .stat-card.indigo.active-stat {
      border-color: var(--c-indigo);
      background: var(--c-indigo-bg);
      box-shadow: 0 0 0 2px var(--c-indigo), var(--shadow-card);
    }

    .stat-card.yellow .stat-value { color: var(--c-yellow); }
    .stat-card.yellow .stat-badge-icon { background: var(--c-yellow-bg); color: var(--c-yellow); }
    .stat-card.yellow.active-stat {
      border-color: var(--c-yellow);
      background: var(--c-yellow-bg);
      box-shadow: 0 0 0 2px var(--c-yellow), var(--shadow-card);
    }

    /* IP / Server host pill */
    .server-host-pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      max-width: 100%;
      padding: 3px 10px;
      border-radius: var(--radius-pill);
      background: var(--c-indigo-bg);
      color: var(--c-indigo);
      border: 1px solid var(--c-indigo-border);
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      transition: var(--transition);
    }
    .server-host-pill:hover { filter: brightness(0.97); transform: translateY(-1px); }
    .server-proto-chip {
      display: inline-flex;
      align-items: center;
      padding: 2px 8px;
      border-radius: var(--radius-pill);
      background: var(--bg-subtle);
      color: var(--text-muted);
      border: 1px solid var(--border);
      font-size: 0.7rem;
      font-weight: 600;
      white-space: nowrap;
    }
    .server-fields-box {
      background: var(--c-indigo-bg);
      border: 1px solid var(--c-indigo-border);
      border-radius: var(--radius-sm);
      padding: 12px;
      display: none;
      flex-direction: column;
      gap: 10px;
    }
    .server-fields-row {
      display: grid;
      grid-template-columns: 1fr 110px;
      gap: 8px;
    }

    /* NOTES (สมุดโน้ต) */
    .notes-toolbar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap;
      margin-bottom: 16px;
    }
    .notes-toolbar-title {
      font-size: 1.05rem;
      font-weight: 700;
      color: var(--text-main);
    }
    .notes-toolbar-sub {
      font-size: 0.8rem;
      color: var(--text-muted);
    }
    .notes-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
      gap: 16px;
    }
    .note-card {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-top: 4px solid var(--c-yellow);
      border-radius: var(--radius-lg);
      padding: 16px 18px;
      min-height: 170px;
      box-shadow: var(--shadow-card);
      cursor: pointer;
      display: flex;
      flex-direction: column;
      gap: 8px;
      transition: var(--transition);
    }
    .note-card:hover {
      transform: translateY(-2px);
      box-shadow: var(--shadow-hover);
      border-color: var(--border-focus);
      border-top-color: var(--c-yellow);
    }
    .note-card.is-pinned { border-top-color: var(--c-emerald); }
    .note-card-title {
      font-weight: 700;
      color: var(--text-main);
      font-size: 0.98rem;
      word-break: break-word;
    }
    .note-card-body {
      font-size: 0.86rem;
      color: var(--text-body);
      white-space: pre-wrap;
      word-break: break-word;
      display: -webkit-box;
      -webkit-line-clamp: 8;
      line-clamp: 8;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
    .note-card-footer {
      margin-top: auto;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 8px;
      font-size: 0.74rem;
      color: var(--text-dim);
    }
    .note-textarea {
      min-height: 220px;
      resize: vertical;
      line-height: 1.6;
    }

    .stat-desc {
      display: none;
    }

    /* -------------------------------------------------------------
       CONTROLS PANEL (Tabs, View Switcher: Grid/List, Search)
       ------------------------------------------------------------- */
    .controls-panel {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 18px 22px;
      margin-bottom: 24px;
      box-shadow: var(--shadow-card);
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .tabs-row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }

    .tab-btn {
      background: var(--bg-subtle);
      border: 1px solid transparent;
      color: var(--text-muted);
      padding: 8px 16px;
      border-radius: var(--radius-pill);
      font-size: 0.88rem;
      font-weight: 500;
      cursor: pointer;
      transition: var(--transition);
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    .tab-btn:hover {
      background: var(--border-subtle);
      color: var(--text-main);
    }

    .tab-btn.active {
      background: var(--brand-gradient);
      color: #ffffff;
      font-weight: 600;
      box-shadow: 0 4px 14px rgba(16, 185, 129, 0.28);
    }

    .tab-counter {
      background: rgba(0, 0, 0, 0.08);
      padding: 1px 7px;
      border-radius: var(--radius-pill);
      font-size: 0.78rem;
    }
    .tab-btn.active .tab-counter {
      background: rgba(255, 255, 255, 0.26);
      color: #ffffff;
    }

    .search-filter-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
    }

    .search-box-wrap {
      flex: 1;
      min-width: 260px;
      position: relative;
    }

    .search-box-wrap input {
      width: 100%;
      height: 42px;
      background: var(--bg-primary);
      border: 1px solid var(--border);
      border-radius: var(--radius-pill);
      padding: 0 94px 0 38px;
      color: var(--text-main);
      font-size: 0.9rem;
      outline: none;
      transition: var(--transition);
    }

    .search-box-wrap input:focus {
      border-color: #10b981;
      background: var(--bg-surface);
      box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
    }

    .search-icon-svg {
      position: absolute;
      left: 14px;
      top: 50%;
      transform: translateY(-50%);
      color: var(--text-dim);
      pointer-events: none;
    }

    .btn-clear-search {
      position: absolute;
      right: 76px;
      top: 50%;
      transform: translateY(-50%);
      background: none;
      border: none;
      color: var(--text-dim);
      cursor: pointer;
      display: none;
      font-size: 0.9rem;
      padding: 4px;
    }

    .btn-search-pill {
      position: absolute;
      right: 5px;
      top: 5px;
      bottom: 5px;
      padding: 0 16px;
      background: var(--brand-gradient);
      color: #ffffff;
      border: none;
      border-radius: var(--radius-pill);
      font-size: 0.84rem;
      font-weight: 600;
      cursor: pointer;
      transition: var(--transition-fast);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
    }
    .btn-search-pill:hover {
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.38);
      transform: translateY(-1px);
    }

    /* View Switcher Buttons (Grid vs List) */
    .view-switch-group {
      display: flex;
      align-items: center;
      background: var(--bg-primary);
      border: 1px solid var(--border);
      border-radius: var(--radius-pill);
      padding: 3px;
      gap: 2px;
    }

    .view-toggle-btn {
      background: transparent;
      border: none;
      padding: 6px 12px;
      border-radius: var(--radius-pill);
      color: var(--text-muted);
      font-size: 0.84rem;
      font-weight: 500;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      transition: var(--transition);
    }

    .view-toggle-btn:hover {
      color: var(--text-main);
    }

    .view-toggle-btn.active {
      background: var(--bg-surface);
      color: var(--text-main);
      font-weight: 600;
      box-shadow: var(--shadow-sm);
    }

    .view-select {
      height: 42px;
      background: var(--bg-primary);
      border: 1px solid var(--border);
      border-radius: var(--radius-pill);
      padding: 0 16px;
      color: var(--text-main);
      font-size: 0.86rem;
      font-weight: 500;
      outline: none;
      cursor: pointer;
      transition: var(--transition);
    }
    .view-select:focus {
      border-color: #10b981;
    }

    /* -------------------------------------------------------------
       MODE 1: VAULT GRID VIEW (Cards)
       ------------------------------------------------------------- */
    .vault-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
      gap: 16px;
    }

    .vault-card {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 18px 20px;
      transition: var(--transition);
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      position: relative;
      box-shadow: var(--shadow-card);
      cursor: pointer;
    }

    .vault-card:hover {
      border-color: var(--border-focus);
      transform: translateY(-2px);
      box-shadow: var(--shadow-hover);
    }

    .vault-card-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }

    .card-title-group {
      display: flex;
      align-items: center;
      gap: 12px;
      min-width: 0;
    }

    .service-avatar {
      width: 40px;
      height: 40px;
      border-radius: var(--radius-sm);
      background: var(--brand-gradient-soft);
      border: 1px solid rgba(16, 185, 129, 0.2);
      color: #059669;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.1rem;
      font-weight: 700;
      flex-shrink: 0;
      text-transform: uppercase;
    }
    [data-theme="dark"] .service-avatar {
      color: #10b981;
    }

    .service-heading {
      min-width: 0;
    }

    .service-name {
      font-size: 1rem;
      font-weight: 600;
      color: var(--text-main);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      max-width: 210px;
    }

    .service-url-link {
      font-size: 0.78rem;
      color: var(--text-dim);
      text-decoration: none;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      display: block;
      max-width: 210px;
    }
    .service-url-link:hover {
      color: #059669;
      text-decoration: underline;
    }

    .category-chip {
      font-size: 0.74rem;
      font-weight: 500;
      padding: 3px 10px;
      border-radius: var(--radius-pill);
      background: var(--bg-subtle);
      color: var(--text-muted);
      border: 1px solid var(--border-subtle);
      white-space: nowrap;
    }

    .card-fields {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin: 10px 0 14px;
      background: var(--bg-primary);
      padding: 12px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border-subtle);
    }

    .field-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      font-size: 0.84rem;
    }

    .field-label {
      color: var(--text-dim);
      font-size: 0.76rem;
      font-weight: 500;
      min-width: 50px;
    }

    .field-val-box {
      display: flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
      font-family: "JetBrains Mono", monospace;
    }

    .email-login-pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: var(--c-blue-bg);
      border: 1px solid var(--c-blue-border);
      color: var(--c-blue);
      padding: 4px 10px;
      border-radius: var(--radius-sm);
      font-size: 0.8rem;
      font-weight: 500;
      font-family: inherit;
    }

    .copy-pill-btn {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: var(--bg-surface);
      border: 1px solid var(--border);
      padding: 3px 8px;
      border-radius: var(--radius-sm);
      font-size: 0.8rem;
      cursor: pointer;
      transition: var(--transition);
      color: var(--text-body);
      max-width: 190px;
    }
    .copy-pill-btn:hover {
      border-color: #10b981;
      color: #059669;
      background: var(--c-emerald-bg);
    }
    .copy-pill-btn span {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .masked-pass-text {
      letter-spacing: 0.15em;
      color: var(--text-dim);
      font-size: 0.86rem;
    }

    .revealed-pass-text {
      color: #059669;
      font-weight: 600;
      font-size: 0.82rem;
    }
    [data-theme="dark"] .revealed-pass-text {
      color: #10b981;
    }

    .icon-action-btn {
      background: none;
      border: none;
      color: var(--text-dim);
      cursor: pointer;
      padding: 4px;
      border-radius: 4px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transition: var(--transition);
    }
    .icon-action-btn:hover {
      color: var(--text-main);
      background: var(--border-subtle);
    }

    .card-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      border-top: 1px solid var(--border-subtle);
      padding-top: 12px;
      margin-top: auto;
    }

    .card-note {
      font-size: 0.78rem;
      color: var(--text-muted);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      flex: 1;
      min-width: 0;
    }

    .card-actions {
      display: flex;
      align-items: center;
      gap: 4px;
      flex-shrink: 0;
    }

    /* -------------------------------------------------------------
       MODE 2: VAULT LIST VIEW (Clean Table Style)
       ------------------------------------------------------------- */
    .vault-list-container {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      overflow: hidden;
      box-shadow: var(--shadow-card);
    }

    .vault-list-table {
      width: 100%;
      border-collapse: collapse;
      text-align: left;
    }

    .vault-list-table th {
      background: var(--bg-primary);
      padding: 12px 18px;
      font-size: 0.78rem;
      font-weight: 600;
      color: var(--text-dim);
      text-transform: uppercase;
      letter-spacing: 0.04em;
      border-bottom: 1px solid var(--border);
      white-space: nowrap;
    }

    .vault-list-table td {
      padding: 14px 18px;
      border-bottom: 1px solid var(--border-subtle);
      vertical-align: middle;
      font-size: 0.88rem;
      cursor: pointer;
    }

    .vault-list-table tr:last-child td {
      border-bottom: none;
    }

    .vault-list-table tr:hover td {
      background: var(--bg-card-hover);
    }

    /* -------------------------------------------------------------
       MODAL 1: DETAIL POPUP MODAL (When clicking an item)
       ------------------------------------------------------------- */
    .detail-avatar-large {
      width: 54px;
      height: 54px;
      border-radius: var(--radius-md);
      background: var(--brand-gradient-soft);
      border: 1px solid rgba(16, 185, 129, 0.25);
      color: #059669;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.6rem;
      font-weight: 700;
      flex-shrink: 0;
    }
    [data-theme="dark"] .detail-avatar-large { color: #10b981; }

    .detail-prop-box {
      background: var(--bg-primary);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 12px 16px;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .detail-prop-label {
      font-size: 0.76rem;
      font-weight: 600;
      color: var(--text-dim);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    .detail-prop-value {
      font-size: 0.95rem;
      color: var(--text-main);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    .detail-desc-box {
      background: var(--c-emerald-bg);
      border: 1px solid var(--c-emerald-border);
      border-radius: var(--radius-sm);
      padding: 14px 16px;
      color: var(--text-body);
      font-size: 0.92rem;
      line-height: 1.6;
    }

    /* -------------------------------------------------------------
       MODAL DIALOG (Standard & Accessible)
       ------------------------------------------------------------- */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.5);
      backdrop-filter: blur(4px);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 10000;
      padding: 20px;
    }
    .modal-overlay.active {
      display: flex;
    }

    .modal-window {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: 22px;
      width: 100%;
      max-width: 520px;
      box-shadow: var(--shadow-floating);
      overflow: hidden;
      animation: modalScale 0.18s ease-out;
    }
    @keyframes modalScale {
      from { opacity: 0; transform: scale(0.96); }
      to { opacity: 1; transform: scale(1); }
    }

    .modal-header {
      padding: 18px 24px;
      border-bottom: 1px solid var(--border-subtle);
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    .modal-title {
      font-size: 1.1rem;
      font-weight: 600;
      color: var(--text-main);
    }

    .modal-body {
      padding: 22px 24px;
      display: flex;
      flex-direction: column;
      gap: 16px;
      max-height: 75vh;
      overflow-y: auto;
    }

    .form-group {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .form-label {
      font-size: 0.82rem;
      font-weight: 500;
      color: var(--text-muted);
    }

    .form-control {
      width: 100%;
      background: var(--bg-primary);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      padding: 10px 14px;
      color: var(--text-main);
      font-size: 0.9rem;
      outline: none;
      transition: var(--transition);
      font-family: inherit;
    }
    .form-control:focus {
      border-color: #10b981;
      background: var(--bg-surface);
      box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
    }

    .modal-footer {
      padding: 16px 24px;
      border-top: 1px solid var(--border-subtle);
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 10px;
      background: var(--bg-subtle);
    }

    /* Modal Pill Buttons & Tag Buttons */
    .tag-btn,
    .btn-modal-pill {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      padding: 8px 18px;
      border-radius: var(--radius-pill);
      font-size: 0.85rem;
      font-weight: 600;
      cursor: pointer;
      border: 1px solid var(--border);
      background: var(--bg-surface);
      color: var(--text-main);
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
      line-height: 1.2;
      user-select: none;
      box-shadow: var(--shadow-sm);
    }
    .tag-btn:hover,
    .btn-modal-pill:hover {
      background: var(--bg-subtle);
      border-color: var(--border-hover);
      transform: translateY(-1px);
      box-shadow: var(--shadow-hover);
    }
    .tag-btn:active,
    .btn-modal-pill:active {
      transform: translateY(0);
    }

    /* Primary Emerald Gradient Pill (Tone matching the search button!) */
    .tag-btn-primary,
    .btn-modal-primary {
      background: var(--brand-gradient) !important;
      color: #ffffff !important;
      border: none !important;
      font-weight: 600 !important;
      box-shadow: 0 3px 12px rgba(16, 185, 129, 0.32) !important;
    }
    .tag-btn-primary:hover,
    .btn-modal-primary:hover {
      box-shadow: 0 5px 18px rgba(16, 185, 129, 0.46) !important;
      transform: translateY(-2px) !important;
      filter: brightness(1.05) !important;
    }

    /* Compact Copy / Action Pill inside Popups (คัดลอกลิงก์, คัดลอกบัญชี, ดูรหัส) */
    .btn-copy-pill {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      background: var(--brand-gradient);
      color: #ffffff;
      border: none;
      padding: 6px 14px;
      border-radius: var(--radius-pill);
      font-size: 0.78rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
      box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
      white-space: nowrap;
      user-select: none;
    }
    .btn-copy-pill:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.38);
      filter: brightness(1.06);
    }
    .btn-copy-pill:active {
      transform: translateY(0);
    }

    /* -------------------------------------------------------------
       GENERATOR BOX & CUSTOM BEAUTIFUL SLIDER
       ------------------------------------------------------------- */
    .generator-preview {
      background: var(--bg-primary);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 14px 18px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-family: "JetBrains Mono", monospace;
      font-size: 1.15rem;
      font-weight: 600;
      color: #059669;
    }
    [data-theme="dark"] .generator-preview { color: #10b981; }

    .slider-box-card {
      background: var(--bg-primary);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 16px 20px;
      margin: 4px 0 6px;
    }

    .slider-header-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 12px;
    }

    .slider-title {
      font-size: 0.86rem;
      font-weight: 600;
      color: var(--text-body);
    }

    .slider-badge-val {
      font-size: 0.82rem;
      font-weight: 700;
      color: #ffffff;
      background: var(--brand-gradient);
      padding: 3px 12px;
      border-radius: var(--radius-pill);
      box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
    }

    .slider-track-wrap {
      padding: 8px 4px;
    }

    .custom-slider {
      -webkit-appearance: none;
      appearance: none;
      width: 100%;
      height: 8px;
      border-radius: 9999px;
      background: var(--border);
      outline: none;
      transition: background 0.2s ease;
      cursor: pointer;
      display: block;
    }

    .custom-slider::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: var(--brand-gradient);
      border: 3px solid #ffffff;
      box-shadow: 0 2px 8px rgba(16, 185, 129, 0.45);
      cursor: pointer;
      transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .custom-slider::-webkit-slider-thumb:hover {
      transform: scale(1.15);
      box-shadow: 0 4px 12px rgba(16, 185, 129, 0.6);
    }

    .custom-slider::-moz-range-thumb {
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: var(--brand-gradient);
      border: 3px solid #ffffff;
      box-shadow: 0 2px 8px rgba(16, 185, 129, 0.45);
      cursor: pointer;
      transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .slider-ticks-row {
      display: flex;
      justify-content: space-between;
      font-size: 0.72rem;
      color: var(--text-dim);
      margin-top: 8px;
    }

    .gen-options-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 10px;
      font-size: 0.84rem;
      color: var(--text-body);
      margin-top: 8px;
    }

    /* Toast Notification */
    .toast-pill {
      position: fixed;
      bottom: 28px;
      right: 28px;
      background: var(--bg-surface);
      border: 1px solid #10b981;
      color: var(--text-main);
      padding: 12px 22px;
      border-radius: var(--radius-pill);
      box-shadow: var(--shadow-floating);
      font-size: 0.88rem;
      font-weight: 500;
      display: flex;
      align-items: center;
      gap: 10px;
      z-index: 20000;
      opacity: 0;
      transform: translateY(14px);
      transition: var(--transition);
      pointer-events: none;
    }
    .toast-pill.show {
      opacity: 1;
      transform: translateY(0);
      pointer-events: auto;
    }

    .empty-box {
      grid-column: 1 / -1;
      background: var(--bg-surface);
      border: 1px dashed var(--border);
      border-radius: var(--radius-lg);
      padding: 50px 20px;
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 12px;
      box-shadow: var(--shadow-sm);
    }

    /* Header Row & Mobile Menu Trigger (3 ขีด) */
    .header-main-row {
      display: flex;
      align-items: center;
      justify-content: center;
      position: relative;
      width: 100%;
    }

    .mobile-menu-trigger {
      display: none;
      align-items: center;
      justify-content: center;
      width: 42px;
      height: 42px;
      border-radius: var(--radius-pill);
      border: 1px solid var(--border);
      background: var(--bg-surface);
      color: var(--text-main);
      cursor: pointer;
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
      box-shadow: var(--shadow-sm);
      padding: 0;
      flex-shrink: 0;
    }
    .mobile-menu-trigger:hover {
      background: var(--bg-subtle);
      border-color: #10b981;
      color: #059669;
      transform: scale(1.04);
    }
    .mobile-menu-trigger:active {
      transform: scale(0.96);
    }

    /* Mobile Drawer (Slide-in Menu from Right) */
    .mobile-drawer-overlay {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.55);
      backdrop-filter: blur(5px);
      -webkit-backdrop-filter: blur(5px);
      z-index: 9500;
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.25s ease, visibility 0.25s ease;
    }
    .mobile-drawer-overlay.active {
      opacity: 1;
      visibility: visible;
    }

    .mobile-drawer {
      position: fixed;
      top: 0;
      right: 0;
      bottom: 0;
      width: 320px;
      max-width: 86vw;
      background: var(--bg-surface);
      border-left: 1px solid var(--border);
      z-index: 9510;
      display: flex;
      flex-direction: column;
      box-shadow: -10px 0 35px rgba(0, 0, 0, 0.2);
      transform: translateX(100%);
      transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .mobile-drawer.active {
      transform: translateX(0);
    }

    .mobile-drawer-header {
      padding: 20px 20px 16px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: 1px solid var(--border-subtle);
    }
    .drawer-brand {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .drawer-title {
      font-size: 1.05rem;
      font-weight: 700;
      color: var(--text-main);
      line-height: 1.2;
    }
    .drawer-subtitle {
      font-size: 0.74rem;
      color: var(--text-muted);
      margin-top: 2px;
    }
    .drawer-close-btn {
      width: 34px;
      height: 34px;
      border-radius: 50%;
      background: var(--bg-subtle);
      border: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.95rem;
      color: var(--text-muted);
      cursor: pointer;
      transition: all 0.15s ease;
    }
    .drawer-close-btn:hover {
      background: var(--border);
      color: var(--text-main);
    }

    .mobile-drawer-content {
      flex: 1;
      overflow-y: auto;
      padding: 16px 14px 20px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .drawer-section-title {
      font-size: 0.72rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      color: var(--text-dim);
      padding: 8px 10px 4px;
    }

    .drawer-divider {
      height: 1px;
      background: var(--border-subtle);
      margin: 8px 0;
    }

    .drawer-nav-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 10px 12px;
      border-radius: var(--radius-md);
      background: transparent;
      border: 1px solid transparent;
      color: var(--text-main);
      font-size: 0.9rem;
      font-weight: 500;
      text-align: left;
      cursor: pointer;
      transition: all 0.15s ease;
      width: 100%;
      user-select: none;
    }
    .drawer-nav-item:hover {
      background: var(--bg-subtle);
      border-color: var(--border-subtle);
    }
    .drawer-nav-item:active {
      transform: scale(0.98);
    }

    .drawer-icon-box {
      width: 36px;
      height: 36px;
      border-radius: var(--radius-sm);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 1.1rem;
      flex-shrink: 0;
    }
    .drawer-item-text {
      display: flex;
      flex-direction: column;
      min-width: 0;
    }
    .drawer-item-label {
      font-weight: 600;
      font-size: 0.88rem;
      color: var(--text-main);
    }
    .drawer-item-desc {
      font-size: 0.74rem;
      color: var(--text-muted);
      margin-top: 1px;
    }

    .mobile-drawer-footer {
      padding: 14px 20px;
      border-top: 1px solid var(--border-subtle);
      background: var(--bg-subtle);
      text-align: center;
    }
    .drawer-footer-badge {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 0.75rem;
      color: var(--text-muted);
      font-weight: 500;
    }

    /* Pagination Component */
    .pagination-bar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 16px 22px;
      margin-top: 24px;
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-sm);
      flex-wrap: wrap;
    }

    .pagination-info {
      font-size: 0.86rem;
      color: var(--text-muted);
    }
    .pagination-info strong {
      color: var(--text-main);
      font-weight: 600;
    }

    .pagination-controls {
      display: flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
    }

    .page-btn {
      min-width: 36px;
      height: 36px;
      padding: 0 10px;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--bg-surface);
      color: var(--text-main);
      font-size: 0.86rem;
      font-weight: 500;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      transition: all 0.15s ease;
      user-select: none;
    }
    .page-btn:hover:not(:disabled) {
      background: var(--bg-subtle);
      border-color: #10b981;
      color: #059669;
      transform: translateY(-1px);
    }
    .page-btn:active:not(:disabled) {
      transform: translateY(0);
    }
    .page-btn:disabled {
      opacity: 0.35;
      cursor: not-allowed;
      border-color: var(--border-subtle);
    }

    .page-btn.active {
      background: var(--brand-gradient);
      color: #ffffff;
      border-color: transparent;
      font-weight: 700;
      box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
    }

    .page-btn.page-ellipsis {
      border: none;
      background: transparent;
      cursor: default;
      color: var(--text-dim);
      min-width: 24px;
      padding: 0;
    }

    .pagination-per-page {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 0.82rem;
      color: var(--text-muted);
    }
    .per-page-select {
      background: var(--bg-primary);
      border: 1px solid var(--border);
      color: var(--text-main);
      padding: 6px 12px;
      border-radius: var(--radius-sm);
      font-size: 0.82rem;
      font-family: inherit;
      outline: none;
      cursor: pointer;
      transition: var(--transition);
    }
    .per-page-select:focus {
      border-color: #10b981;
    }

    /* RESPONSIVE MEDIA QUERIES (Mobile <= 768px) */
    @media (max-width: 768px) {
      .container {
        padding: 0 12px;
      }

      .app-header-box {
        padding: 12px 14px;
        border-radius: 20px;
        margin: 10px auto 12px;
        text-align: left;
        width: 100%;
      }
      .header-main-row {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
      }
      .brand-title {
        font-size: 1.22rem !important;
        margin-bottom: 0 !important;
        text-align: left;
        line-height: 1.2;
      }
      .mobile-menu-trigger {
        display: inline-flex !important;
        width: 38px;
        height: 38px;
        flex-shrink: 0;
      }
      .header-tags {
        display: none !important; /* Managed via Mobile Drawer */
      }

      /* Horizontal Category Swipe Strip on Mobile */
      .stats-grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 8px;
        padding: 2px 2px 8px 2px;
        margin-bottom: 12px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
      }
      .stats-grid::-webkit-scrollbar {
        display: none;
      }
      .stat-card {
        flex: 0 0 auto;
        scroll-snap-align: start;
        min-height: auto;
        padding: 8px 13px;
        border-radius: var(--radius-pill);
        flex-direction: row;
        align-items: center;
        gap: 8px;
      }
      .stat-card .stat-top {
        margin-bottom: 0;
        min-height: auto;
        gap: 6px;
      }
      .stat-card .stat-value {
        font-size: 0.95rem;
        font-weight: 700;
        margin-left: 2px;
      }
      .stat-card .stat-label {
        font-size: 0.8rem;
        white-space: nowrap;
      }
      .stat-card .stat-badge-icon {
        width: 24px;
        height: 24px;
        font-size: 0.88rem;
      }

      /* Minimal Controls on Mobile */
      .controls-panel {
        padding: 12px 14px;
        margin-bottom: 14px;
        border-radius: 18px;
        gap: 10px;
      }
      .search-filter-row {
        flex-direction: column;
        gap: 10px;
        width: 100%;
      }
      .search-box-wrap {
        width: 100%;
        min-width: 100%;
      }
      .search-box-wrap input {
        height: 38px;
        font-size: 0.85rem;
      }
      .search-filter-row > div:last-child {
        width: 100%;
        display: flex;
        gap: 8px;
        justify-content: space-between;
      }
      .view-switch-group {
        flex: 1;
      }
      .view-toggle-btn {
        flex: 1;
        justify-content: center;
        padding: 6px 8px;
        font-size: 0.78rem;
      }
      .view-select {
        flex: 1;
        font-size: 0.78rem;
        padding: 6px 8px;
        max-width: 50%;
      }

      /* Minimal Cards on Mobile */
      .vault-grid {
        grid-template-columns: 1fr;
        gap: 10px;
      }
      .vault-card {
        padding: 13px 14px;
        border-radius: 16px;
      }
      .vault-card-header {
        margin-bottom: 8px;
      }
      .service-avatar {
        width: 36px;
        height: 36px;
        font-size: 1.05rem;
      }
      .service-name {
        font-size: 0.93rem;
      }
      .card-fields {
        margin-bottom: 8px;
        gap: 6px;
      }
      .copy-pill-btn {
        max-width: 140px;
        font-size: 0.78rem;
      }
      .card-footer {
        padding-top: 8px;
        margin-top: 6px;
      }
      .card-note {
        font-size: 0.76rem;
        max-width: 160px;
      }

      /* Pagination Mobile Layout */
      .pagination-bar {
        padding: 14px 14px;
        margin-top: 16px;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        text-align: center;
      }
      .pagination-controls {
        justify-content: center;
        width: 100%;
        gap: 4px;
      }
      .page-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.82rem;
        padding: 0 8px;
      }
      .pagination-per-page {
        font-size: 0.78rem;
      }
    }

    /* Cancelled Items Styling (ขึ้นสีแดง + ย้ายไปล่างสุด) */
    .vault-card.is-cancelled {
      border: 1.5px solid var(--c-rose-border) !important;
      background: var(--c-rose-bg) !important;
      opacity: 0.92;
      position: relative;
    }
    .vault-card.is-cancelled:hover {
      opacity: 1;
      border-color: var(--c-rose) !important;
      box-shadow: 0 8px 24px -4px rgba(225, 29, 72, 0.18);
    }
    .vault-card.is-cancelled .service-avatar {
      background: var(--c-rose-bg);
      color: var(--c-rose);
      border: 1.5px solid var(--c-rose-border);
    }
    .badge-cancelled {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 9px;
      border-radius: var(--radius-pill);
      font-size: 0.72rem;
      font-weight: 600;
      background: var(--c-rose-bg);
      color: var(--c-rose);
      border: 1px solid var(--c-rose-border);
      letter-spacing: 0.02em;
    }
    .vault-list-table tr.is-cancelled-row {
      background: var(--c-rose-bg) !important;
      opacity: 0.92;
    }
    .vault-list-table tr.is-cancelled-row:hover {
      opacity: 1;
      background: rgba(225, 29, 72, 0.12) !important;
    }
    .vault-list-table tr.is-cancelled-row td:first-child {
      border-left: 4px solid var(--c-rose);
    }
    .cancelled-alert-banner {
      display: flex;
      align-items: center;
      gap: 10px;
      background: var(--c-rose-bg);
      border: 1px solid var(--c-rose-border);
      color: var(--c-rose);
      padding: 10px 14px;
      border-radius: var(--radius-sm);
      margin-bottom: 14px;
      font-size: 0.85rem;
    }
    .quick-email-pill {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-pill);
      padding: 4px 10px;
      font-size: 0.76rem;
      font-family: 'JetBrains Mono', monospace;
      color: var(--text-body);
      cursor: pointer;
      transition: var(--transition);
      display: inline-flex;
      align-items: center;
      gap: 4px;
    }
    .quick-email-pill:hover {
      border-color: var(--c-blue);
      color: var(--c-blue);
      background: var(--c-blue-bg);
    }


    /* -------------------------------------------------------------
       SECURITY SYSTEM: MASTER PASSWORD LOCK & AES-256 ENCRYPTION
       ------------------------------------------------------------- */
    .lock-screen-container {
      position: fixed;
      inset: 0;
      z-index: 9999;
      background: var(--bg-primary);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
    }
    .lock-card {
      background: var(--bg-surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-floating);
      width: 100%;
      max-width: 450px;
      padding: 38px 32px;
      text-align: center;
      position: relative;
      animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .lock-icon-badge {
      width: 68px;
      height: 68px;
      border-radius: 50%;
      background: var(--brand-gradient-soft);
      border: 1.5px solid rgba(16, 185, 129, 0.3);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 2.1rem;
      margin-bottom: 18px;
      box-shadow: 0 4px 15px rgba(16, 185, 129, 0.15);
    }
    .lock-title {
      font-size: 1.45rem;
      font-weight: 700;
      color: var(--text-main);
      margin-bottom: 6px;
    }
    .lock-desc {
      font-size: 0.88rem;
      color: var(--text-muted);
      line-height: 1.55;
      margin-bottom: 22px;
    }
    .lock-input-wrap {
      position: relative;
      margin-bottom: 14px;
      text-align: left;
    }
    .lock-input-label {
      display: block;
      font-size: 0.8rem;
      font-weight: 600;
      color: var(--text-body);
      margin-bottom: 6px;
    }
    .lock-input-wrap input {
      width: 100%;
      padding: 12px 42px 12px 14px;
      font-size: 0.98rem;
      font-family: inherit;
      border-radius: var(--radius-sm);
      border: 1px solid var(--border);
      background: var(--bg-primary);
      color: var(--text-main);
      transition: var(--transition);
      outline: none;
    }
    .lock-input-wrap input:focus {
      border-color: #10b981;
      box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
    }
    .lock-eye-btn {
      position: absolute;
      right: 12px;
      top: 36px;
      background: none;
      border: none;
      cursor: pointer;
      color: var(--text-dim);
      padding: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    #lockCardUnlock .lock-eye-btn {
      top: 50%;
      transform: translateY(-50%);
    }
    .lock-eye-btn:hover {
      color: var(--text-main);
    }
    .lock-btn-submit {
      width: 100%;
      padding: 13px;
      font-size: 1rem;
      font-weight: 600;
      border: none;
      border-radius: var(--radius-sm);
      background: var(--brand-gradient);
      color: white;
      cursor: pointer;
      box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
      transition: var(--transition);
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      margin-top: 10px;
    }
    .lock-btn-submit:hover {
      transform: translateY(-1px);
      box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
    }
    .lock-btn-secondary {
      width: 100%;
      padding: 9px 14px;
      font-size: 0.82rem;
      font-weight: 500;
      color: var(--text-muted);
      background: var(--bg-subtle);
      border: 1px solid var(--border);
      border-radius: var(--radius-sm);
      cursor: pointer;
      transition: all var(--transition-fast);
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .lock-btn-secondary:hover {
      background: var(--bg-surface);
      color: var(--text-main);
      border-color: var(--border-hover);
    }
    .lock-error-msg {
      color: var(--c-rose);
      font-size: 0.84rem;
      font-weight: 500;
      margin-top: 10px;
      min-height: 20px;
    }
    .security-badge-active {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      font-size: 0.74rem;
      font-weight: 600;
      padding: 3px 9px;
      border-radius: var(--radius-pill);
      background: rgba(16, 185, 129, 0.1);
      color: #059669;
      border: 1px solid rgba(16, 185, 129, 0.25);
    }
    [data-theme="dark"] .security-badge-active {
      background: rgba(16, 185, 129, 0.18);
      color: #10b981;
      border-color: rgba(16, 185, 129, 0.35);
    }
    .shake {
      animation: shakeAnim 0.4s ease-in-out;
    }
    @keyframes shakeAnim {
      0%, 100% { transform: translateX(0); }
      20%, 60% { transform: translateX(-8px); }
      40%, 80% { transform: translateX(8px); }
    }
    @keyframes popIn {
      0% { opacity: 0; transform: scale(0.95); }
      100% { opacity: 1; transform: scale(1); }
    }

    .file-drop-zone {
      border: 2px dashed var(--border);
      background: var(--bg-card);
      border-radius: var(--radius-md);
      padding: 24px 16px;
      text-align: center;
      cursor: pointer;
      transition: all var(--transition-fast);
    }
    .file-drop-zone:hover {
      border-color: var(--c-primary);
      background: var(--bg-subtle);
      transform: translateY(-1px);
    }
    .file-drop-zone.has-file {
      border-color: #10b981;
      background: rgba(16, 185, 129, 0.06);
    }

    /* Hide master password recovery on mobile devices */
    @media (max-width: 768px) {
      .desktop-only-recovery {
        display: none !important;
      }
    }
