/* =====================================================================================
   Support System - theme switch, hamburger action menus and hand-tuned dark rules.
   Load order (every layout): ...existing css..., theme.css, theme-dark.css.
   theme-dark.css is generated from the light stylesheets (tools/gen_dark.py) and only
   repaints colours; the rules below cover what a colour remap cannot express well.
   ===================================================================================== */

/* ---------- no transition flash while switching ---------- */
html.theme-switching *,html.theme-switching *::before,html.theme-switching *::after{transition:none!important;}

/* ---------- theme toggle button (Admin/User topbar + public nav) ---------- */
.theme-toggle{display:inline-flex;align-items:center;justify-content:center;width:38px;height:38px;flex:none;padding:0;border:1px solid #e2e8f0;border-radius:10px;background:#fff;color:#475569;cursor:pointer;transition:background .15s,color .15s,border-color .15s;}
.theme-toggle:hover{background:#eff6ff;color:#2563eb;border-color:#bfdbfe;}
.theme-toggle:focus-visible{outline:0;box-shadow:0 0 0 3px #bfdbfe;}
.theme-toggle svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;}
.theme-toggle .ic-sun{display:none;}
html[data-theme="dark"] .theme-toggle .ic-sun{display:block;}
html[data-theme="dark"] .theme-toggle .ic-moon{display:none;}
/* public header placement: brand | links | toggle | mobile menu */
.public-nav-inner .public-brand{margin-right:auto;}
.public-nav-inner .public-links{order:2;}
.public-nav-tools{order:3;display:flex;align-items:center;gap:8px;}
.public-nav-inner .nav-toggle{order:4;}
@media(max-width:980px){.public-nav-inner .public-links{order:5;}}
@media(max-width:560px){.theme-toggle{width:34px;height:34px;border-radius:9px;}.theme-toggle svg{width:17px;height:17px;}}

/* ---------- hamburger action menu ---------- */
.ss-am-hidden{display:none!important;}
.ss-menu-trigger,.story-menu-trigger{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;flex:none;
  border:1px solid #d6e0ee;border-radius:9px;background:#fff;color:#334155;cursor:pointer;font-size:0;line-height:0;vertical-align:middle;
  box-shadow:0 1px 2px rgba(15,23,42,.05);transition:background .12s,border-color .12s,color .12s,box-shadow .12s;}
.ss-menu-trigger svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;}
.story-menu-trigger::before{content:'';width:16px;height:12px;background:linear-gradient(currentColor 0 0) 0 0/100% 2px no-repeat,linear-gradient(currentColor 0 0) 0 5px/100% 2px no-repeat,linear-gradient(currentColor 0 0) 0 10px/100% 2px no-repeat;border-radius:1px;}
.ss-menu-trigger:hover,.ss-menu-trigger:focus-visible,.ss-menu-trigger[aria-expanded="true"],
.story-menu-trigger:hover,.story-menu-trigger:focus-visible,.story-menu-trigger[aria-expanded="true"]{background:#eff6ff;border-color:#93c5fd;color:#1d4ed8;outline:0;}
.ss-menu-trigger:focus-visible,.story-menu-trigger:focus-visible{box-shadow:0 0 0 3px #bfdbfe;}
.data-table td.ss-am-cell{width:1%;white-space:nowrap;text-align:center;}
.ss-am-head{flex-wrap:nowrap!important;}
.ss-am-head .ss-menu-trigger{width:38px;height:38px;border-radius:10px;}

.ss-action-menu{position:fixed;z-index:3500;min-width:200px;max-width:min(300px,calc(100vw - 16px));background:#fff;border:1px solid #dbe2ed;border-radius:12px;
  box-shadow:0 16px 45px rgba(15,23,42,.20);padding:6px;animation:ss-menu-in .12s ease-out;}
.ss-action-menu[hidden]{display:none!important;}
@keyframes ss-menu-in{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
.ss-action-item{display:flex;align-items:center;gap:11px;width:100%;box-sizing:border-box;border:0;border-radius:7px;background:transparent;text-align:left;
  font:inherit;font-size:13px;font-weight:550;color:#334155;padding:9px 12px;cursor:pointer;text-decoration:none;white-space:nowrap;}
.ss-action-item span{overflow:hidden;text-overflow:ellipsis;}
.ss-action-item svg{width:16px;height:16px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;opacity:.85;}
.ss-action-item:hover,.ss-action-item:focus-visible{background:#eff6ff;color:#1d4ed8;outline:0;text-decoration:none;}
.ss-action-item.is-danger{color:#b91c1c;}
.ss-action-item.is-danger:hover,.ss-action-item.is-danger:focus-visible{background:#fef2f2;color:#b91c1c;}
.ss-action-item:disabled{opacity:.45;cursor:not-allowed;}
.ss-action-item.is-danger{border-top:1px solid #f1f5f9;border-radius:0 0 7px 7px;margin-top:3px;padding-top:11px;}

/* ---------- password reveal (Admin > Admin/User Management) ---------- */
.pw-field{position:relative;}
.pw-field .form-control{padding-right:40px!important;}
.pw-eye{position:absolute;right:4px;top:50%;transform:translateY(-50%);width:30px;height:28px;border:0;border-radius:6px;background:transparent;color:#64748b;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;padding:0;}
.pw-eye:hover,.pw-eye:focus-visible{background:#eff6ff;color:#1d4ed8;outline:0;}
.pw-eye svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;}
.pw-eye .ic-hide{display:none;}.pw-eye[aria-pressed="true"] .ic-show{display:none;}.pw-eye[aria-pressed="true"] .ic-hide{display:block;}
.pw-view{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
.pw-value{font-family:Consolas,ui-monospace,monospace;font-size:14px;letter-spacing:.04em;background:#f1f5f9;border:1px solid #e2e8f0;border-radius:7px;padding:4px 10px;color:#0f172a;overflow-wrap:anywhere;}
.pw-value.is-masked{letter-spacing:.18em;color:#64748b;}
.pw-reveal-box{margin:6px auto 0;max-width:360px;text-align:left;}
.pw-reveal-row{display:flex;justify-content:space-between;gap:12px;padding:9px 0;border-bottom:1px solid #e5e7eb;font-size:14px;}
.pw-reveal-row:last-child{border-bottom:0;}
.pw-reveal-row b{color:#64748b;font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.05em;padding-top:3px;}
.pw-reveal-row .pw-value{user-select:all;}
.pw-reveal-note{font-size:12px;color:#64748b;margin-top:10px;}

/* =====================================================================================
   Dark mode - hand-tuned layer (generated colour remap lives in theme-dark.css)
   ===================================================================================== */
html[data-theme="dark"]{color-scheme:dark;
  --ss-bg:#0b1120;--ss-surface:#131a2a;--ss-surface-2:#182136;--ss-raise:#1e293b;--ss-line:#263248;--ss-line-2:#334155;
  --ss-text:#e2e8f0;--ss-muted:#94a3b8;--ss-accent:#60a5fa;
  /* public site variables */
  --site-white:#131a2a;--site-light:#0b1120;--site-sky:#13223a;--site-text:#e2e8f0;--site-muted:#9fb0c3;--site-border:#263248;
  --site-navy:#cfe3ff;--site-steel:#9cc1e0;
  /* bootstrap-lite variables */
  --bs-body-bg:#0b1120;--bs-body-color:#e2e8f0;--bs-border-color:#334155;--bs-light:#1e293b;--bs-white:#131a2a;
  --shadow-sm:0 4px 16px rgba(0,0,0,.35);--shadow-md:0 12px 30px rgba(0,0,0,.40);--shadow-hover:0 20px 45px rgba(0,0,0,.50);}
html[data-theme="dark"] body{background:var(--ss-bg);color:var(--ss-text);}
html[data-theme="dark"] .admin-shell{background:var(--ss-bg);color:var(--ss-text);}
html[data-theme="dark"] .sidebar{background:#0f172a;border-right:1px solid var(--ss-line);}
html[data-theme="dark"] .admin-side-bottom{border-top-color:var(--ss-line);}
html[data-theme="dark"] .topbar{background:rgba(19,26,42,.92);backdrop-filter:saturate(1.2) blur(8px);border-bottom-color:var(--ss-line);}
html[data-theme="dark"] .crud-card,
html[data-theme="dark"] .stat-card:not(.dash-card),
html[data-theme="dark"] .rp-card,html[data-theme="dark"] .rp-kpi,html[data-theme="dark"] .rp-filters,
html[data-theme="dark"] .modal-dialog{background:var(--ss-surface);border-color:var(--ss-line);box-shadow:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.25);}
html[data-theme="dark"] .page-head h1,html[data-theme="dark"] .filterbar h2,html[data-theme="dark"] .modal-header h2,
html[data-theme="dark"] .story-page-card h2{color:#f1f5f9;}
html[data-theme="dark"] .data-table th{background:var(--ss-surface-2);color:var(--ss-muted);}
html[data-theme="dark"] .data-table td{border-bottom-color:var(--ss-line);}
html[data-theme="dark"] .data-table tbody tr:hover{background:#17203a;}
html[data-theme="dark"] .story-table-wrap .data-table{border-color:var(--ss-line);}
html[data-theme="dark"] .story-clickable-row:hover,html[data-theme="dark"] .story-clickable-row:focus-visible{background:#17203a!important;}
html[data-theme="dark"] .admin-modal{background:rgba(2,6,23,.75);}
html[data-theme="dark"] .modal-header,html[data-theme="dark"] .modal-footer{border-color:var(--ss-line);}
html[data-theme="dark"] .admin-shell .form-control,html[data-theme="dark"] .form-control,html[data-theme="dark"] .form-select{background-color:#0f1626;color:var(--ss-text);border-color:var(--ss-line-2);}
html[data-theme="dark"] .admin-shell .form-control:hover{border-color:#475569;}
html[data-theme="dark"] .admin-shell .form-control:focus,html[data-theme="dark"] .form-control:focus{border-color:#3b82f6;box-shadow:0 0 0 3px rgba(59,130,246,.25);}
html[data-theme="dark"] .admin-shell .form-control:disabled{background-color:#111827;color:#64748b;}
html[data-theme="dark"] .admin-shell select.form-control{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");}
html[data-theme="dark"] .form-control::placeholder{color:#64748b;}
html[data-theme="dark"] select option,html[data-theme="dark"] select optgroup{background:#0f1626;color:var(--ss-text);}
html[data-theme="dark"] .rich-editor{background:#0f1626;color:var(--ss-text);border-color:var(--ss-line-2);}
html[data-theme="dark"] .rich-toolbar{background:var(--ss-surface-2);border-color:var(--ss-line-2);}
html[data-theme="dark"] .rich-toolbar button{background:var(--ss-raise);color:#cbd5e1;}
html[data-theme="dark"] .rich-toolbar button:hover{border-color:#475569;}
html[data-theme="dark"] .admin-btn.secondary{background:var(--ss-raise);color:#e2e8f0;border-color:var(--ss-line-2);}
html[data-theme="dark"] .admin-btn.secondary:hover{background:#273449;border-color:#475569;}
html[data-theme="dark"] .admin-btn:focus-visible{box-shadow:0 0 0 3px rgba(96,165,250,.4);}
html[data-theme="dark"] .view-field{border-bottom-color:var(--ss-line);}
html[data-theme="dark"] .view-content,html[data-theme="dark"] .story-rich-text{color:#dbe4ef;}
html[data-theme="dark"] .story-rich-text a,html[data-theme="dark"] .view-content a{color:var(--ss-accent);}
html[data-theme="dark"] .account-link:hover{background:var(--ss-raise);color:#bfdbfe;}
html[data-theme="dark"] .account-avatar{background:#1e3a8a;color:#dbeafe;}
html[data-theme="dark"] .logout-link{color:var(--ss-accent);}
html[data-theme="dark"] .notif-badge{box-shadow:0 0 0 2px var(--ss-surface);}
html[data-theme="dark"] .notif-panel{background:var(--ss-surface);border-color:var(--ss-line);box-shadow:0 24px 60px -12px rgba(0,0,0,.7);}
html[data-theme="dark"] .notif-tabs button[aria-selected="true"]{background:#e2e8f0;border-color:#e2e8f0;color:#0f172a;}
html[data-theme="dark"] .dash-card:focus-visible{box-shadow:0 0 0 3px var(--ss-bg),0 0 0 6px var(--g1);}
html[data-theme="dark"] .rp-donut-total{fill:#f1f5f9;}
html[data-theme="dark"] .rp .rp-donut-track{stroke:var(--ss-raise);}
html[data-theme="dark"] .rp-grid-line{stroke:var(--ss-line);}
html[data-theme="dark"] .disc-thread#storyComments{background:linear-gradient(180deg,#0f1626,#111a2c);}
html[data-theme="dark"] .disc-bubble{background:var(--ss-raise);border-color:var(--ss-line-2);color:#e2e8f0;}
html[data-theme="dark"] .disc-msg.is-mine .disc-bubble{background:linear-gradient(135deg,#1e3a8a,#312e81);border-color:#3b4fa8;color:#eef2ff;}
html[data-theme="dark"] .disc-bubble pre{background:#020617;}
html[data-theme="dark"] #messageForm.disc-composer{background:var(--ss-surface);border-top-color:var(--ss-line);}
html[data-theme="dark"] .disc-avatar{box-shadow:0 0 0 2px var(--ss-surface);}
html[data-theme="dark"] .wf-scroll{background:linear-gradient(#111a2c,#0f1626);border-color:var(--ss-line);}
html[data-theme="dark"] .wf-state-box{background:var(--ss-raise);border-color:var(--ss-line-2);color:#e2e8f0;}
html[data-theme="dark"] .wf-state.is-current .wf-state-box{background:#1d4ed8;border-color:#1d4ed8;color:#fff;}
html[data-theme="dark"] .wf-quick{background:var(--ss-surface);border-color:var(--ss-line);}
html[data-theme="dark"] .wf-quick.is-dirty{background:#13213b;border-color:#2b4c80;}
html[data-theme="dark"] .story-event-values{background:var(--ss-surface-2);color:#dbe4ef;}
html[data-theme="dark"] .story-history-rich{color:#dbe4ef;}
html[data-theme="dark"] .story-rich-text pre,html[data-theme="dark"] .rich-editor pre{background:#0b1120;color:#e2e8f0;}
html[data-theme="dark"] .story-rich-text img,html[data-theme="dark"] .view-content img{background:#fff;border-radius:6px;}
html[data-theme="dark"] .story-doc-picker{background:#0f1626;border-color:var(--ss-line-2);color:#cbd5e1;}
html[data-theme="dark"] .story-doc-picker:hover,html[data-theme="dark"] .story-doc-picker.is-drag{background:#13213b;border-color:#3b82f6;}
html[data-theme="dark"] .mobile-menu{background:var(--ss-raise);border-color:var(--ss-line-2);color:#e2e8f0;}
html[data-theme="dark"] .sidebar-toggle,html[data-theme="dark"] .theme-toggle{background:var(--ss-raise);border-color:var(--ss-line-2);color:#cbd5e1;}
html[data-theme="dark"] .sidebar-toggle:hover,html[data-theme="dark"] .theme-toggle:hover{background:#273449;border-color:#475569;color:#fbbf24;}
html[data-theme="dark"] .sidebar-toggle:hover{color:#93c5fd;}
/* hamburger + menus in dark (matches the requested dark rounded-square trigger) */
html[data-theme="dark"] .ss-menu-trigger,html[data-theme="dark"] .story-menu-trigger{background:#1e293b;border-color:#334155;color:#cbd5e1;box-shadow:none;}
html[data-theme="dark"] .ss-menu-trigger:hover,html[data-theme="dark"] .ss-menu-trigger:focus-visible,html[data-theme="dark"] .ss-menu-trigger[aria-expanded="true"],
html[data-theme="dark"] .story-menu-trigger:hover,html[data-theme="dark"] .story-menu-trigger:focus-visible,html[data-theme="dark"] .story-menu-trigger[aria-expanded="true"]{background:#273449;border-color:#60a5fa;color:#bfdbfe;}
html[data-theme="dark"] .ss-menu-trigger:focus-visible,html[data-theme="dark"] .story-menu-trigger:focus-visible{box-shadow:0 0 0 3px rgba(96,165,250,.35);}
html[data-theme="dark"] .ss-action-menu,html[data-theme="dark"] .story-floating-menu{background:#1a2335;border-color:#2c3a52;box-shadow:0 18px 50px rgba(0,0,0,.6);}
html[data-theme="dark"] .ss-action-item,html[data-theme="dark"] .story-floating-menu button{color:#dbe4ef;}
html[data-theme="dark"] .ss-action-item:hover,html[data-theme="dark"] .ss-action-item:focus-visible,
html[data-theme="dark"] .story-floating-menu button:hover,html[data-theme="dark"] .story-floating-menu button:focus-visible{background:#24344f;color:#bfdbfe;}
html[data-theme="dark"] .ss-action-item.is-danger,html[data-theme="dark"] .story-floating-menu button[data-menu-action="delete"]{color:#fca5a5;border-top-color:#2c3a52;}
html[data-theme="dark"] .ss-action-item.is-danger:hover,html[data-theme="dark"] .ss-action-item.is-danger:focus-visible{background:#3a1a1f;color:#fecaca;}
html[data-theme="dark"] .pw-value{background:#0f1626;border-color:var(--ss-line-2);color:#f1f5f9;}
html[data-theme="dark"] .pw-value.is-masked{color:#94a3b8;}
html[data-theme="dark"] .pw-reveal-row{border-bottom-color:var(--ss-line);}
html[data-theme="dark"] .pw-eye:hover,html[data-theme="dark"] .pw-eye:focus-visible{background:var(--ss-raise);color:#bfdbfe;}
/* scrollbars */
html[data-theme="dark"] *{scrollbar-color:#334155 transparent;}
html[data-theme="dark"] ::-webkit-scrollbar-thumb{background:#334155;border-radius:8px;}
html[data-theme="dark"] ::-webkit-scrollbar-track{background:transparent;}
/* SweetAlert2 popups */
html[data-theme="dark"] .swal2-popup{background:#162033;color:#e2e8f0;border:1px solid var(--ss-line);}
html[data-theme="dark"] .swal2-title{color:#f1f5f9;}
html[data-theme="dark"] .swal2-html-container{color:#cbd5e1;}
html[data-theme="dark"] .swal2-container.swal2-backdrop-show{background:rgba(2,6,23,.72);}
html[data-theme="dark"] .swal2-input,html[data-theme="dark"] .swal2-textarea,html[data-theme="dark"] .swal2-select{background:#0f1626;color:#e2e8f0;border-color:var(--ss-line-2);}
html[data-theme="dark"] .swal2-icon.swal2-success [class^=swal2-success-circular-line],html[data-theme="dark"] .swal2-icon.swal2-success .swal2-success-fix{background:#162033!important;}
html[data-theme="dark"] .swal2-close{color:#94a3b8;}
/* public site */
html[data-theme="dark"] .public-nav{background:rgba(15,23,42,.94);box-shadow:0 5px 20px rgba(0,0,0,.45);}
html[data-theme="dark"] .support-brand,html[data-theme="dark"] .support-brand-text{color:#e2e8f0!important;}
html[data-theme="dark"] .public-links a{color:#cbd5e1;}
html[data-theme="dark"] .nav-toggle{background:var(--ss-raise);border-color:var(--ss-line-2);color:#e2e8f0;}
html[data-theme="dark"] .support-login-card,html[data-theme="dark"] .support-faq-card{background:var(--ss-surface);border-color:var(--ss-line);}
html[data-theme="dark"] .support-faq-card h3,html[data-theme="dark"] .support-login-card h2{color:#f1f5f9;}
