/* Flexibility layer + responsive/robust UI helpers */
html,body{max-width:100%;overflow-x:clip}
main{min-width:0}
main img,main video,main iframe{max-width:100%}
.tip{display:inline-grid;place-items:center;width:16px;height:16px;border-radius:999px;background:#e2e8f0;color:#475569;font-size:10px;font-weight:700;cursor:help;position:relative;vertical-align:middle}
.tip:hover::after,.tip:focus::after{content:attr(data-tip);position:absolute;z-index:60;left:50%;bottom:calc(100% + 6px);transform:translateX(-50%);width:max-content;max-width:240px;background:#0b1230;color:#fff;font-weight:400;font-size:12px;line-height:1.35;padding:.45rem .6rem;border-radius:8px;text-align:left;white-space:normal;box-shadow:0 6px 20px rgba(0,0,0,.25)}
.net-banner{position:sticky;top:64px;z-index:29;display:flex;align-items:center;gap:.6rem;background:#fef3c7;color:#92400e;padding:.55rem 1rem;font-size:.85rem;border-bottom:1px solid #fcd34d}
html.dark .net-banner{background:#3b2f0b;color:#fde68a;border-color:#78560f}
.tap{min-height:40px;min-width:40px;justify-content:center}
@media (pointer:coarse){.btn{min-height:42px}.inp{min-height:42px}}
.m-actionbar{display:none}
@media (max-width:639px){
  .m-actionbar{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:35;gap:.5rem;padding:.6rem 1rem calc(.6rem + env(safe-area-inset-bottom));background:rgba(255,255,255,.95);backdrop-filter:blur(8px);border-top:1px solid #e5e7eb}
  html.dark .m-actionbar{background:rgba(11,16,32,.95);border-color:#1f2a4d}
  .m-actionbar .btn{flex:1;justify-content:center;min-height:46px}
  .qform{padding-bottom:5rem}
  .toast-safe{bottom:5rem}
}
/* list tables become stacked cards on phones */
@media (max-width:767px){
  table.rtable,table.rtable tbody{display:block;width:100%}
  table.rtable thead{display:none}
  table.rtable tr[data-row]{display:block;position:relative;margin:.6rem;padding:.55rem .4rem;border:1px solid #e5e7eb;border-radius:14px;background:#fff}
  html.dark table.rtable tr[data-row]{background:#111a3f;border-color:#1f2a4d}
  table.rtable tr[data-row] td{display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:.3rem .6rem!important;width:auto;border:0}
  table.rtable tr[data-row] td[data-lbl]::before{content:attr(data-lbl);font-size:.66rem;text-transform:uppercase;letter-spacing:.06em;color:#94a3b8;flex:0 0 auto}
  table.rtable tr[data-row] td:last-child{justify-content:flex-end;opacity:1}
  table.rtable tr[data-row] td:first-child{position:absolute;right:.4rem;top:.4rem;padding:0!important;width:auto}
  table.rtable tr[data-row] td:last-child .btn{min-height:40px;min-width:40px;justify-content:center}
}
/* builder / theme / calendar */
.fx-card{background:#fff;border:1px solid #e5e7eb;border-radius:14px}
html.dark .fx-card{background:#111a3f;border-color:#1f2a4d}
.sec-item{display:flex;align-items:center;gap:.6rem;padding:.6rem .7rem;border:1px solid #e5e7eb;border-radius:12px;background:#fff;cursor:pointer}
.sec-item.on{border-color:#4f46e5;box-shadow:0 0 0 3px rgba(79,70,229,.14)}
html.dark .sec-item{background:#111a3f;border-color:#1f2a4d}
.gal-item{display:flex;flex-direction:column;align-items:center;gap:.25rem;padding:.6rem .3rem;border:1px dashed #cbd5e1;border-radius:12px;font-size:.72rem;text-align:center;cursor:grab;background:#fff}
.gal-item:hover{border-color:#4f46e5;color:#4338ca}
html.dark .gal-item{background:#111a3f;border-color:#2b3868}
.rte{min-height:140px;border:1px solid #d1d5db;border-radius:0 0 10px 10px;padding:.7rem;font-size:.9rem;outline:none;background:#fff}
.rte:focus{border-color:#4f46e5}html.dark .rte{background:#0b1230;border-color:#2b3868}
.rte-bar{display:flex;gap:.25rem;flex-wrap:wrap;border:1px solid #d1d5db;border-bottom:0;border-radius:10px 10px 0 0;padding:.3rem;background:#f8fafc}
html.dark .rte-bar{background:#111a3f;border-color:#2b3868}
.rte-bar button{min-width:34px;min-height:34px;border-radius:8px;font-weight:700;font-size:.8rem}.rte-bar button:hover{background:#e0e7ff}
.frame-wrap{border:1px solid #e5e7eb;border-radius:14px;overflow:hidden;background:#f1f5f9;display:flex;justify-content:center}
.frame-wrap iframe{border:0;background:#fff;height:70vh;width:100%;transition:width .2s}
.frame-wrap.mobile iframe{width:390px;max-width:100%}
.cal-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:1px;background:#e5e7eb;border:1px solid #e5e7eb;border-radius:14px;overflow:hidden}
html.dark .cal-grid{background:#1f2a4d;border-color:#1f2a4d}
.cal-day{background:#fff;min-height:96px;padding:.3rem;font-size:.72rem;min-width:0}
html.dark .cal-day{background:#0f1636}
.cal-day.other{background:#f8fafc;color:#94a3b8}html.dark .cal-day.other{background:#0b1230}
.cal-day.hover{outline:2px solid #4f46e5;outline-offset:-2px}
.cal-day.today .n{background:#4f46e5;color:#fff;border-radius:999px;padding:0 .35rem}
.cal-week .cal-day{min-height:260px}
.cal-ev{display:block;width:100%;text-align:left;border-radius:6px;padding:.15rem .35rem;margin-top:.2rem;font-size:.7rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:grab;border-left:3px solid}
.cal-ev.emerald{background:#ecfdf5;border-color:#10b981;color:#065f46}.cal-ev.rose{background:#fff1f2;border-color:#f43f5e;color:#9f1239}
.cal-ev.amber{background:#fffbeb;border-color:#f59e0b;color:#92400e}.cal-ev.sky{background:#f0f9ff;border-color:#0ea5e9;color:#075985}
@media (max-width:640px){.cal-day{min-height:64px;font-size:.65rem}.cal-ev{font-size:.62rem;padding:.1rem .2rem}}
.shade{flex:1;height:34px;display:grid;place-items:center;font-size:.6rem;font-weight:600}
.switch{position:relative;width:44px;height:24px;border-radius:999px;background:#cbd5e1;transition:.15s;flex:0 0 auto}
.switch::after{content:"";position:absolute;top:2px;left:2px;width:20px;height:20px;border-radius:999px;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3);transition:.15s}
.switch[aria-checked=true]{background:#10b981}.switch[aria-checked=true]::after{transform:translateX(20px)}
.empty-state{text-align:center;padding:3rem 1rem;color:#64748b}
.skel-line{height:14px;border-radius:8px;background:linear-gradient(90deg,#eef1f6 25%,#f8fafc 37%,#eef1f6 63%);background-size:800px 100%;animation:shimmer 1.3s infinite linear}

/* Leaflet maps in the dashboard */
.qmap{position:relative;z-index:0;isolation:isolate}
.qmap .leaflet-container{width:100%;height:100%;font:inherit}
.dark .qmap .leaflet-tile-pane{filter:invert(1) hue-rotate(180deg) brightness(.92) contrast(.92) saturate(.6)}
.dark .qmap .leaflet-control-attribution{background:rgba(15,23,42,.8);color:#94a3b8}
.dark .qmap .leaflet-control-attribution a{color:#a5b4fc}
