/* AquaFlow system workspace — scoped layout */
#system-dialog{width:min(900px,100vw)!important;max-width:100vw!important;height:min(860px,100dvh)!important;max-height:100dvh!important;padding:0!important;border:0!important;border-radius:20px!important;background:#f3f7fc;color:#173451;overflow:hidden!important}
#system-dialog>form{display:flex!important;flex-direction:column!important;height:100%!important;max-height:100%!important;min-height:0;padding:0!important;gap:0!important;overflow:hidden!important}
#system-dialog .dialog-head{position:static!important;flex:none;padding:18px 22px!important;margin:0!important;background:#fff;border-bottom:1px solid #dce7f2;min-height:0!important}
#system-dialog .dialog-head h2{font-size:23px!important;line-height:1.3;margin:4px 0 0!important}
#system-dialog .dialog-head small{font-size:10px!important;letter-spacing:.1em}
#system-dialog .icon-btn{width:44px!important;height:44px!important;min-height:44px!important;border:1px solid #d6e4f1;border-radius:12px!important;background:#f5f9ff;font-size:26px!important;box-shadow:none!important}
#system-dialog .system-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;flex:none;padding:12px 20px;background:#fff;border-bottom:1px solid #dce7f2}
#system-dialog .system-tabs button{min-height:44px;border:0;border-radius:10px;background:#f0f5fa;color:#536e85;font-size:14px;font-weight:700}
#system-dialog .system-tabs button[aria-pressed=true]{background:#0878ef;color:#fff}
#system-dialog .system-scroll{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:20px}
#system-dialog .system-panel{margin:0!important;padding:20px!important;border:1px solid #dce7f2!important;border-radius:16px!important;box-shadow:none!important;background:#fff}
#system-dialog [hidden]{display:none!important}
#system-dialog .section-head{gap:12px;margin:0 0 12px!important;padding:0!important;align-items:center}
#system-dialog h3{font-size:20px!important;margin:4px 0!important;line-height:1.3}
#system-dialog .section-head small{font-size:10px!important;letter-spacing:.08em}
#system-dialog #backup-now{padding:0 14px;min-height:44px;white-space:nowrap;border-radius:10px;font-size:13px}
#system-dialog .system-note{margin:0 0 16px;font-size:13px;line-height:1.6;color:#586f86}
#system-dialog .system-field{display:grid;gap:6px;font-size:12px;color:#506980;min-width:0}
#system-dialog .system-field input,#system-dialog .system-field select{width:100%;max-width:100%;min-width:0;min-height:44px;padding:8px 10px;border:1px solid #cdddeb;border-radius:10px;font-size:16px;background:#fff;box-sizing:border-box}
#system-dialog .system-filters{display:grid;grid-template-columns:minmax(0,1fr) 180px;gap:10px}
#system-dialog .system-count{font-size:12px;color:#62788d;margin:14px 0 10px}
#system-dialog #backup-list,#system-dialog #audit-list{display:grid;gap:10px}
#system-dialog .system-backup-card{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:14px;border:1px solid #e1eaf3;border-radius:12px;background:#fbfdff;min-width:0}
#system-dialog .system-backup-copy{display:grid;gap:6px;min-width:0}
#system-dialog .system-tag{display:inline-block;width:fit-content;max-width:100%;padding:5px 9px;border-radius:7px;background:#eaf3ff;color:#086bcf;font-size:12px!important;font-weight:700;letter-spacing:0!important;line-height:1.4;word-break:normal;overflow-wrap:break-word}
#system-dialog .system-backup-copy>strong{font-size:17px}
#system-dialog .system-backup-card>.edit{flex:none;min-width:86px;min-height:44px;padding:8px 12px;border:1px solid #cbddeb;border-radius:10px;background:white;color:#285473;font-size:13px;white-space:nowrap}
#system-dialog details{min-width:0;font-size:12px;color:#62778b}
#system-dialog details summary{cursor:pointer;min-height:28px;padding:5px 0}
#system-dialog details small{font-size:12px!important;line-height:1.5;letter-spacing:0!important;font-weight:400!important;color:#5c7085!important;overflow-wrap:anywhere;word-break:normal}
#system-dialog .system-audit-card{display:grid;gap:7px;min-width:0;border:1px solid #e1eaf3;border-radius:12px;padding:14px;background:#fff}
#system-dialog .system-row-head{display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:space-between}
#system-dialog .system-date{font-size:12px;color:#62788d}
#system-dialog .system-audit-card>strong{font-size:16px;line-height:1.4;overflow-wrap:anywhere}
#system-dialog .system-audit-card p{margin:0;font-size:13px;color:#536e85;line-height:1.5;overflow-wrap:anywhere}
#system-dialog .system-audit-card .system-reason{padding:8px 10px;border-radius:8px;background:#f4f8fc}
#system-dialog .system-export-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
#system-dialog .system-export-grid a{display:grid;gap:6px;min-height:82px;padding:16px;text-decoration:none;border:1px solid #d9e6f2;border-radius:12px;background:#f8fbff;color:#086bcf}
#system-dialog .system-export-grid strong{font-size:15px}
#system-dialog .system-export-grid span{font-size:12px;color:#61788d}
#system-dialog .dialog-actions{position:static!important;flex:none;display:flex!important;justify-content:space-between;align-items:center;margin:0!important;padding:12px 20px max(12px,env(safe-area-inset-bottom))!important;background:#fff;border-top:1px solid #dce7f2;box-shadow:none!important}
#system-dialog .dialog-actions>span{font-size:11px;color:#718398}
#system-dialog .dialog-actions .btn{width:auto!important;min-width:100px;min-height:44px;font-size:14px;border-radius:10px}
#system-dialog button:focus-visible,#system-dialog a:focus-visible,#system-dialog input:focus-visible,#system-dialog select:focus-visible{outline:3px solid #80baff;outline-offset:2px}
@media(max-width:600px){#system-dialog{width:100vw!important;height:100dvh!important;border-radius:0!important;margin:0!important;inset:0!important}#system-dialog .dialog-head{padding:14px 16px!important}#system-dialog .dialog-head h2{font-size:21px!important}#system-dialog .system-tabs{padding:10px 12px}#system-dialog .system-scroll{padding:12px}#system-dialog .system-panel{padding:14px!important}#system-dialog .system-filters{grid-template-columns:minmax(0,1fr)}#system-dialog .section-head h3{font-size:18px!important}#system-dialog .system-export-grid{grid-template-columns:minmax(0,1fr)}#system-dialog .dialog-actions{padding-left:16px!important;padding-right:16px!important}}


/* AquaFlow v4.13.0 · Enterprise Health Dashboard */
.health-overall{display:flex;flex-direction:column;gap:4px;margin:0 0 14px;padding:14px 16px;border:1px solid #b9e3cd;border-radius:16px;background:#f2fbf6}.health-overall strong{font-size:16px;color:#12613b}.health-overall span{font-size:13px;color:#4b6356}.health-overall.has-warning{border-color:#f0d09b;background:#fff8eb}.health-overall.has-warning strong{color:#945814}.health-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.health-card{min-width:0;padding:13px 14px;border:1px solid #dce6ef;border-radius:14px;background:#fff;box-shadow:0 4px 14px rgba(21,49,75,.04)}.health-card header{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}.health-card header strong{font-size:13px;color:#304457}.health-card header span{white-space:nowrap;border-radius:999px;padding:4px 8px;font-size:10px;font-weight:800;letter-spacing:.02em}.health-card>b{display:block;overflow-wrap:anywhere;font-size:18px;color:#172b3c}.health-card p{margin:6px 0 0;font-size:12px;line-height:1.45;color:#657789}.health-card.health-ok{border-color:#c8ead7}.health-card.health-ok header span{background:#eaf8f0;color:#177044}.health-card.health-warn{border-color:#f0d09b;background:#fffdfa}.health-card.health-warn header span{background:#fff0d4;color:#9a5e15}.health-card.health-neutral header span{background:#edf3f8;color:#526b80}.health-warnings{margin-top:12px;padding:12px 14px;border:1px solid #f0d09b;border-radius:14px;background:#fff8eb;color:#80531e}.health-warnings strong{display:block;margin-bottom:4px}.health-warnings p{margin:4px 0;font-size:12px}.health-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}.health-actions .btn{margin:0;white-space:nowrap}.system-health-panel .section-head{align-items:center}@media(max-width:700px){.health-grid{grid-template-columns:1fr}.health-card>b{font-size:17px}}

/* V31.9.4 — restore directly from audit log */
.system-audit-actions{display:flex;justify-content:flex-end;margin-top:12px}
.system-audit-restore{min-height:42px;padding:8px 16px;font-weight:800}
.system-restore-ok{margin:10px 0 0;color:var(--success,#087a55);font-weight:800}


/* AquaFlow V32.2 — Recovery Health Clarity */
#system-dialog .system-tabs{grid-template-columns:repeat(5,minmax(0,1fr))}
#system-dialog #recovery-list,#system-dialog #recovery-history-list{display:grid;gap:10px}
.recovery-summary{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:0 0 14px}
.recovery-summary article{min-width:0;padding:12px 14px;border:1px solid #dce7f2;border-radius:14px;background:#f8fbff}
.recovery-summary small{display:block;font-size:10px;font-weight:800;letter-spacing:.05em;color:#678099}
.recovery-summary strong{display:block;margin-top:5px;font-size:22px;color:#173451}
.recovery-filters{grid-template-columns:minmax(0,1fr) 170px 130px 170px!important}
.recovery-card{display:grid;gap:9px;padding:14px;border:1px solid #dce7f2;border-radius:14px;background:#fff}
.recovery-card.is-safe{border-color:#bfe6d0;background:#fbfffd}.recovery-card.is-attention{border-color:#efd09c;background:#fffdfa}.recovery-card.is-history{border-color:#dde7f0;background:#fbfcfe}
.recovery-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}.recovery-card-head>div{min-width:0}
.recovery-card-head small{display:block;color:#6b8094;font-size:11px}.recovery-card-head strong{display:block;margin-top:3px;font-size:17px;line-height:1.35;overflow-wrap:anywhere}
.recovery-state{flex:none;border-radius:999px;padding:5px 9px;font-size:10px;font-weight:800;white-space:nowrap}.recovery-state.safe{background:#e9f8ef;color:#177044}.recovery-state.attention{background:#fff0d4;color:#956017}.recovery-state.history{background:#edf3f8;color:#587087}
.recovery-meta{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.recovery-meta span{min-width:0;padding:8px 10px;border-radius:10px;background:#f3f7fb;color:#506980;font-size:11px}.recovery-meta b{display:block;margin-top:2px;color:#193753;font-size:13px;overflow-wrap:anywhere}
.recovery-preview{margin:0;padding:9px 11px;border-radius:10px;background:#eef6ff;color:#315a7c;font-size:12px;line-height:1.5}.recovery-blockers{margin:0;padding:9px 11px;border-radius:10px;background:#fff4df;color:#80531e;font-size:12px;line-height:1.5}.recovery-blockers.is-history{background:#f1f5f9;color:#5d7185}
.recovery-card-actions{display:flex;justify-content:flex-end}.recovery-card-actions .btn{min-height:42px;margin:0;padding:8px 16px;font-weight:800}
.recovery-history{margin-top:14px}.recovery-history summary{cursor:pointer;font-weight:800;color:#36536d}.recovery-history-item{padding:10px 12px;border:1px solid #e1eaf3;border-radius:10px;background:#fbfdff;font-size:12px;color:#536e85}.recovery-history-item strong{color:#173451}
@media(max-width:700px){#system-dialog .system-tabs{grid-template-columns:repeat(2,minmax(0,1fr))}.recovery-summary{grid-template-columns:repeat(2,minmax(0,1fr))}.recovery-summary article{padding:10px 12px}.recovery-filters{grid-template-columns:1fr!important}.recovery-meta{grid-template-columns:1fr 1fr}.recovery-card-head{align-items:center}}


/* AquaFlow V34.1.2 — iPhone System & Data dialog layout hotfix.
   The generic mobile dialog selector must not shrink this specialist workspace.
   Keep header/action/tabs/footer fixed and let only .system-scroll move. */
#system-dialog #sepay-admin-history{
  flex:none;
  margin:12px 20px 0;
  width:auto;
  min-height:44px;
}
@media(max-width:600px){
  #system-dialog{
    width:100vw!important;
    max-width:100vw!important;
    height:100dvh!important;
    max-height:100dvh!important;
    margin:0!important;
    inset:0!important;
    border-radius:0!important;
  }
  #system-dialog>form{
    padding:0!important;
    height:100%!important;
    max-height:100%!important;
    overflow:hidden!important;
  }
  #system-dialog #sepay-admin-history{
    margin:8px 12px 0;
    min-height:42px;
  }
  #system-dialog .system-tabs{
    display:flex!important;
    grid-template-columns:none!important;
    gap:7px!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
    scroll-snap-type:x proximity;
    padding:8px 12px 10px!important;
  }
  #system-dialog .system-tabs::-webkit-scrollbar{display:none}
  #system-dialog .system-tabs button{
    flex:0 0 auto!important;
    min-width:108px;
    min-height:40px!important;
    padding:0 14px;
    scroll-snap-align:start;
    white-space:nowrap;
  }
  #system-dialog .system-scroll{
    flex:1 1 auto!important;
    min-height:0!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior-y:contain;
    padding:12px!important;
    scroll-padding-top:12px;
  }
  #system-dialog .dialog-actions{
    flex:none!important;
    position:static!important;
    margin:0!important;
    padding:10px 16px max(10px,env(safe-area-inset-bottom))!important;
  }
  #system-dialog .system-health-panel .section-head{
    align-items:flex-start!important;
    flex-wrap:wrap;
  }
  #system-dialog .health-actions{
    width:100%;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
  }
  #system-dialog .health-actions .btn{
    width:100%;
    min-width:0;
  }
}

/* AquaFlow V34.1.3 — iPhone System & Data tab/scroll final fix.
   All five tabs stay visible in one row; no horizontal tab scrolling.
   Only .system-scroll may scroll vertically. */
@media(max-width:600px){
  #system-dialog .system-tabs{
    display:grid!important;
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
    gap:4px!important;
    overflow:visible!important;
    padding:8px 8px 10px!important;
    scroll-snap-type:none!important;
  }
  #system-dialog .system-tabs button{
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    min-height:40px!important;
    padding:0 3px!important;
    font-size:clamp(10px,2.65vw,12px)!important;
    line-height:1.12!important;
    letter-spacing:-.01em!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:clip!important;
    scroll-snap-align:none!important;
  }
}
@media(max-width:350px){
  #system-dialog .system-tabs{gap:3px!important;padding-left:6px!important;padding-right:6px!important}
  #system-dialog .system-tabs button{font-size:9.5px!important;padding:0 1px!important}
}
